Skip to content

Commit

Permalink
- simplify constraints (optimization)
Browse files Browse the repository at this point in the history
- fixed jacobian size (optimization)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18738 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed Jan 23, 2014
1 parent b5b9fb8 commit c5fc1bf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
20 changes: 12 additions & 8 deletions Compiler/BackEnd/BackendEquation.mo
Expand Up @@ -2182,14 +2182,18 @@ algorithm
local
DAE.Exp rhs,e1,e2;
DAE.ComponentRef lhs;
case (lhs, DAE.RELATION(e1,DAE.LESS(_),e2,_,_), _)
then {BackendDAE.SOLVED_EQUATION(lhs,DAE.BINARY(e1,DAE.SUB(DAE.T_REAL_DEFAULT),e2),Source,false)};
case (lhs, DAE.RELATION(e1,DAE.LESSEQ(_),e2,_,_), _)
then {BackendDAE.SOLVED_EQUATION(lhs,DAE.BINARY(e1,DAE.SUB(DAE.T_REAL_DEFAULT),e2),Source,false)};
case (lhs, DAE.RELATION(e1,DAE.GREATER(_),e2,_,_), _)
then {BackendDAE.SOLVED_EQUATION(lhs,DAE.BINARY(e2,DAE.SUB(DAE.T_REAL_DEFAULT),e1),Source,false)};
case (lhs, DAE.RELATION(e1,DAE.GREATEREQ(_),e2,_,_), _)
then {BackendDAE.SOLVED_EQUATION(lhs,DAE.BINARY(e2,DAE.SUB(DAE.T_REAL_DEFAULT),e1),Source,false)};
case (lhs, DAE.RELATION(e1,DAE.LESS(_),e2,_,_), _) equation
(rhs,_) = ExpressionSimplify.simplify(DAE.BINARY(e1,DAE.SUB(DAE.T_REAL_DEFAULT),e2));
then {BackendDAE.SOLVED_EQUATION(lhs,rhs,Source,false)};
case (lhs, DAE.RELATION(e1,DAE.LESSEQ(_),e2,_,_), _) equation
(rhs,_) = ExpressionSimplify.simplify(DAE.BINARY(e1,DAE.SUB(DAE.T_REAL_DEFAULT),e2));
then {BackendDAE.SOLVED_EQUATION(lhs,rhs,Source,false)};
case (lhs, DAE.RELATION(e1,DAE.GREATER(_),e2,_,_), _) equation
(rhs,_) = ExpressionSimplify.simplify(DAE.BINARY(e2,DAE.SUB(DAE.T_REAL_DEFAULT),e1));
then {BackendDAE.SOLVED_EQUATION(lhs,rhs,Source,false)};
case (lhs, DAE.RELATION(e1,DAE.GREATEREQ(_),e2,_,_), _) equation
(rhs,_) = ExpressionSimplify.simplify(DAE.BINARY(e2,DAE.SUB(DAE.T_REAL_DEFAULT),e1));
then {BackendDAE.SOLVED_EQUATION(lhs, rhs,Source,false)};
else then {};
end match;
end generateResidualfromRealtion;
Expand Down
Expand Up @@ -257,7 +257,7 @@ int loadDAEmodel(DATA *data, IPOPT_DATA_ *iData)

/* iData->njac = iData->nX*iData->nsi*(iData->nv + iData->deg) + iData->nX*(iData->nv-1); */
local_jac_struct(iData, &id);
iData->njac = iData->deg*(iData->nlocalJac-iData->nx+iData->nsi*iData->nlocalJac+iData->deg*iData->nsi*iData->nx)-iData->nc*iData->deg*id;
iData->njac = iData->deg*(iData->nlocalJac-iData->nx+iData->nsi*iData->nlocalJac+iData->deg*iData->nsi*iData->nx)-iData->deg*id;
iData->nhess = 0.5*iData->nv*(iData->nv + 1)*(1+iData->deg*iData->nsi);

allocateIpoptData(iData);
Expand Down Expand Up @@ -455,7 +455,7 @@ static int local_jac_struct(IPOPT_DATA_ *iData, int * nng)
short **Hg;
int i,j,l,ii,nx, id;
int *cC,*lindex;
int nJ = (iData->nx+iData->nc);
int nJ = (int)(iData->nx+iData->nc);
id = 0;

iData->nlocalJac = 0;
Expand Down Expand Up @@ -531,7 +531,8 @@ static int local_jac_struct(IPOPT_DATA_ *iData, int * nng)

if(ACTIVE_STREAM(LOG_IPOPT))
{
for(ii = 0; ii < iData->nx; ++ii)
printf("\n***********");
for(ii = 0; ii < nJ; ++ii)
{
printf("\n");
for(j =0;j<iData->nv;++j)
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/optimization/mainOptimizer/ipoptODE.c
Expand Up @@ -135,7 +135,7 @@ int startIpopt(DATA* data, SOLVER_INFO* solverInfo, int flag)
}
/*AddIpoptStrOption(nlp, "derivative_test_print_all", "yes");*/
/* AddIpoptNumOption(nlp,"derivative_test_perturbation",1e-6); */
AddIpoptIntOption(nlp, "max_iter", 5000);
AddIpoptIntOption(nlp, "max_iter", 250);

res = IpoptSolve(nlp, iData->v, NULL, &obj, iData->mult_g, iData->mult_x_L, iData->mult_x_U, (void*)iData);

Expand Down

0 comments on commit c5fc1bf

Please sign in to comment.