codac 2.0.0
Loading...
Searching...
No Matches
Integration and primitive operations on sliced tubes

The following methods are valid for tubes defined for Interval or IntervalVector codomains. The returned values are integral enclosures of same type (respectively, Interval or IntervalVector). More...

Functions

SlicedTube< T > codac2::SlicedTube< T >::primitive () const
 Returns a primitive of this tube with zero initial condition.
SlicedTube< T > codac2::SlicedTube< T >::primitive (const T &x0) const
 Returns a primitive of this tube with prescribed initial condition.
T codac2::SlicedTube< T >::integral (const Interval &t) const
 Returns an enclosure of the integrals of this tube from \(t_0\) to \([t]\).
T codac2::SlicedTube< T >::integral (const Interval &t1, const Interval &t2) const
 Returns an enclosure of the integrals of this tube between the time intervals \([t_1]\) and \([t_2]\).
std::pair< T, T > codac2::SlicedTube< T >::partial_integral (const Interval &t) const
 Returns lower and upper enclosures of the integrals of this tube \([x](\cdot)=[x^-(\cdot),x^+(\cdot)]\) from \(t_0\) to \([t]\).
std::pair< T, T > codac2::SlicedTube< T >::partial_integral (const Interval &t1, const Interval &t2) const
 Returns lower and upper enclosures of the integrals of this tube \([x](\cdot)=[x^-(\cdot),x^+(\cdot)]\) between \([t_1]\) and \([t_2]\).

Detailed Description

The following methods are valid for tubes defined for Interval or IntervalVector codomains. The returned values are integral enclosures of same type (respectively, Interval or IntervalVector).

Function Documentation

◆ primitive() [1/2]

template<typename T>
SlicedTube< T > codac2::SlicedTube< T >::primitive ( ) const
inline

Returns a primitive of this tube with zero initial condition.

This is a shorthand for primitive(x0) with \(x_0 = 0\).

In other words, the returned tube encloses solutions of

\[ \dot{p}(\cdot) \in [x](\cdot), \qquad p(t_0)=0. \]

Returns
primitive tube with zero initial condition
936 {
937 auto x0 = all_reals_value();
938 x0.init(0.);
939 return primitive(x0);
940 }
Tube represented over a sliced temporal domain.
Definition codac2_SlicedTube.h:38
T all_reals_value() const
Returns the unbounded codomain value associated with T.
Definition codac2_SlicedTube.h:1213
SlicedTube< T > primitive() const
Returns a primitive of this tube with zero initial condition.
Definition codac2_SlicedTube.h:935

◆ primitive() [2/2]

template<typename T>
SlicedTube< T > codac2::SlicedTube< T >::primitive ( const T & x0) const
inline

Returns a primitive of this tube with prescribed initial condition.

This method constructs a tube p on the same temporal domain as this tube, imposes the initial condition \(p(t_0)=x_0\), and contracts p with this tube through the derivative relation using CtcDeriv.

In other words, the returned tube encloses solutions of

\[ \dot{p}(\cdot) \in [x](\cdot), \qquad p(t_0)=x_0. \]

Note
The current implementation may create an explicit gate at the initial time \(t_0\) if it is not already present in the temporal partition.
Parameters
x0initial condition at \(t_0\)
Returns
primitive tube satisfying the prescribed initial condition
964 {
965 auto x = all_reals_value();
966 auto p = SlicedTube<T>(this->tdomain(), x);
967 p.set(x0, this->tdomain()->t0_tf().lb()); // may create an unwanted gate
968 CtcDeriv c;
969 c.contract(p,*this);
970 return p;
971 }
SlicedTube(const std::shared_ptr< TDomain > &tdomain, const T &codomain)
Creates a sliced tube with constant codomain over all temporal slices.
Definition codac2_SlicedTube.h:47
void set(const T &codomain)
Sets all codomains of this tube to the same value.
Definition codac2_SlicedTube.h:443
Interval t0_tf() const
Returns the global temporal interval of this tube.
Definition codac2_TubeBase.h:61
const std::shared_ptr< TDomain > & tdomain() const
Returns the temporal domain of this tube.
Definition codac2_TubeBase.h:49
auto lb() const
Returns a matrix containing the lower bounds of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:91

◆ integral() [1/2]

template<typename T>
T codac2::SlicedTube< T >::integral ( const Interval & t) const

Returns an enclosure of the integrals of this tube from \(t_0\) to \([t]\).

This method computes an enclosure of

\[ \left\{ \int_{t_0}^{\tau} [x](s)\,ds \;\middle|\; \tau\in[t] \right\}. \]

It is obtained from partial_integral(t) by taking the hull between the lower bound of the lower enclosure and the upper bound of the upper enclosure.

Parameters
ttemporal interval \([t]\)
Returns
enclosure of the integrals of this tube over t
21 {
23
24 if(partial_integ.first.is_empty() || partial_integ.second.is_empty())
25 return this->empty_value();
26
27 else if(partial_integ.first.is_unbounded() || partial_integ.second.is_unbounded())
28 return this->all_reals_value();
29
30 else
31 return T(partial_integ.first.lb()) | partial_integ.second.ub();
32 }
T empty_value() const
Returns the empty codomain value associated with T.
Definition codac2_SlicedTube.h:1225
bool is_unbounded() const
Tests whether this tube is unbounded.
Definition codac2_SlicedTube.h:331
bool is_empty() const
Tests whether this tube is empty.
Definition codac2_SlicedTube.h:315
std::pair< T, T > partial_integral(const Interval &t) const
Returns lower and upper enclosures of the integrals of this tube from to .
Definition codac2_SlicedTube_integral_impl.h:83

◆ integral() [2/2]

template<typename T>
T codac2::SlicedTube< T >::integral ( const Interval & t1,
const Interval & t2 ) const

Returns an enclosure of the integrals of this tube between the time intervals \([t_1]\) and \([t_2]\).

This method computes an enclosure of

\[ \left\{ \int_{\tau_1}^{\tau_2} [x](s)\,ds \;\middle|\; \tau_1\in[t_1],\ \tau_2\in[t_2] \right\}. \]

For degenerate time intervals, the integral is evaluated directly on the non-gate slices between the two dates, with the appropriate sign for backward integration. Otherwise, partial integral enclosures are subtracted and combined according to the possible integration directions.

Parameters
t1first temporal interval \([t_1]\)
t2second temporal interval \([t_2]\)
Returns
enclosure of the integrals of this tube between t1 and t2
36 {
37 if(t1.is_empty() || t2.is_empty())
38 return this->empty_value();
39 if(!t1.is_subset(this->t0_tf()) || !t2.is_subset(this->t0_tf()))
40 return this->all_reals_value();
41
42 if(t1.is_degenerated() && t2.is_degenerated())
43 {
44 auto p = this->all_reals_value();
45 p.init(Interval(0.));
46 if(t1 == t2)
47 return p;
48
49 // Integrate only the slices between the two dates
50 Interval t = t1 | t2;
51 for(auto it = _tdomain->tslice(t.lb()) ; it != _tdomain->end() && it->lb() < t.ub() ; ++it)
52 {
53 if(it->is_gate())
54 continue;
55 Interval ti = t & it->t0_tf();
56 if(ti.is_empty() || ti.is_degenerated())
57 continue;
58 const auto& x = this->slice(it)->codomain();
59 if(x.is_empty())
60 return this->empty_value();
61 Interval dt = Interval(ti.ub()) - Interval(ti.lb());
62 p += dt * x;
63 }
64
65 return t1.lb() < t2.lb() ? p : T(-p);
66 }
67
68 auto p = partial_integral(t1,t2);
69 if(p.first.is_empty() || p.second.is_empty())
70 return this->empty_value();
71 if(p.first.is_unbounded() || p.second.is_unbounded())
72 return this->all_reals_value();
73
74 if(t1.ub() <= t2.lb())
75 return T(p.first.lb()) | p.second.ub();
76 if(t2.ub() <= t1.lb())
77 return T(p.second.lb()) | p.first.ub();
78
79 return p.first | p.second;
80 }
T codomain() const
Returns the global codomain of this tube.
Definition codac2_SlicedTube.h:346
std::shared_ptr< Slice< T > > slice(const std::list< TSlice >::iterator &it)
Returns the slice attached to a temporal iterator.
Definition codac2_SlicedTube.h:249
const std::shared_ptr< TDomain > _tdomain
Shared temporal domain of this tube.
Definition codac2_TubeBase.h:71

◆ partial_integral() [1/2]

template<typename T>
std::pair< T, T > codac2::SlicedTube< T >::partial_integral ( const Interval & t) const

Returns lower and upper enclosures of the integrals of this tube \([x](\cdot)=[x^-(\cdot),x^+(\cdot)]\) from \(t_0\) to \([t]\).

This method returns a pair \(([p^-],[p^+])\) such that:

\[ [p^-]\supset \left\{ \int_{t_0}^{\tau} x^-(s)\,ds \;\middle|\; \tau\in[t] \right\} \mathrm{~~and~~} [p^+]\supset \left\{\int_{t_0}^{\tau} x^+(s)\,ds \;\middle|\; \tau\in[t] \right\}. \]

This representation preserves more information than integral(t), which only returns the hull of these partial integral bounds.

Parameters
ttemporal interval \([t]\)
Returns
pair of lower and upper partial integral enclosures over t
84 {
85 if(t.is_empty())
86 return { this->empty_value(), this->empty_value() };
87 if(!t.is_subset(this->t0_tf()) || t.is_unbounded() || !std::isfinite(this->t0_tf().lb()))
88 return { this->all_reals_value(), this->all_reals_value() };
89
90 auto zero = this->all_reals_value();
91 zero.init(Interval(0.));
92 if(t == Interval(this->t0_tf().lb()))
93 return { zero, zero };
94
96 std::pair<T,T> result { this->empty_value(), this->empty_value() };
97
98 for(const auto& s : *this)
99 {
100 if(s.t0_tf().lb() >= t.ub())
101 break;
102 if(s.is_gate())
103 continue;
104
105 const auto& x = s.codomain();
106 if(x.is_empty())
107 return { this->empty_value(), this->empty_value() };
108 if(x.is_unbounded())
109 return { this->all_reals_value(), this->all_reals_value() };
110
111 // Evaluate the affine partial primitives on the queried part of the slice
112 Interval ti = s.t0_tf() & t;
113 if(!ti.is_empty())
114 {
115 Interval dt = ti - Interval(s.t0_tf().lb());
116 result.first |= p.first + dt * T(x.lb());
117 result.second |= p.second + dt * T(x.ub());
118 }
119
120 if(s.t0_tf().ub() >= t.ub())
121 break;
122
123 Interval dt = Interval(s.t0_tf().ub()) - Interval(s.t0_tf().lb());
124 p.first += dt * T(x.lb());
125 p.second += dt * T(x.ub());
126 }
127
128 return result;
129 }
double ub() const
Returns the upper bound of this.
Definition codac2_Interval_impl.h:131
double lb() const
Returns the lower bound of this.
Definition codac2_Interval_impl.h:126

◆ partial_integral() [2/2]

template<typename T>
std::pair< T, T > codac2::SlicedTube< T >::partial_integral ( const Interval & t1,
const Interval & t2 ) const

Returns lower and upper enclosures of the integrals of this tube \([x](\cdot)=[x^-(\cdot),x^+(\cdot)]\) between \([t_1]\) and \([t_2]\).

This method returns a pair obtained by subtracting the partial integral enclosures at t1 from those at t2. The returned pair \(([p^-],[p^+])\) is such that:

\[ [p^-]\supset \left\{ \int_{\tau_1}^{\tau_2} x^-(s)\,ds \;\middle|\; \tau_1\in[t_1],\ \tau_2\in[t_2] \right\}, \]

and

\[ [p^+]\supset \left\{\int_{\tau_1}^{\tau_2} x^+(s)\,ds \;\middle|\; \tau_1\in[t_1],\ \tau_2\in[t_2] \right\}. \]

Parameters
t1first temporal interval \([t_1]\)
t2second temporal interval \([t_2]\)
Returns
pair of lower and upper enclosures of the integrals
133 {
136 return {
137 integ_t2.first - integ_t1.first,
138 integ_t2.second - integ_t1.second
139 };
140 }