|
| 1 | +.. _sec-ctc-dynamic-ctclohner: |
| 2 | + |
| 3 | +The CtcLohner contractor |
| 4 | +========================= |
| 5 | + |
| 6 | + Main authors: Auguste Bourgois, `Maël Godard <https://godardma.github.io>`_ (porting to Codac2) |
| 7 | + |
| 8 | +Definition |
| 9 | +---------- |
| 10 | + |
| 11 | +The Lohner contractor uses Lohner's guaranteed integration algorithm to contract a tube according to a differential |
| 12 | +equation. This algorithm performs two main steps: |
| 13 | + |
| 14 | +- an estimation of a global enclosure of the system's trajectories over an integration step (*i.e.* the domain of a slice), |
| 15 | + which corresponds to the codomain of that slice; |
| 16 | +- using this estimation and the input gate (or output gate in the backward mode), the corresponding output gate (or input gate |
| 17 | + in the backward mode) is then estimated; |
| 18 | +- over a single slice, these steps can be iterated a few times to obtain tighter enclosures for both the gate and the codomain of the slice. |
| 19 | + |
| 20 | +This contractor is supposed to yield better results than the Picard contractor, as long as the tubes are "thin enough". |
| 21 | + |
| 22 | +.. important:: |
| 23 | + |
| 24 | + .. math:: |
| 25 | +
|
| 26 | + \left.\begin{array}{r}\dot{\mathbf{x}}(t)=\mathbf{f}\big(\mathbf{x}(t)\big)\end{array}\right. \longrightarrow \mathcal{C}_{\textrm{Lohner}}\big([\mathbf{x}](\cdot)\big) |
| 27 | +
|
| 28 | + .. tabs:: |
| 29 | + |
| 30 | + .. code-tab:: py |
| 31 | + |
| 32 | + var = VectorVar(n) # n is the dimension of the system |
| 33 | + ctc_lohner = CtcLohner(AnalyticFunction([var], [expr1, expr2, ..., exprn])) |
| 34 | + ctc_lohner.contract(x) |
| 35 | + |
| 36 | + .. code-tab:: c++ |
| 37 | + |
| 38 | + VectorVar var(n); // n is the dimension of the system |
| 39 | + CtcLohner ctc_lohner(AnalyticFunction({x}, {expr1, expr2, ..., exprn});); |
| 40 | + ctc_lohner.contract(x); |
| 41 | + |
| 42 | +.. important:: |
| 43 | + |
| 44 | + The contractor might throw a runtime error when it cannot find a global enclosure over a specific time step. This usually |
| 45 | + happens when the time step is too large, and may therefore be avoided by reducing the discretisation frequency of the tube. |
| 46 | + |
| 47 | + Note that this behaviour may be tackled using automatic step adjustment. However, such a feature is not yet implemented. |
| 48 | + |
| 49 | + |
| 50 | +Simple example of use |
| 51 | +--------------------- |
| 52 | + |
| 53 | +In the following example, we consider the two-dimensional system described by: |
| 54 | + |
| 55 | +.. math:: |
| 56 | +
|
| 57 | + \left(\begin{array}{c}\dot{x}_1\\\dot{x}_2\end{array}\right) = \left(\begin{array}{c}-x_1\\-\sin({x}_2)\end{array}\right). |
| 58 | +
|
| 59 | +The Lohner contractor is used for obtaining a two-dimensional tube, considering an initial condition :math:`\mathbf{x}_0\in[0.9,1.1]\times[0.9,1.1]`. The contraction is tested on two tubes :math:`[\mathbf{a}](\cdot)` and :math:`[\mathbf{b}](\cdot)` of different resolutions (width of slices). |
| 60 | + |
| 61 | +.. tabs:: |
| 62 | + |
| 63 | + .. code-tab:: py |
| 64 | + |
| 65 | + x0 = IntervalVector([Interval(1,1),Interval(1,1)]) # the box [1,1]×[1,1].. |
| 66 | + x0.inflate(0.1) # ..becomes [0.9,1.1]×[0.9,1.1] |
| 67 | + |
| 68 | + # 2d tubes: |
| 69 | + ta = create_tdomain([0.,10.0],0.2) # low resolution |
| 70 | + a = SlicedTube_IntervalVector(ta, IntervalVector(2)) |
| 71 | + a.set(x0,0.0) # setting initial value |
| 72 | + |
| 73 | + tb =create_tdomain([0.,10.0],0.01) # high resolution |
| 74 | + b = SlicedTube_IntervalVector(tb, IntervalVector(2)) |
| 75 | + b.set(x0,0.0) # setting initial value |
| 76 | + |
| 77 | + # Defining Lohner contractor from f |
| 78 | + x = VectorVar(2) |
| 79 | + f = AnalyticFunction([x], [-x[0],-sin(x[1])]) |
| 80 | + ctc_lohner = CtcLohner(f) |
| 81 | + |
| 82 | + # Contracting the tubes |
| 83 | + ctc_lohner.contract(a) |
| 84 | + ctc_lohner.contract(b) |
| 85 | + |
| 86 | + # Graphics |
| 87 | + fig1 = Figure2D("Lohner_1",GraphicOutput.VIBES|GraphicOutput.IPE) |
| 88 | + fig2 = Figure2D("Lohner_2",GraphicOutput.VIBES|GraphicOutput.IPE) |
| 89 | + |
| 90 | + fig1.plot_tube(a[0]) |
| 91 | + fig1.plot_tube(b[0],StyleProperties([Color.blue(),Color.blue()])) |
| 92 | + |
| 93 | + fig2.plot_tube(a[1]) |
| 94 | + fig2.plot_tube(b[1],StyleProperties([Color.blue(),Color.blue()])) |
| 95 | + |
| 96 | + .. code-tab:: c++ |
| 97 | + |
| 98 | + IntervalVector x0({Interval(1,1),Interval(1,1)}); // the box [1,1]×[1,1].. |
| 99 | + x0.inflate(0.1); // ..becomes [0.9,1.1]×[0.9,1.1] |
| 100 | + |
| 101 | + // 2d tubes: |
| 102 | + auto ta =create_tdomain({0.,10.0},0.2); // low resolution |
| 103 | + SlicedTube a(ta, IntervalVector(2)); |
| 104 | + a.set(x0,0.0); // setting initial value |
| 105 | + |
| 106 | + auto tb =create_tdomain({0.,10.0},0.01); // high resolution |
| 107 | + SlicedTube b(tb, IntervalVector(2)); |
| 108 | + b.set(x0,0.0); // setting initial value |
| 109 | + |
| 110 | + // Defining Lohner contractor from f |
| 111 | + VectorVar x(2); |
| 112 | + AnalyticFunction f({x}, {-x[0],-sin(x[1])}); |
| 113 | + CtcLohner ctc_lohner(f); |
| 114 | + |
| 115 | + // Contracting the tubes |
| 116 | + ctc_lohner.contract(a); |
| 117 | + ctc_lohner.contract(b); |
| 118 | + |
| 119 | + // Graphics |
| 120 | + Figure2D fig1 ("Lohner_1",GraphicOutput::VIBES|GraphicOutput::IPE); |
| 121 | + Figure2D fig2 ("Lohner_2",GraphicOutput::VIBES|GraphicOutput::IPE); |
| 122 | + |
| 123 | + fig1.plot_tube(a[0]); |
| 124 | + fig1.plot_tube(b[0],{Color::blue(),Color::blue()}); |
| 125 | + |
| 126 | + fig2.plot_tube(a[1]); |
| 127 | + fig2.plot_tube(b[1],{Color::blue(),Color::blue()}); |
| 128 | + |
| 129 | + fig1.set_window_properties({100,50},{1000,400}); |
| 130 | + fig2.set_window_properties({100,500},{1000,400}); |
| 131 | + |
| 132 | + |
| 133 | +The above code yields the following result for :math:`[a_1](\cdot)` (in gray, large slices) and :math:`[b_1](\cdot)` (in blue, thin slices): |
| 134 | + |
| 135 | +.. figure:: clohner.png |
| 136 | + |
| 137 | + |
| 138 | +Related content |
| 139 | +--------------- |
| 140 | + |
| 141 | +.. admonition:: Mathematical documentation |
| 142 | + |
| 143 | + See `Auguste Bourgois' thesis <https://www.ensta-bretagne.fr/jaulin/thesis_auguste.pdf>`_. In particular, check Chapter 4. |
| 144 | + |
| 145 | +.. admonition:: Technical documentation |
| 146 | + |
| 147 | + See the `C++ API documentation of this class <../../../extra_html/api/classcodac2_1_1_ctc_lohner.html>`_. |
| 148 | + |
0 commit comments