Menu

Time dependent constraints with OCP

Sim
2015-04-13
2015-04-16
  • Sim

    Sim - 2015-04-13

    I'm trying to solve an optimal control problem using OCP. I have seen in many posts that to be able to use constraints that depend on the states we should set CG_HARDCODE_CONSTRAINTS to NO.
    algo = acado.OptimizationAlgorithm(ocp);
    algo.set('CG_HARDCODE_CONSTRAINTS ','NO');
    I believe if I use the above setup , I would be able to use state dependent constraints
    ocp.subjectTo(0<= u <= .5- x2); such that x2 is the real time state. However this actually didn't work for me.
    I would appreciate any help on this issue.
    Thanks.

     
  • Rien Quirynen

    Rien Quirynen - 2015-04-14

    Hi there,

    You are using an option for the code generation tool ("CG_") outside of this tool, so that will indeed not work.
    But why don't you specify your constraints directly as:
    ocp.subjectTo( 0 <= u );
    ocp.subjectTo( u+x2 <= .5 );

     
  • Sim

    Sim - 2015-04-14

    That's a smarter way to define the constraint and it answers my question. Thank you Rien.

     
  • Sim

    Sim - 2015-04-16

    I have another question, putting constraints on the states the way you mentioned make the solver to fail compared to using only fixed constraints (0<=u<=.5). Even with fixed constraints, when increasing the window of optimization from ocp = acado.OCP(0.0, 40, 40) to ocp = acado.OCP(0.0, 168, 100); the solver also fails. I understand increasing the time, increases the number of decision variables and makes the optimization more difficult but is there any other explanation to that. Thank you.

     

Log in to post a comment.