Model Predictive Controller only works for certain values

I can’t reproduce your issues, because I don’t know the arguments to your function. Take a read of: Please read: make it easier to help you

Some things that might help:

  • use fix(phi[1] init_phi) instead of adding the initial value constraints.
  • Add sensible bounds on phi, theta, and u
  • Consider rewriting phi and theta as a @NLexpression instead of a variable. (It seems your only real decision variable is u.) For example, something like:
    phi = [@NLexpression(model, init_phi)]
    for i in 2:num_time_steps
        push!(phi, @NLexpression(model, phidot[i - 1] * h + phi[i - 1]))
    end
    
2 Likes