I am using GEKKO in MPC mode (Solver APOPT). I am defining my manipulated variable as follows:
u = m.MV(lb=0, ub=1, integer=True)
u.STATUS = 1
I am intentionally not using:
u = m.MV(value=1 ,lb=0, ub=1, integer=True)
u.STATUS = 1
Or:
u = m.MV(value=0 ,lb=0, ub=1, integer=True)
u.STATUS = 1
because I don't know what the next decision is and I want my optimizer to define it. Apparently when you don't define the value of u
, GEKKO gives it a default value of 0.
The problem is that this value of u
is used in my model predictions and also in other calculations which is not desirable (see figure). As you can see, the new value of u
is one meaning the fridge in on in my case. But, the temperature prediction starts with a default value of u
which is 0. Therefore, the temperature in the fridge rises for the next time step and only starts to fall in the next time step. I have the possibility to define value as the previous result of u
but also this would not be 100% right.
How can I avoid this? Are there any other options so that my prediction starts right?
I appreciate the help :)
There is an option to calculate the initial condition for any parameter or variable including an MV:
Here is a simple application that shows the difference that this function makes on the solution.
With
free_initial(mv)
Without
free_initial(mv)