I am currently employing the MPC-class by Axelsson in a project revolving optimal control of both district heating and power production. Generally, it works great with very nice solution times. However, I am banging my head against a problem -- and have been for quite some time now...
I would like to investigate scenarios with changes to power prices, which alters my general cost function of maximizing profit while maintaining a certain QoS of for the consumers.
In a very crude example, I would simply like to change the price at a certain time, t. This should have the effect, that e.g. load is switched from one production unit to another. The price change is simply modeled by a Step (Modelica.Blocks.Sources), and the output of the step is then simply a factor in my cost function.
This works just fine for 'open loop' optimal control; solving the problem once and just obtaining the control input trajectories.
But when I use the MPC-class and the same optimization problem, it is as if the price change never happens... No response/reaction at all.
I stumbled upon a paragraph in Axelssons thesis about the MPC-class, which states that it can't handle time-dependent models (e.g. equations including 'time' explicitly).
Perhaps this is this case?
If this is simply not possible using the MPC-class; are there other options? Should it be possible if one instead uses the cstr_mpc.py example as reference?
So, I fooled around with the external_data after reading http://www.jmodelica.org/4436 -- which is basically what I want. Now, I understand from Axelssons thesis, that external_data is not supported. But after the implementation of https://trac.jmodelica.org/ticket/4258 (mutable_external_data), it theoretically should be, right?
But, with a naive attempt, I run into the following problems:
Traceback (most recent call last):
File "MPC.py", line 131, in
MPC_object = MPC(op['model'], opts, sample_period, horizon, initial_guess='prev')
File "/opt/jmodelica/Python/pyjmi/optimization/mpc.py", line 180, in __init__
File "/opt/jmodelica/Python/pyjmi/optimization/mpc.py", line 384, in _create_nlp_object
self.alg = LocalDAECollocationAlg(self.op, self.options)
File "/opt/jmodelica/Python/pyjmi/jmi_algorithm_drivers.py", line 1300, in __init__
self.nlp = LocalDAECollocator(self.op, self.options)
File "/opt/jmodelica/Python/pyjmi/optimization/casadi_collocation.py", line 981, in __init__
File "/opt/jmodelica/Python/pyjmi/optimization/casadi_collocation.py", line 1034, in _create_nlp
File "/opt/jmodelica/Python/pyjmi/optimization/casadi_collocation.py", line 1542, in _create_nlp_variables
File "/opt/jmodelica/Python/casadi/casadi_core.py", line 18979, in vertsplit
RuntimeError: The assertion "isMonotone(offset)" on line 198 of file "/home/borlum/JModelica.org/ThirdParty/CasADi/CasADi/casadi/core/mx/mx_tools.cpp" failed.
Please notify the CasADi developers.
I would be happy to help in getting it to work, but my understanding of the underlying functionality is very limited. It would however be a great feature(!).