Skip to content

Commit

Permalink
- fixed initial guess and pre simulation for optimization
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19363 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed Mar 1, 2014
1 parent c97e66a commit 4ab1c8e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions SimulationRuntime/c/optimization/initialOptimizer/initial_guess.c
Expand Up @@ -160,9 +160,8 @@ static int initial_guess_ipopt_sim(IPOPT_DATA_ *iData,SOLVER_INFO* solverInfo)

for(i=0, k=1, v=iData->v + iData->nv; i<iData->nsi; ++i){
for(jj=0; jj<iData->deg; ++jj, ++k){

smallIntSolverStep(iData, solverInfo, iData->time[k]);
iData->data->localData[0]->timeValue = solverInfo->currentTime = iData->time[k];
smallIntSolverStep(iData, solverInfo, iData->time[k]);
//iData->data->localData[0]->timeValue = solverInfo->currentTime = iData->time[k];

if(printGuess)
printf("\ndone: time[%i] = %g", k, iData->time[k]);
Expand Down Expand Up @@ -287,22 +286,25 @@ static int smallIntSolverStep(IPOPT_DATA_ *iData, SOLVER_INFO* solverInfo, doubl
int iter;
int err;

while(iData->data->localData[0]->timeValue < tstop){
solverInfo->currentTime = iData->data->localData[1]->timeValue;
while(solverInfo->currentTime < tstop){
a = 1.0;
iter = 0;
do{

solverInfo->currentStepSize = a*(tstop - iData->data->localData[0]->timeValue);
solverInfo->currentStepSize = a*(tstop - solverInfo->currentTime);
err = dasrt_step(iData->data, solverInfo);
a *= 0.5;
if(++iter > 10)
break;
}while(err < 0);

solverInfo->currentTime = iData->data->localData[0]->timeValue;

if(iData->data->localData[0]->timeValue < tstop)
if(iData->data->localData[0]->timeValue < tstop){
rotateRingBuffer(iData->data->simulationData, 1, (void**) iData->data->localData);
solverInfo->currentTime = iData->data->localData[0]->timeValue;
}else{
solverInfo->currentTime = tstop;
}
}
return 0;
}
Expand Down

0 comments on commit 4ab1c8e

Please sign in to comment.