Hello,
I am researching in nlp applied to optimal control, specifically in an very simple electric point mass vehicle model, defined by the next dae:
# min tf
# dx/dt = v
# dv/dt = u - R*v^2
# x(0)=0; x(tf)=L
# v(0)=0; v(tf)=0
# -3 <= u <= 1 (engine constraint)
#
# {v <= 7m/s ===> u < 1
# u <= { (electric car constraint)
# {v > 7m/s ===> u < 1*7/v
#
# -1.5 <= dv/dt <= 0.8 (comfort constraint -> smooth driving)
# -0.5 <= d2v/dt2 <= 0.5 (comfort constraint -> jerk)
# v <= Vmax (40 kmh[0-500m] + 25 kmh(500-1000m])
As you can see, the acceleration provided by the electric engine (the only control variable, by the way) must be modelled as a piecewise equation, because it is define by constant acceleration until reaching a specific speed, and then by a constant power hyperbola depending of the vehicle speed (a state variable). Something close happens with the Max allowed speed constraint.
I could model that easily in AMPL, but I would like to migrate to an open source library, so I first tried Pyomo, but it does not work due that this kind of constraints are not allowed by it, due that constrain are not defined as callbacks that are called by the solver in every iteration, but as a container filler called once at model creation, so I wonder if Casadi would allow this feature?
1) If so, I have not found anything even close to this in the examples repository, could someone show me how to do it using some code example?
2) Also, if Casadi does not allow this or implementation becomes hard and/or clumpsy, what about the combination of JModelica + Casadi? Should I install JModelica executable or is Casadi able of opening, parsing and using Modelica source code directly?
Thanks in advance,
Pablo