Skip to content

Commit c987ace

Browse files
author
Vitalij Ruge
committed
- fixed start-values in dyn. optimization
- added test git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22160 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 41534e6 commit c987ace

File tree

1 file changed

+9
-12
lines changed
  • SimulationRuntime/c/optimization/DataManagement

1 file changed

+9
-12
lines changed

SimulationRuntime/c/optimization/DataManagement/MoveData.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -722,32 +722,29 @@ static inline void pickUpStates(OptData* optData){
722722
int i, j;
723723
double start_value;
724724
char buffer[200];
725-
726-
--n;
727-
if(n != optData->dim.nx)
728-
warningStreamPrint(LOG_STDOUT, 0, "size %i != %i of %s", n, optData->dim.nx, cflags);
729-
725+
const int nReal = optData->data->modelData.nVariablesReal;
730726
rewind(pFile);
731727
for(i =0; i< n; ++i){
732728
fscanf(pFile, "%s", buffer);
733-
fscanf(pFile, "%lf", &start_value);
734-
735-
printf("\n[%i]set %s.start %g", i, buffer,start_value);
729+
if (fscanf(pFile, "%lf", &start_value) <= 0) continue;
736730

737-
for(j = 0, b = 0; j < optData->dim.nx; ++j){
731+
for(j = 0, b = 0; j < nReal; ++j){
738732
if(!strcmp(optData->data->modelData.realVarsData[j].info.name, buffer)){
739-
optData->data->localData[0]->realVars[i] = start_value;
740-
optData->data->localData[1]->realVars[i] = start_value;
741-
optData->data->localData[2]->realVars[i] = start_value;
733+
optData->data->localData[0]->realVars[j] = start_value;
734+
optData->data->localData[1]->realVars[j] = start_value;
735+
optData->data->localData[2]->realVars[j] = start_value;
742736
optData->v0[i] = start_value;
743737
b = 1;
744738
continue;
745739
}
746740
}
747741
if(!b)
748742
warningStreamPrint(LOG_STDOUT, 0, "it was impossible to set %s.start %g", buffer,start_value);
743+
else
744+
printf("\n[%i]set %s.start %g", i, buffer,start_value);
749745

750746
}
747+
fclose(pFile);
751748
printf("\n");
752749
/*update system*/
753750
optData->data->callback->input_function(optData->data);

0 commit comments

Comments
 (0)