/*
*
* @author Amin Rezaee
* amin_rezaee68@yahoo.com
* amin.rezaee68@gmail.com
*/
package net.amin.mobateg.ampl;
import java.util.ArrayList;
import net.amin.mobateg.helper.variables.TCGVariable;
import net.sf.parteg.base.testcasegraph.generated.TCGNode;
import net.sf.parteg.base.testcasegraph.generated.TCGRealNode;
import net.sf.parteg.base.testcasegraph.generated.TCGTransition;
import net.sf.parteg.base.testcasegraph.ocl.TestCaseGraphHelper;
public class SmToAMPLModel {
public static String transform(TestCaseGraphHelper sm, ArrayList<TCGVariable> allVariables) {
StringBuilder result = new StringBuilder();
result.append("param Pathlength;\n\n");
for(TCGVariable var : allVariables){
result.append(ConvertToAMPL.tcgBasicVariableToAMPL(var));
result.append("\n");
}
for (TCGTransition oTCGTransition : sm.getAllTransitions()) {
result.append(ConvertToAMPL.TCGTransitionToAMPL(oTCGTransition));
result.append("\n");
}
result.append("\n");
for (TCGNode oNode : sm.getAllNodes()){
if(oNode instanceof TCGRealNode){
TCGRealNode oRealNode = (TCGRealNode) oNode;
if(oRealNode.getCondition() != null && !oRealNode.getCondition().getConjunctions().isEmpty()){
if(oRealNode.getCondition().getOriginalExpression() != null){
result.append(ConvertToAMPL.stateToAMPL(oRealNode));
result.append("\n");
}
}
}
}
result.append("\n");
return result.toString();
}
}