Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
EMAM2Cpp
Commits
eb43f352
Commit
eb43f352
authored
Mar 06, 2021
by
Jan Philipp Haller
Browse files
Changes after attempted merge
parent
204e9b2d
Changes
3
Show whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/generator/cpp/mathopt/optimizationSolver/solver/ipopt/IpoptSolverGeneratorImplementation.java
View file @
eb43f352
...
...
@@ -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
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
());
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/mathopt/optimizationSolver/solver/ipopt/IpoptViewModel.java
View file @
eb43f352
...
...
@@ -125,40 +125,52 @@ public class IpoptViewModel extends SolverViewModel {
MathMatrixVectorExpressionSymbol
result
=
null
;
MathExpressionSymbol
mathExpression
=
getStepSize
();
//ToDo: Add CoCo to ensure this always holds.
if
(
mathExpression
.
isAssignmentExpression
())
{
if
(
mathExpression
!=
null
)
{
if
(
mathExpression
.
isAssignmentExpression
())
{
MathAssignmentExpressionSymbol
assignExpression
=
(
MathAssignmentExpressionSymbol
)
mathExpression
;
MathExpressionSymbol
assignChildExpression
=
assignExpression
.
getExpressionSymbol
();
result
=
(
MathMatrixVectorExpressionSymbol
)
assignChildExpression
;
}
}
return
result
;
}
public
String
getStepSizeName
(){
String
result
=
""
;
MathExpressionSymbol
mathExpression
=
getStepSize
();
if
(
mathExpression
!=
null
)
{
//ToDo: Add CoCo to ensure this always holds.
if
(
mathExpression
.
isAssignmentExpression
())
{
if
(
mathExpression
.
isAssignmentExpression
())
{
MathAssignmentExpressionSymbol
assignExpression
=
(
MathAssignmentExpressionSymbol
)
mathExpression
;
result
=
assignExpression
.
getNameOfMathValue
();
}
}
return
result
;
}
public
int
getStepSizeMin
(){
Str
in
g
result
=
""
;
in
t
result
=
0
;
MathMatrixVectorExpressionSymbol
vectorExpressionSymbol
=
getStepSizeVectorSymbol
();
if
(
vectorExpressionSymbol
!=
null
)
{
MathNumberExpressionSymbol
startExpression
=
(
MathNumberExpressionSymbol
)
vectorExpressionSymbol
.
getStart
();
return
startExpression
.
getValue
().
getRealNumber
().
intValue
();
result
=
startExpression
.
getValue
().
getRealNumber
().
intValue
();
}
return
result
;
}
public
int
getStepSizeMax
(){
Str
in
g
result
=
""
;
in
t
result
=
0
;
MathMatrixVectorExpressionSymbol
vectorExpressionSymbol
=
getStepSizeVectorSymbol
();
if
(
vectorExpressionSymbol
!=
null
)
{
MathNumberExpressionSymbol
endExpression
=
(
MathNumberExpressionSymbol
)
vectorExpressionSymbol
.
getEnd
();
return
endExpression
.
getValue
().
getRealNumber
().
intValue
();
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
;
...
...
src/test/java/de/monticore/lang/monticar/generator/mathopt/GeneratorEMAMOpt2CPPTest.java
View file @
eb43f352
...
...
@@ -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);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment