Skip to content

Commit

Permalink
- LOG_STATS adjust for optimiziation
Browse files Browse the repository at this point in the history
- codestyle for hess


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18151 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed Nov 15, 2013
1 parent 46d48c1 commit e1e3296
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
24 changes: 13 additions & 11 deletions SimulationRuntime/c/optimization/lagrangeFun/ipopt_hessian.c
Expand Up @@ -103,7 +103,6 @@ Bool ipopt_h(int n, double *v, Bool new_x, double obj_factor, int m, double *lam
}
else
{
/*obj_factor*/
double *x;
double *ll;
int ii;
Expand All @@ -115,32 +114,34 @@ Bool ipopt_h(int n, double *v, Bool new_x, double obj_factor, int m, double *lam
r = 0;
c = 0;
k = 0;

for(ii = 0; ii <1; ++ii)
{
for(j = 0; j<iData->nx; ++j)
iData->sh[j] = iData->d1[4]*(lambda[j] - lambda[j + iData->nx]) + lambda[j + 2*iData->nx];

for(p = 0, x= v, ll = lambda;p <iData->deg+1;++p, x += iData->nv)
{
mayer_yes = iData->mayer && ii+1 == iData->nsi && p == iData->deg;
if(!p)
{
for(j = 0; j<iData->nx; ++j)
iData->sh[j] = iData->d1[4]*(ll[j] - ll[j + iData->nx]) + ll[j + 2*iData->nx];
num_hessian(x, iData->time[p], iData,iData->sh,iData->lagrange,mayer_yes,obj_factor);
}else{
num_hessian(x, iData->time[p], iData, ll,iData->lagrange,mayer_yes,obj_factor);
}

if(p){
num_hessian(x, iData->time[p], iData, ll,iData->lagrange,mayer_yes,obj_factor);
}else{
num_hessian(x, iData->time[p], iData, iData->sh,iData->lagrange,mayer_yes,obj_factor);
}

for(i=0;i< iData->nv;++i)
for(j = 0; j< i+1; ++j)
{
sumLagrange(iData, &sum, ii, i, j, p, mayer_yes);
values[k++] = sum;
}

r += iData->nv;
c += iData->nv;

if(p >0)
if(p)
ll += iData->nx;

}

}
Expand Down Expand Up @@ -231,6 +232,7 @@ static int num_hessian(double *v, double t, IPOPT_DATA_ *iData, double *lambda,
iData->H[l][i][j] = lambda[l]*(iData->J[l][j] - iData->J0[l][j])/h;
else
iData->H[l][i][j] = (long double) 0.0;

iData->H[l][j][i] = iData->H[l][i][j];
}
}
Expand Down
12 changes: 10 additions & 2 deletions SimulationRuntime/c/simulation/solver/solver_main.c
Expand Up @@ -440,6 +440,7 @@ int finishSimulation(DATA* data, SOLVER_INFO* solverInfo, const char* outputVari

if(ACTIVE_STREAM(LOG_STATS))
{
char * contextRun;
rt_accumulate(SIM_TIMER_TOTAL);

INFO(LOG_STATS, "### STATISTICS ###");
Expand All @@ -452,7 +453,14 @@ int finishSimulation(DATA* data, SOLVER_INFO* solverInfo, const char* outputVari
INFO2(LOG_STATS, "%12gs [%5.1f%%] creating output-file", rt_accumulated(SIM_TIMER_OUTPUT), rt_accumulated(SIM_TIMER_OUTPUT)/rt_accumulated(SIM_TIMER_TOTAL)*100.0);
INFO2(LOG_STATS, "%12gs [%5.1f%%] event-handling", rt_accumulated(SIM_TIMER_EVENT), rt_accumulated(SIM_TIMER_EVENT)/rt_accumulated(SIM_TIMER_TOTAL)*100.0);
INFO2(LOG_STATS, "%12gs [%5.1f%%] overhead", rt_accumulated(SIM_TIMER_OVERHEAD), rt_accumulated(SIM_TIMER_OVERHEAD)/rt_accumulated(SIM_TIMER_TOTAL)*100.0);
INFO2(LOG_STATS, "%12gs [%5.1f%%] simulation", rt_accumulated(SIM_TIMER_TOTAL)-rt_accumulated(SIM_TIMER_OVERHEAD)-rt_accumulated(SIM_TIMER_EVENT)-rt_accumulated(SIM_TIMER_OUTPUT)-rt_accumulated(SIM_TIMER_STEP)-rt_accumulated(SIM_TIMER_INIT)-rt_accumulated(SIM_TIMER_PREINIT), (rt_accumulated(SIM_TIMER_TOTAL)-rt_accumulated(SIM_TIMER_OVERHEAD)-rt_accumulated(SIM_TIMER_EVENT)-rt_accumulated(SIM_TIMER_OUTPUT)-rt_accumulated(SIM_TIMER_STEP)-rt_accumulated(SIM_TIMER_INIT)-rt_accumulated(SIM_TIMER_PREINIT))/rt_accumulated(SIM_TIMER_TOTAL)*100.0);

if(solverInfo->solverMethod != S_OPTIMIZATION)
contextRun = "simulation";
else
contextRun = "optimization";

INFO3(LOG_STATS, "%12gs [%5.1f%%] %s", contextRun, rt_accumulated(SIM_TIMER_TOTAL)-rt_accumulated(SIM_TIMER_OVERHEAD)-rt_accumulated(SIM_TIMER_EVENT)-rt_accumulated(SIM_TIMER_OUTPUT)-rt_accumulated(SIM_TIMER_STEP)-rt_accumulated(SIM_TIMER_INIT)-rt_accumulated(SIM_TIMER_PREINIT), (rt_accumulated(SIM_TIMER_TOTAL)-rt_accumulated(SIM_TIMER_OVERHEAD)-rt_accumulated(SIM_TIMER_EVENT)-rt_accumulated(SIM_TIMER_OUTPUT)-rt_accumulated(SIM_TIMER_STEP)-rt_accumulated(SIM_TIMER_INIT)-rt_accumulated(SIM_TIMER_PREINIT))/rt_accumulated(SIM_TIMER_TOTAL)*100.0);

INFO2(LOG_STATS, "%12gs [%5.1f%%] total", rt_accumulated(SIM_TIMER_TOTAL), rt_accumulated(SIM_TIMER_TOTAL)/rt_accumulated(SIM_TIMER_TOTAL)*100.0);
RELEASE(LOG_STATS);

Expand All @@ -476,7 +484,7 @@ int finishSimulation(DATA* data, SOLVER_INFO* solverInfo, const char* outputVari
INFO1(LOG_STATS, "%5d error test failures", ((DASSL_DATA*)solverInfo->solverData)->dasslStatistics[3]);
INFO1(LOG_STATS, "%5d convergence test failures", ((DASSL_DATA*)solverInfo->solverData)->dasslStatistics[4]);
}
else
else if(solverInfo->solverMethod != S_OPTIMIZATION)
{
INFO(LOG_STATS, "sorry - no solver statistics available. [not yet implemented]");
}
Expand Down

0 comments on commit e1e3296

Please sign in to comment.