Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with defining variable parameters for terminal cost function #40

Open
aabsz opened this issue Oct 15, 2023 · 3 comments
Open

Problem with defining variable parameters for terminal cost function #40

aabsz opened this issue Oct 15, 2023 · 3 comments

Comments

@aabsz
Copy link

aabsz commented Oct 15, 2023

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
Copy link
Member

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
Copy link
Author

aabsz commented Oct 17, 2023

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants