20 template <
typename DomA,
typename DomB>
21 class ReachabilityStep;
27 class DiffInclusionBase
30 virtual IntervalVector f_eval(
const EvalMode& m,
const Interval &t,
34 virtual VectorType f_eval_diff(
const Interval &t,
38 inline std::tuple<IntervalVector,IntervalMatrix,IntervalMatrix>
40 if (_time_dependant) {
43 da.middleCols(1,_x_shape.first*_x_shape.second),
44 da.rightCols(_u_shape.first*_u_shape.second)
48 IntervalVector::Zero(_x_shape.first*_x_shape.second),
49 da.leftCols(_x_shape.first*_x_shape.second),
50 da.rightCols(_u_shape.first*_u_shape.second)
56 DiffInclusionBase(
bool td) : _time_dependant(td) { }
60 bool forward,
bool end_gate)
const;
62 const bool _time_dependant =
false;
63 std::pair<Index,Index> _x_shape;
64 std::pair<Index,Index> _u_shape;
96 template<
typename XVar=VectorVar,
typename UVar=VectorVar>
97 class DiffInclusion :
public DiffInclusionBase
102 using XType =
typename ExprType<XVar>::Type;
104 using X = XType::Domain;
105 using U =
typename ExprType<UVar>::Type::Domain;
108 inline DiffInclusion(
const AnalyticFunction<XType>& f,
109 bool time_dependant=
false) :
110 DiffInclusionBase(time_dependant), _f(f)
112 size_t x_arg=(time_dependant ? 1 : 0);
113 assert_release(f.
args().size() == x_arg+2 &&
114 "DiffInclusion: wrong args size");
118 _u_shape =
dynamic_cast<const UVar&
>(*(f.
args()[x_arg+1])).
120 if (time_dependant) {
121 assert_release((f.
args()[0]->size() == 1)
122 &&
"DiffInclusion: wrong time size");
124 _x_shape =
dynamic_cast<const XVar&
>(*(f.
args()[x_arg])).
126 assert_release(_x_shape == f.output_shape()
127 &&
"DiffInclusion: wrong output size");
137 template<
bool forward=true,
bool end_gate=false>
140 to_X(approx_RK4_base(time_step,
141 from_X(
init),from_U(u),forward,end_gate));
160 if constexpr(std::is_same_v<X,IntervalVector>
161 && std::is_same_v<U,IntervalVector>) {
163 return _f.eval(m,t,x,u);
165 return _f.eval(m,x,u);
168 return from_X(_f.eval(m,t,to_X(x),to_U(u)));
170 return from_X(_f.eval(m,to_X(x),to_U(u)));
174 inline VectorType f_eval_diff(
const Interval &t,
177 if constexpr(std::is_same_v<X,IntervalVector>
178 && std::is_same_v<U,IntervalVector>) {
180 return _f.eval_analytic(t,x,u);
182 return _f.eval_analytic(x,u);
184 if (_time_dependant) {
185 XType ret = _f.eval_analytic(t,to_X(x),to_U(u));
186 return { from_X(ret.m),
192 XType ret = _f.eval_analytic(to_X(x),to_U(u));
193 return { from_X(ret.m),
202 if constexpr(std::is_same_v<X,Interval>) {
205 return x.template reshaped<Eigen::ColMajor>();
208 inline Vector from_X(
const XType::Scalar& x)
const {
209 if constexpr(std::is_same_v<X,Interval>) {
212 return x.template reshaped<Eigen::ColMajor>();
216 if constexpr(std::is_same_v<X,Interval>) {
219 return x.template reshaped<Eigen::ColMajor>
220 (_x_shape.first,_x_shape.second);
225 if constexpr(std::is_same_v<U,Interval>) {
228 return u.template reshaped<Eigen::ColMajor>();
232 if constexpr(std::is_same_v<U,Interval>) {
235 return u.template reshaped<Eigen::ColMajor>
236 (_u_shape.first,_u_shape.second);
241 const AnalyticFunction<XType> _f;
IntervalVector f_eval(const EvalMode &m, const Interval &t, const IntervalVector &x, const IntervalVector &u) const override
basic enclosing step
Definition codac2_DiffInclusion.h:157
X approx_RK4(const Interval &time_step, const X &init, const U &u)
approximation of IVP on a step using RK4. Does not return a guaranteed result, used for approximate e...
Definition codac2_DiffInclusion.h:138
const FunctionArgsList & args() const
Returns the arguments of the function.
Definition codac2_FunctionBase.h:93
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:50
auto & init(const Scalar &x)
Initializes all elements of the matrix with the scalar value x.
Definition codac2_Matrix_addons_Base.h:64
auto & init()
Initializes all elements of the matrix with default intervals.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:113
Definition codac2_OctaSym.h:21
Eigen::Matrix< double,-1, 1 > Vector
Alias for a dynamically-sized column vector of doubles.
Definition codac2_Vector.h:24
Eigen::Matrix< Interval,-1, 1 > IntervalVector
Alias for a dynamic-size column vector of intervals.
Definition codac2_IntervalVector.h:25
Eigen::Matrix< Interval,-1,-1 > IntervalMatrix
Alias for a dynamic-size matrix of intervals.
Definition codac2_IntervalMatrix.h:25