Question

I'm working on infinite-dimensional optimization algorithms using optimal control methods (trajectory generation and optimization). The systems that I'd like to do this trajectory optimization on are nonlinear of the form $\dot{x}(t) = f(x(t), u(t), t)$. In other words, I've got time-varying nonlinear inputs.

Is it possible to solve such an ODE using boost::odeint? I didn't find any hint in the documentation, but I might just not have seen it.

Était-ce utile?

La solution

Yes, you can use odeint for this kind of problems. The explicit steppers expect that the system function (the ODE) you pass to odeint has the signature

ode( x , dxdt , t );

where x is the input parameter for the current state, dxdt is the output parameter for the r.h.s. of the ODE an t is the time. For example a driven oscillator might be implemented like

typedef std::array< double , 2 > state_type;

struct oscillator
{
    double driving_strength;
    double dribving_frequency;

    void operator()( state_type const &x , state_type &dxdt , double t ) const
    {
        dxdt[0] = x[1];
        dxdt[1] = -x[0] + driving_strength * sin( driving_frequency * t );
    }
};

state_type x;
oscillator osc;
// initialize x and osc 
runge_kutta4< state_type > stepper;
integrate_const( stepper , osc , x , t_start , t_end , dt );
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top