54 std::make_shared<Slice<T>>(*this, it, codomain)
68 const AnalyticFunction<
typename ExprType<T>::Type>& f)
71 assert_release(f.args().size() == 1
72 &&
"function's inputs must be limited to one system variable");
77 std::make_shared<Slice<T>>(*
this, it, f.eval((
Interval)*it))
91 requires std::is_same_v<typename ExprType<T>::Type,V>
93 const AnalyticTraj<V>& x)
99 std::make_shared<Slice<T>>(*this, it, x.eval((Interval)*it))
111 requires std::is_same_v<typename Wrapper<V>::Domain,T>
113 const SampledTraj<V>& x)
119 std::make_shared<Slice<T>>(*this, it, x((Interval)*it))
136 std::make_shared<Slice<T>>(*x.slice(it), *this)
153 slice(it)->set(x.
slice(it)->codomain(),
false);
175 virtual std::pair<Index,Index>
shape()
const
177 if constexpr(std::is_same_v<typename ExprType<T>::Type,ScalarType>)
193 for(
const auto& s : *
this)
206 return std::const_pointer_cast<Slice<T>>(
207 static_cast<const SlicedTube&
>(*this).first_slice());
217 return std::static_pointer_cast<const Slice<T>>(
228 return std::const_pointer_cast<Slice<T>>(
229 static_cast<const SlicedTube&
>(*this).last_slice());
239 return std::static_pointer_cast<const Slice<T>>(
249 inline std::shared_ptr<Slice<T>>
slice(
const std::list<TSlice>::iterator& it)
251 return std::const_pointer_cast<Slice<T>>(
252 static_cast<const SlicedTube&
>(*this).slice(it));
261 inline std::shared_ptr<const Slice<T>>
slice(
const std::list<TSlice>::const_iterator& it)
const
263 return std::static_pointer_cast<const Slice<T>>(
264 it->slices().at(
this));
273 inline std::shared_ptr<Slice<T>>
slice(
const std::list<TSlice>::reverse_iterator& it)
275 return std::const_pointer_cast<Slice<T>>(
276 static_cast<const SlicedTube&
>(*this).slice(it));
285 inline std::shared_ptr<const Slice<T>>
slice(
const std::list<TSlice>::const_reverse_iterator& it)
const
287 return std::static_pointer_cast<const Slice<T>>(
288 it->slices().at(
this));
299 inline std::shared_ptr<Slice<T>>
slice(std::shared_ptr<TSlice> ptr)
303 [&](
TSlice& t){ return &t == ptr.get(); });
318 for(
const auto& s : *
this)
319 if(s.is_gate() && s.is_empty())
321 for(
const auto& s : *
this)
322 if(!s.is_gate() && s.is_empty())
334 for(
const auto& s : *
this)
350 for(
const auto& s : *
this)
355 template<
typename Func>
356 inline T eval_common(
const Interval& t,
const Func& apply_eval)
const
363 T
codomain = apply_eval(it, t & *it);
365 while(it != std::next(
_tdomain->tslice(t.
ub())))
367 if(it->lb() == t.
ub())
break;
368 codomain |= apply_eval(it, t & *it);
383 return eval_common(t,
384 [
this](
auto it,
const Interval& t_) {
385 return this->
slice(it)->operator()(t_);
397 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
399 return eval_common(t,
400 [
this,&v](
auto it,
const Interval& t_) {
401 return this->
slice(it)->operator()(t_, *v.slice(it));
415 auto bounds = std::make_pair(x,x);
428 while(si && si->t0_tf().lb() <= t_inter.
ub())
430 auto slice_bounds = si->enclosed_bounds(t_inter & si->t0_tf());
431 bounds.first |= slice_bounds.first;
432 bounds.second |= slice_bounds.second;
433 si = si->next_slice();
446 assert_release(
codomain.size() == this->size());
467 assert_release(
codomain.size() == this->size());
483 std::list<TSlice>::iterator it_ub;
489 if(it_ub->lb() == t.
ub())
492 if(it_lb->ub() == t.
lb())
502 }
while(it_lb != it_ub && (++it_lb) !=
_tdomain->end());
514 for(
auto& si : *
this)
530 requires (std::is_same_v<typename Wrapper<V>::Domain,T> || std::is_same_v<V,double>)
536 s.set(T(s.codomain()).inflate(
rad),
false);
540 s.set(T(s.codomain()).inflate(
rad),
false);
553 requires (std::is_same_v<typename Wrapper<V>::Domain,T> || std::is_same_v<V,double>)
561 s.set(T(s.codomain()).inflate(
rad(s.t0_tf()).ub()),
false);
565 s.set(T(s.codomain()).inflate(
rad(s.t0_tf()).ub()),
false);
578 assert_release(i >= 0 && i <
size());
581 xi.
slice(it)->codomain() =
slice(it)->codomain()[i];
594 assert_release(i >= 0 && i <= j && j <
size());
597 xij.
slice(it)->codomain() =
slice(it)->codomain().subvector(i,j);
616 auto it_x = x.
tdomain()->cbegin();
637 auto it_x = x.
tdomain()->cbegin();
641 auto s =
slice(it_this);
642 s->set(s->codomain() & x.
slice(it_x)->codomain());
646 assert(it_x == x.
tdomain()->cend());
662 <<
" slice" << (x.
nb_slices() > 1 ?
"s" :
"")
677 AnalyticExprWrapper<typename ExprType<T>::Type>(
678 std::make_shared<AnalyticOperationExpr<
679 TubeOp<SlicedTube<T>>,
typename ExprType<T>::Type,ScalarType>>(*
this,t))
689 template<
typename Func>
690 Interval invert_common(
const T& y,
const Interval& t,
const Func& apply_invert)
const
692 assert_release(y.size() == this->size());
705 it !=
_tdomain->end() && it->lb() <= t_.
ub() ; it++)
711 invert |= apply_invert(it, t & *it);
717 template<
typename Func>
718 void invert_common_subsets(
const T& y, std::vector<Interval> &v_t,
719 const Interval& t,
const Func& apply_invert)
const
721 assert_release(y.size() == this->size());
724 if(t.is_empty() || y.is_empty())
727 else if(!t.is_subset(
_tdomain->t0_tf()))
729 v_t.push_back(Interval());
734 Interval t_ = t &
_tdomain->t0_tf();
736 assert(!t_.is_empty() && !t_.is_unbounded());
737 for(
auto it =
_tdomain->tslice(t_.lb()) ;
738 it !=
_tdomain->end() && it->lb() < t_.ub() ; it++)
744 Interval local_invert = apply_invert(it, t & *it);
746 if(local_invert.is_empty() && !
invert.is_empty())
785 return invert_common(y, t,
786 [
this,&y](
auto it,
const Interval& t_) {
787 return this->
slice(it)->invert(y, t_);
798 void invert(
const T& y, std::vector<Interval> &v_t)
const
814 return invert_common_subsets(y, v_t, t,
815 [
this,&y](
auto it,
const Interval& t_) {
816 return this->
slice(it)->invert(y, t_);
831 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
849 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
851 return invert_common(y, t,
852 [
this,&v,&y](
auto it,
const Interval& t_) {
853 return this->
slice(it)->invert(y, *v.slice(it), t_);
868 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
886 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
888 return invert_common_subsets(y, v_t, t,
889 [
this,&v,&y](
auto it,
const Interval& t_) {
890 return this->
slice(it)->invert(y, *v.slice(it), t_);
1043 c.contract(p,*
this);
1077 inline SampledTraj<typename Scalar<T>::Type>
mid()
const
1079 SampledTraj<typename Scalar<T>::Type> m;
1080 double t0 =
_tdomain->t0_tf().lb();
1081 m.set((*
this)(t0).
mid(), t0);
1082 for(
const auto& s : *
this)
1084 m.set(s.output_gate().mid(),s.t0_tf().ub());
1091 using base_container = std::list<TSlice>;
1096 struct iterator :
public base_container::iterator
1100 iterator(
SlicedTube& x, base_container::iterator it)
1101 : base_container::iterator(it), _x(x) { }
1103 std::shared_ptr<Slice<T>> operator->()
1105 return _x.slice(*
this);
1110 return *operator->();
1131 struct reverse_iterator :
public base_container::reverse_iterator
1135 reverse_iterator(
SlicedTube& x, base_container::reverse_iterator it)
1136 : base_container::reverse_iterator(it), _x(x) { }
1138 std::shared_ptr<Slice<T>> operator->()
1140 return _x.slice(*
this);
1145 return *operator->();
1166 struct const_iterator :
public base_container::const_iterator
1170 const_iterator(
const SlicedTube& x, base_container::const_iterator it)
1171 : base_container::const_iterator(it), _x(x) { }
1173 std::shared_ptr<const Slice<T>> operator->()
1175 return _x.slice(*
this);
1180 return *operator->();
1201 struct const_reverse_iterator :
public base_container::const_reverse_iterator
1205 const_reverse_iterator(
const SlicedTube& x, base_container::const_reverse_iterator it)
1206 : base_container::const_reverse_iterator(it), _x(x) { }
1208 std::shared_ptr<const Slice<T>> operator->()
1210 return _x.slice(*
this);
1215 return *operator->();
1237 template<
typename T>
1238 SlicedTube(
const std::shared_ptr<TDomain>& tdomain,
const AnalyticFunction<T>& f) ->
1239 SlicedTube<typename Wrapper<T>::Domain>;
1241 template<
typename T>
1242 SlicedTube(
const std::shared_ptr<TDomain>& tdomain,
const SampledTraj<T>& f) ->
1243 SlicedTube<typename Wrapper<T>::Domain>;
1245 template<
typename T>
1246 SlicedTube(
const std::shared_ptr<TDomain>& tdomain,
const AnalyticTraj<T>& f) ->
1247 SlicedTube<typename Wrapper<T>::Domain>;
1252 template<
typename... X>
1253 inline void CtcBase<X...>::contract(SlicedTube<X>&... x)
const
1255 auto&& x0 = std::get<0>(std::forward_as_tuple(x...));
1256 for(
auto it = x0.begin(); it != x0.end(); ++it)
1257 contract((x.slice(it)->codomain())...);
1260 template<
typename... X>
1261 inline void CtcBase<X...>::contract_tube(
SlicedTube<X>&... x)
const
1263 std::cout <<
"CtcInverse::contract_tube(...) is deprecated; \
1264 use CtcInverse::contract(...) with SlicedTube arguments instead" << std::endl;
1265 return contract(x...);
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:50
bool is_unbounded() const
Tests if one of the bounds of this is infinite.
Definition codac2_Interval_impl.h:236
bool is_empty() const
Tests if this is empty.
Definition codac2_Interval_impl.h:221
double ub() const
Returns the upper bound of this.
Definition codac2_Interval_impl.h:131
bool is_degenerated() const
Tests if this is degenerated, that is, in the form of .
Definition codac2_Interval_impl.h:241
bool is_subset(const Interval &x) const
Tests if this is a subset of x.
Definition codac2_Interval_impl.h:271
double lb() const
Returns the lower bound of this.
Definition codac2_Interval_impl.h:126
static Interval empty()
Provides an empty interval.
Definition codac2_Interval_impl.h:584
Codomain of a sliced tube over one temporal slice.
Definition codac2_Slice.h:42
std::shared_ptr< const SliceBase > first_slice() const
Returns the first slice of this tube.
Definition codac2_SlicedTubeBase.h:81
size_t nb_slices() const
Returns the number of temporal elements of this tube.
Definition codac2_SlicedTubeBase.h:67
std::shared_ptr< const SliceBase > last_slice() const
Returns the last slice of this tube.
Definition codac2_SlicedTubeBase.h:97
SlicedTubeBase(const std::shared_ptr< TDomain > &tdomain)
Creates a sliced tube over a given temporal domain.
Definition codac2_SlicedTubeBase.h:43
Tube represented over a sliced temporal domain.
Definition codac2_SlicedTube.h:38
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
SlicedTube(const SlicedTube< T > &x)
Copy constructor.
Definition codac2_SlicedTube.h:130
void set(const T &codomain, double t)
Sets the codomain at one temporal instant.
Definition codac2_SlicedTube.h:465
reverse_iterator rbegin()
Returns a reverse iterator to the last temporal slice.
Definition codac2_SlicedTube.h:1156
std::pair< T, T > enclosed_bounds(const Interval &t) const
Returns enclosed lower and upper bounds over a temporal interval.
Definition codac2_SlicedTube.h:412
void invert(const T &y, std::vector< Interval > &v_t, const SlicedTube< T > &v) const
Computes the set of continuous values of the optimal inversion .
Definition codac2_SlicedTube.h:867
void set(const T &codomain)
Sets all codomains of this tube to the same value.
Definition codac2_SlicedTube.h:444
T all_reals_value() const
Returns the unbounded codomain value associated with T.
Definition codac2_SlicedTube.h:1052
void set(const T &codomain, const Interval &t)
Sets the codomain over a temporal interval.
Definition codac2_SlicedTube.h:480
virtual std::pair< Index, Index > shape() const
Returns the matrix shape of this tube codomain.
Definition codac2_SlicedTube.h:175
SlicedTube & operator=(const SlicedTube &x)
Assignment operator.
Definition codac2_SlicedTube.h:148
void invert(const T &y, std::vector< Interval > &v_t) const
Computes the set of continuous values of the inversion .
Definition codac2_SlicedTube.h:798
SlicedTube(const std::shared_ptr< TDomain > &tdomain, const AnalyticTraj< V > &x)
Creates a sliced tube by evaluating an analytic trajectory on each temporal slice.
Definition codac2_SlicedTube.h:92
iterator begin()
Returns an iterator to the first temporal slice.
Definition codac2_SlicedTube.h:1121
T operator()(const Interval &t) const
Evaluates this tube over a temporal interval.
Definition codac2_SlicedTube.h:381
std::shared_ptr< const Slice< T > > last_slice() const
Returns the last slice of this tube.
Definition codac2_SlicedTube.h:237
std::shared_ptr< Slice< T > > first_slice()
Returns the first slice of this tube.
Definition codac2_SlicedTube.h:204
T codomain() const
Returns the global codomain of this tube.
Definition codac2_SlicedTube.h:347
T empty_value() const
Returns the empty codomain value associated with T.
Definition codac2_SlicedTube.h:1064
bool is_unbounded() const
Tests whether this tube is unbounded.
Definition codac2_SlicedTube.h:332
SlicedTube(const std::shared_ptr< TDomain > &tdomain, const AnalyticFunction< typename ExprType< T >::Type > &f)
Creates a sliced tube by evaluating an analytic function on each temporal slice.
Definition codac2_SlicedTube.h:67
SlicedTube< IntervalVector > subvector(Index i, Index j) const
Extracts a subvector of this tube.
Definition codac2_SlicedTube.h:592
void set_ith_slice(const T &codomain, Index i)
Sets the codomain of the -th stored slice.
Definition codac2_SlicedTube.h:511
std::shared_ptr< const Slice< T > > slice(const std::list< TSlice >::const_iterator &it) const
Returns the slice attached to a temporal iterator.
Definition codac2_SlicedTube.h:261
reverse_iterator rend()
Returns a reverse iterator past the first temporal slice.
Definition codac2_SlicedTube.h:1161
Index size() const
Returns the codomain dimension.
Definition codac2_SlicedTube.h:163
bool is_empty() const
Tests whether this tube is empty.
Definition codac2_SlicedTube.h:316
const_reverse_iterator rend() const
Returns a constant reverse iterator past the first temporal slice.
Definition codac2_SlicedTube.h:1231
double volume() const
Returns the volume of this tube.
Definition codac2_SlicedTube.h:190
SlicedTube(const std::shared_ptr< TDomain > &tdomain, const SampledTraj< V > &x)
Creates a sliced tube from a sampled trajectory.
Definition codac2_SlicedTube.h:112
const_reverse_iterator rbegin() const
Returns a constant reverse iterator to the last temporal slice.
Definition codac2_SlicedTube.h:1226
Interval invert(const T &y) const
Returns the interval inversion .
Definition codac2_SlicedTube.h:768
SlicedTube & operator&=(const SlicedTube &x)
Intersects this tube with another one.
Definition codac2_SlicedTube.h:633
const SlicedTube< T > & inflate(const SampledTraj< V > &rad)
Inflates this tube by a time-varying sampled radius.
Definition codac2_SlicedTube.h:554
std::shared_ptr< Slice< T > > slice(const std::list< TSlice >::reverse_iterator &it)
Returns the slice attached to a reverse temporal iterator.
Definition codac2_SlicedTube.h:273
std::shared_ptr< const Slice< T > > first_slice() const
Returns the first slice of this tube.
Definition codac2_SlicedTube.h:215
iterator end()
Returns an iterator past the last temporal slice.
Definition codac2_SlicedTube.h:1126
std::shared_ptr< Slice< T > > last_slice()
Returns the last slice of this tube.
Definition codac2_SlicedTube.h:226
bool operator==(const SlicedTube &x) const
Compares two sliced tubes.
Definition codac2_SlicedTube.h:610
SlicedTube< Interval > operator[](Index i) const
Extracts one scalar component of this tube.
Definition codac2_SlicedTube.h:576
T operator()(const Interval &t, const SlicedTube< T > &v) const
Returns the optimal evaluation over a temporal interval using a derivative tube.
Definition codac2_SlicedTube.h:396
const_iterator end() const
Returns a constant iterator past the last temporal slice.
Definition codac2_SlicedTube.h:1196
std::shared_ptr< Slice< T > > slice(std::shared_ptr< TSlice > ptr)
Returns the slice attached to a temporal slice pointer.
Definition codac2_SlicedTube.h:299
Interval invert(const T &y, const SlicedTube< T > &v) const
Returns the optimal interval inversion .
Definition codac2_SlicedTube.h:830
AnalyticFunction< typename ExprType< T >::Type > as_function() const
Returns an analytic wrapper of this tube, allowing to evaluate this tube as an operator in an analyti...
Definition codac2_SlicedTube.h:673
friend std::ostream & operator<<(std::ostream &os, const SlicedTube< T > &x)
Stream output for a sliced tube.
Definition codac2_SlicedTube.h:657
const SlicedTube< T > & inflate(const V &rad)
Inflates this tube by a constant radius.
Definition codac2_SlicedTube.h:531
SampledTraj< typename Scalar< T >::Type > mid() const
Returns the approximated midpoint trajectory of this tube.
Definition codac2_SlicedTube.h:1077
std::shared_ptr< const Slice< T > > slice(const std::list< TSlice >::const_reverse_iterator &it) const
Returns the slice attached to a reverse temporal iterator.
Definition codac2_SlicedTube.h:285
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_iterator begin() const
Returns a constant iterator to the first temporal slice.
Definition codac2_SlicedTube.h:1191
static bool are_same(const std::shared_ptr< const TDomain > &tdom1, const std::shared_ptr< const TDomain > &tdom2)
Tests whether two temporal domains share the same temporal partition.
Temporal slice shared by sliced tubes.
Definition codac2_TSlice.h:34
const std::shared_ptr< TDomain > _tdomain
Shared temporal domain of this tube.
Definition codac2_TubeBase.h:71
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
bool is_superset(const Matrix< codac2::Interval, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks whether this matrix is a superset of another interval matrix.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:858
bool is_subset(const Matrix< codac2::Interval, RowsAtCompileTime, ColsAtCompileTime > &x) const
Checks whether this matrix is a subset of another interval matrix.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:678
auto lb() const
Returns a matrix containing the lower bounds of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:91
auto rad() const
Returns a matrix containing the radii of each interval element.
Definition codac2_MatrixBase_addons_IntervalMatrixBase.h:197
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:58
SlicedTube< T > primitive() const
Returns a primitive of this tube with zero initial condition.
Definition codac2_SlicedTube.h:1009
SlicedTube< T > primitive(const T &x0) const
Returns a primitive of this tube with prescribed initial condition.
Definition codac2_SlicedTube.h:1037
T integral(const Interval &t) const
Returns an enclosure of the integrals of this tube from to .
Definition codac2_SlicedTube_integral_impl.h:17
void invert(const T &y, std::vector< Interval > &v_t, const Interval &t) const
Computes the set of continuous values of the inversion .
Definition codac2_SlicedTube.h:812
Interval invert(const T &y, const SlicedTube< T > &v, const Interval &t) const
Returns the optimal interval inversion .
Definition codac2_SlicedTube.h:848
void invert(const T &y, std::vector< Interval > &v_t, const SlicedTube< T > &v, const Interval &t) const
Computes the set of continuous values of the optimal inversion .
Definition codac2_SlicedTube.h:885
Interval invert(const T &y, const Interval &t) const
Returns the interval inversion .
Definition codac2_SlicedTube.h:783
Definition codac2_OctaSym.h:21
Eigen::Matrix< Interval,-1, 1 > IntervalVector
Alias for a dynamic-size column vector of intervals.
Definition codac2_IntervalVector.h:25
Constant iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1167
Constant reverse iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1202
Mutable iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1097
Mutable reverse iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1132