Can generate once in python and change in c++?


I’m using the python interface and linking some c_generated_code to my C++ program.
In the problem I constructed, the kinematic model is invariant, so I only need to generate the file once under the python interface. However, the dimension of the problem will change, for example, sometimes optimizing 100 shooting points, sometimes optimizing 80 shooting points. I would like to ask if there is a way to modify the relevant code of c_generated_code to meet this requirement?


Hi Blood,

Not sure if set_new_time_steps() would be the right answer to your question: Python Interface — acados documentation. I do not have experience with that.

Otherwise, the very naive way would be to generate C code for 2 OCP solvers (their only difference is the number of shooting nodes) and call them in C++ separately.

Hi Fenglong,

Thank you for your reply! It is indeed reasonable to construct multiple problems with the same model but different numbers of steps. However, the possible values of the number of steps in my problem are too many (100 and 80 are examples). The description of set_new_time_steps() seems to be able to deal with my problem, but I am not sure about the specific details and C++ interface.