Differential Inclusions

Main author: Damien Massé

The content of this page is limited to C++. Python bindings are missing for now.

Differential inclusions

Differential inclusions are equations of the form \(\dot{\mathbf{x}} \in \big\{ \mathbf{f}\big(t,\mathbf{x},\mathbf{u}\big) \big\}\) where \(\mathbf{u}\) are unknown (possibly non-continuous) functions varying on a domain \(U\).

Codac enables to define differential inclusions and to integrate differential inclusions. The variables for \(\mathbf{x}\) and \(\mathbf{u}\) can be indifferently ScalarVar, VectorVar or MatrixVar. The function \(\mathbf{f}\) can be any function (linear or not).

For now, two integration schemes are implemented:

  • RS_box: a 0-order scheme using boxes (IntervalVector), very imprecise

  • RS_zonotope: a 1-order scheme using zonotopes, more precise. This scheme requires \(\mathbf{f}\) to be differentiable (for all its variables).

Examples

Direct integration

We consider \(\mathbf{f}:\mathbb{R}^2 \times \mathbb{R} \to\mathbb{R}^2\):

\[\mathbf{f}((x_1,x_2),u)= (-x_2+u, x_1-0.1 x_2)\]

We consider \(\mathbf{u}\) varying in the interval \([-0.03,0.03]\). The following code performs a guaranteed integration (which constant time steps) from \(t=0\) to \(t=10\) using RS_box, starting from a small box \([1,1.01]\times[0,0.01]\) and draws the result.

VectorVar x(2);
ScalarVar u;
AnalyticFunction f({x,u}, {-x[1]+u, x[0]-0.1*x[1]});
DiffInclusion<VectorVar,ScalarVar> di(f);

int q=0;
DI_Integration<DiffInclusion<VectorVar,ScalarVar>,
    RS_box> integration0(di);
IntervalVector state {{1.0,1.01},{0.0,0.01}};
for (double t=0;t<2.0;t+=0.01) {
  IntervalVector s1 = IntervalVector::constant(2,Interval());
  IntervalVector s2 = IntervalVector::constant(2,Interval());
  integration0.contract_one_step(Interval(t,t+0.01),
            state,
            s1,s2, Interval(-0.03,0.03),true);
  state=s2;
  if ((++q)%10==0) 
    DefaultFigure::draw_box(state,Color::purple());
  else
    DefaultFigure::draw_box(state,Color::purple(0.1));
}

The next code performs the same integration using RS_zonotope:

state = {{1.0,1.01},{0.0,0.01}};
Zonotope zstate(state);
DI_Integration<DiffInclusion<VectorVar,ScalarVar>,
    RS_zonotope> integration1(di);
q=0;
  /* high limit the number of zonotope generators */
integration1.get_reachabilitystep()->set_max_zonotope_order(200.0);
for (double t=0;t<10.0;t+=0.02) {
  IntervalVector s1 = IntervalVector::constant(2,Interval());
  Zonotope z2;
  integration1.contract_one_step(Interval(t,t+0.02),
            zstate,
            s1,z2, Interval(-0.03,0.03),true);
  zstate=z2;
  if ((++q)%10==0) {
    DefaultFigure::draw_zonotope(zstate,Color::red());
  } else 
    DefaultFigure::draw_zonotope(zstate,Color::red(0.1));
}

And this code integrate starting from a large square (the maximum order of zonotopes is deliberately set to a low value, which means that the integration is done on parallelepipeds):

  /* low limit the number of zonotope generators */
integration1.get_reachabilitystep()->set_max_zonotope_order(2.0);
state = {{-2.0,2.0},{-2.0,2.0}};
zstate = Zonotope(state);
  DefaultFigure::draw_zonotope(zstate,Color::blue());
q=0;
for (double t=0;t<11.0;t+=0.01) {
  IntervalVector s1 = IntervalVector::constant(2,Interval());
  Zonotope z2;
  integration1.contract_one_step(Interval(t,t+0.01),
            zstate,
            s1,z2, Interval(-0.03,0.03),true);
  zstate=z2;
  if ((++q)%30==0) DefaultFigure::draw_zonotope(zstate,Color::red(0.2));
}
  DefaultFigure::draw_zonotope(zstate,Color::black());

The results are given below. A black line describes the computation result when \(\mathbf{u}\) is 0 (hence the equation is an ODE). The inclusion of the final set of reachables sets from the large square (in black) inside the initial set (in blue) proves the stability of the differential inclusion.

2D-differential inclusion integration

Tube integration

Codac enables to generate a tube :class:~codac.SlicedTube from a set of initial (or final) states, following a temporal domain TDomain. The contraction of an existing tube is also provided. However, since the domain of zonotopes does not admit useful intersection operators, the contraction is not very efficient for now. An example is given below:

VectorVar x(2);
ScalarVar u;
AnalyticFunction f({x,u}, {-x[1]+u, x[0]-0.1*x[1]});
DiffInclusion<VectorVar,ScalarVar> di(f);

IntervalVector init = {{-0.3,0.3},{0.8,1.0}};
DI_Integration<DiffInclusion<VectorVar,ScalarVar>,
    RS_zonotope> integration1(di);
auto tube = integration1.create_sliced_tube
          (create_tdomain(Interval(0,10),0.03),
                  init, IntervalVector({{-10,10},{-10,10}}),
                  Interval(-0.03,0.03),true);

DefaultFigure::plot_tube(tube[0],Color::red(0.1));
DefaultFigure::plot_tube(tube[1],Color::blue(0.1));

tube.set(IntervalVector({{0.85,0.9},{0.15,0.2}}),Interval(5.0));
integration1.contract_sliced_tube
          (tube,Interval(-0.03,0.03),TimePropag::FWD_BWD);

DefaultFigure::plot_tube(tube[0],Color::red(1.0));
DefaultFigure::plot_tube(tube[1],Color::blue(1.0));

The resulting plot is shown below.

tubes for differential inclusion