Optimisations using if statements

2 posts / 0 new
Last post
Joined: 2014-01-03
Optimisations using if statements

If statements are currently not supported in optimisation problems, even though casadi is able to handle them. I suspect that this is a design choice to avoid the optimisation problem to contain disconinuities. However, I am using if-expressions that are C2 continous across the transition point so I would like to use them anyway.

It seems sufficient to set 

    MXVector FStatement.updateExpressionsAccordingToStatement(MXVector expressions, MXVector allVars) {
        return expressions;

in FExpToCasADi.jrag but I'm not sure if this implementation is correct?

Is there an easy way to check if this expression is generated in the body of a function that contains the smoothOrder>=2 annotation to avoid mistakes?


Joined: 2011-08-26
I think supporting general if

I think supporting general if statements would be very difficult. If expressions are however supported, and map trivially to CasADi's if_else functionality, as you say.

I unfortunately can't comment on your suggested implementation.

Login or register to post comments