Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)

Forgot password? | Forgot username? | Register

Crash with an optimization problem containing a for loop

Crash with an optimization problem containing a for loop

Hi ! I am working on an optimization problem with OpenModelica and Optimica and I would like the number of optimization variables to be flexible. I tried to use a for loop to do it but OMedit crashes when I use the for loop instead of the "non for loop expression". Do you have any idea where does the problem come from ?
code below :
model optim_debug2

Real totalCost  annotation(isMayer = true);

parameter Integer nb_variables=3; //number of optimization variables
input Real x[nb_variables](each min=0,each max=1); //array of optimization variables
Real power_input[nb_variables];
Real power_output;





/*for i in 1:nb_variables loop
end for;*/

//Problem : OMedit crashes when trying to replace line 18 (power_output:=x[1]...) by for loop (lines 21-23)

totalCost:=(power_output-22)^2; //the objective is to obtain power_output=22

annotation(experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-07, Interval = 1),
__OpenModelica_simulationFlags(s="optimization", optimizerNP="1"),

end optim_debug2;

There are 0 guests and 0 other users also viewing this topic
You are here: