hilo-mpc / hilo-mpc

HILO-MPC is a Python toolbox for easy, flexible and fast development of machine-learning-supported optimal control and estimation problems
https://www.ccps.tu-darmstadt.de/research_ccps/hilo_mpc/
GNU Lesser General Public License v3.0
158 stars 32 forks source link

Problem with defining variable parameters for terminal cost function #40

Open aabsz opened 10 months ago

aabsz commented 10 months ago

Hi,

I am trying to define a terminal cost function with variable parameters. I know how to define variable parameters and I have already done it when defining a stage cost function with variable parameters and it is working well (using stage_cost.cost).

However, when defining the terminal cost using the following command, I get the error that the parameters have not been declared:

self.nmpc.quad_terminal_cost.add_states(names=['x', 'y', 'z'], weights=[self.model.p[1] , self.model.p[2], self.model.p[3]],ref=[self.x_dess,self.y_dess, self.z_dess])

This is the error that I get:

Initialization failed since variables [stage_cost_weight_xstage_cost_weight_ystage_cost_weight_z] are free. These symbols occur in the output expressions but you forgot to declare these as inputs. Set option 'allow_free' to allow free variables.

Is there any option that I can define the parameter varying terminal cost function?

brunomorampc commented 10 months ago

Hi @aabsz,

This could be a problem with the CasADi version, which one do you have? and which hilo-mpc version do you have?

if you have hilo <= 1.0.3 and you have Casadi >3.5 then that could be the problem. You need to either upgrade hilo-mpc to 1.1.0 or downgrade casadi to 3.5.

if that's not the case, please send me an example code and I'll have a look at it.

Cheers

aabsz commented 10 months ago

Hi Bruno,

Thanks for the reply.

You are right. My CasADi version is 3.6 and hilo-mpc is 1.0.3. I couldn't find the 1.1.0 version to replace it with the current version.

brunomorampc commented 10 months ago

Hi @aabsz,

You're right. I just noticed that the last version (the 1.1.0) was not published in pypi. I'll try to fix the problem