Commit eb43f352 authored by Jan Philipp Haller's avatar Jan Philipp Haller
Browse files

Changes after attempted merge

parent 204e9b2d
......@@ -89,7 +89,9 @@ public class IpoptSolverGeneratorImplementation implements NLPSolverGeneratorImp
objVar = "objectiveValue" + optimizationProblem.getId();
//ToDo: modify call. Restriction: only same type? (Matrix opposed to skalar)
//Dynamic function call, better generated by vm
result = String.format("%s::solveOptimizationProblemIpOpt(%s, %s%s);\n", vm.getCallSolverName(), vm.getOptimizationVariables().get(0).getName(), objVar, knownVariables);
if(!vm.getOptimizationVariables().isEmpty()) {
result = String.format("%s::solveOptimizationProblemIpOpt(%s, %s%s);\n", vm.getCallSolverName(), vm.getOptimizationVariables().get(0).getName(), objVar, knownVariables);
}
// generate templates by view model
generateIpoptTemplates(vm, auxillaryFiles);
necessaryIncludes.add(vm.getCallSolverName());
......
......@@ -125,11 +125,13 @@ public class IpoptViewModel extends SolverViewModel {
MathMatrixVectorExpressionSymbol result = null;
MathExpressionSymbol mathExpression = getStepSize();
//ToDo: Add CoCo to ensure this always holds.
if(mathExpression.isAssignmentExpression()) {
MathAssignmentExpressionSymbol assignExpression = (MathAssignmentExpressionSymbol) mathExpression;
MathExpressionSymbol assignChildExpression = assignExpression.getExpressionSymbol();
if(mathExpression != null) {
if (mathExpression.isAssignmentExpression()) {
MathAssignmentExpressionSymbol assignExpression = (MathAssignmentExpressionSymbol) mathExpression;
MathExpressionSymbol assignChildExpression = assignExpression.getExpressionSymbol();
result = (MathMatrixVectorExpressionSymbol) assignChildExpression;
result = (MathMatrixVectorExpressionSymbol) assignChildExpression;
}
}
return result;
}
......@@ -137,28 +139,38 @@ public class IpoptViewModel extends SolverViewModel {
public String getStepSizeName(){
String result = "";
MathExpressionSymbol mathExpression = getStepSize();
//ToDo: Add CoCo to ensure this always holds.
if(mathExpression.isAssignmentExpression()) {
MathAssignmentExpressionSymbol assignExpression = (MathAssignmentExpressionSymbol) mathExpression;
result = assignExpression.getNameOfMathValue();
if(mathExpression != null) {
//ToDo: Add CoCo to ensure this always holds.
if (mathExpression.isAssignmentExpression()) {
MathAssignmentExpressionSymbol assignExpression = (MathAssignmentExpressionSymbol) mathExpression;
result = assignExpression.getNameOfMathValue();
}
}
return result;
}
public int getStepSizeMin(){
String result = "";
int result = 0;
MathMatrixVectorExpressionSymbol vectorExpressionSymbol = getStepSizeVectorSymbol();
MathNumberExpressionSymbol startExpression = (MathNumberExpressionSymbol) vectorExpressionSymbol.getStart();
return startExpression.getValue().getRealNumber().intValue();
if(vectorExpressionSymbol != null) {
MathNumberExpressionSymbol startExpression = (MathNumberExpressionSymbol) vectorExpressionSymbol.getStart();
result = startExpression.getValue().getRealNumber().intValue();
}
return result;
}
public int getStepSizeMax(){
String result = "";
int result = 0;
MathMatrixVectorExpressionSymbol vectorExpressionSymbol = getStepSizeVectorSymbol();
MathNumberExpressionSymbol endExpression = (MathNumberExpressionSymbol) vectorExpressionSymbol.getEnd();
return endExpression.getValue().getRealNumber().intValue();
if(vectorExpressionSymbol != null) {
MathNumberExpressionSymbol endExpression = (MathNumberExpressionSymbol) vectorExpressionSymbol.getEnd();
result = endExpression.getValue().getRealNumber().intValue();
}
return result;
}
public int getStepSizeCount(){
......@@ -210,11 +222,12 @@ public class IpoptViewModel extends SolverViewModel {
public String listClassesInScope(){
String result = "";
for ( Collection<Symbol> x : getIndependentVariables().get(0).getEnclosingScope().getLocalSymbols().values()){
result += ","+x.getClass().toString();
for(Symbol s : x){
result += ", "+s.getClass().toString();
if(!getIndependentVariables().isEmpty()) {
for (Collection<Symbol> x : getIndependentVariables().get(0).getEnclosingScope().getLocalSymbols().values()) {
result += "," + x.getClass().toString();
for (Symbol s : x) {
result += ", " + s.getClass().toString();
}
}
}
return result;
......
......@@ -59,7 +59,7 @@ public class GeneratorEMAMOpt2CPPTest extends AbstractSymtabTest {
@Test
public void testMPCImplementation() throws IOException {
doGenerateMathOptModel("mpcautopilot.torcsWrapper");
List<File> files = doGenerateMathOptModel("mpcautopilot.torcsWrapper");
// TODO: create reference solution
// String restPath = "testMath/optimizationSolver/";
// testFilesAreEqual(files, restPath);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment