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 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 slice(it)->operator()(t_, *v.slice(it));
414 auto bounds = std::make_pair(x,x);
427 while(si && si->t0_tf().lb() <= t_inter.
ub())
429 auto slice_bounds = si->enclosed_bounds(t_inter & si->t0_tf());
430 bounds.first |= slice_bounds.first;
431 bounds.second |= slice_bounds.second;
432 si = si->next_slice();
445 assert_release(
codomain.size() == this->size());
466 assert_release(
codomain.size() == this->size());
482 std::list<TSlice>::iterator it_ub;
488 if(it_ub->lb() == t.
ub())
491 if(it_lb->ub() == t.
lb())
501 }
while(it_lb != it_ub && (++it_lb) !=
_tdomain->end());
513 for(
auto& si : *
this)
529 requires (std::is_same_v<typename Wrapper<V>::Domain,T> || std::is_same_v<V,double>)
535 s.set(T(s.codomain()).inflate(
rad),
false);
539 s.set(T(s.codomain()).inflate(
rad),
false);
552 requires (std::is_same_v<typename Wrapper<V>::Domain,T> || std::is_same_v<V,double>)
560 s.set(T(s.codomain()).inflate(
rad(s.t0_tf()).ub()),
false);
564 s.set(T(s.codomain()).inflate(
rad(s.t0_tf()).ub()),
false);
577 assert_release(i >= 0 && i <
size());
580 xi.
slice(it)->codomain() =
slice(it)->codomain()[i];
593 assert_release(i >= 0 && i <= j && j <
size());
596 xij.
slice(it)->codomain() =
slice(it)->codomain().subvector(i,j);
615 auto it_x = x.
tdomain()->cbegin();
636 auto it_x = x.
tdomain()->cbegin();
640 auto s =
slice(it_this);
641 s->set(s->codomain() & x.
slice(it_x)->codomain());
645 assert(it_x == x.
tdomain()->cend());
661 <<
" slice" << (x.
nb_slices() > 1 ?
"s" :
"")
676 AnalyticExprWrapper<typename ExprType<T>::Type>(
677 std::make_shared<AnalyticOperationExpr<
678 TubeOp<SlicedTube<T>>,
typename ExprType<T>::Type,ScalarType>>(*
this,t))
688 template<
typename Func>
689 Interval invert_common(
const T& y,
const Interval& t,
const Func& apply_invert)
const
691 assert_release(y.size() == this->size());
704 it !=
_tdomain->end() && it->lb() <= t_.
ub() ; it++)
710 invert |= apply_invert(it, t & *it);
716 template<
typename Func>
717 void invert_common_subsets(
const T& y, std::vector<Interval> &v_t,
718 const Interval& t,
const Func& apply_invert)
const
720 assert_release(y.size() == this->size());
723 if(t.is_empty() || y.is_empty())
726 else if(!t.is_subset(
_tdomain->t0_tf()))
728 v_t.push_back(Interval());
733 Interval t_ = t &
_tdomain->t0_tf();
735 assert(!t_.is_empty() && !t_.is_unbounded());
736 for(
auto it =
_tdomain->tslice(t_.lb()) ;
737 it !=
_tdomain->end() && it->lb() < t_.ub() ; it++)
743 Interval local_invert = apply_invert(it, t & *it);
745 if(local_invert.is_empty() && !
invert.is_empty())
784 return invert_common(y, t,
785 [
this,&y](
auto it,
const Interval& t_) {
786 return slice(it)->invert(y, t_);
797 void invert(
const T& y, std::vector<Interval> &v_t)
const
813 return invert_common_subsets(y, v_t, t,
814 [
this,&y](
auto it,
const Interval& t_) {
815 return slice(it)->invert(y, t_);
830 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
848 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
850 return invert_common(y, t,
851 [
this,&v,&y](
auto it,
const Interval& t_) {
852 return slice(it)->invert(y, *v.slice(it), t_);
867 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
885 requires (std::is_same_v<T,Interval> || std::is_same_v<T,IntervalVector>)
887 return invert_common_subsets(y, v_t, t,
888 [
this,&v,&y](
auto it,
const Interval& t_) {
889 return slice(it)->invert(y, *v.slice(it), t_);
1042 c.contract(p,*
this);
1076 inline SampledTraj<typename Scalar<T>::Type>
mid()
const
1078 SampledTraj<typename Scalar<T>::Type> m;
1079 double t0 =
_tdomain->t0_tf().lb();
1080 m.set((*
this)(t0).
mid(), t0);
1081 for(
const auto& s : *
this)
1083 m.set(s.output_gate().mid(),s.t0_tf().ub());
1090 using base_container = std::list<TSlice>;
1095 struct iterator :
public base_container::iterator
1099 iterator(
SlicedTube& x, base_container::iterator it)
1100 : base_container::iterator(it), _x(x) { }
1102 std::shared_ptr<Slice<T>> operator->()
1104 return _x.slice(*
this);
1109 return *operator->();
1130 struct reverse_iterator :
public base_container::reverse_iterator
1134 reverse_iterator(
SlicedTube& x, base_container::reverse_iterator it)
1135 : base_container::reverse_iterator(it), _x(x) { }
1137 std::shared_ptr<Slice<T>> operator->()
1139 return _x.slice(*
this);
1144 return *operator->();
1165 struct const_iterator :
public base_container::const_iterator
1169 const_iterator(
const SlicedTube& x, base_container::const_iterator it)
1170 : base_container::const_iterator(it), _x(x) { }
1172 std::shared_ptr<const Slice<T>> operator->()
1174 return _x.slice(*
this);
1179 return *operator->();
1200 struct const_reverse_iterator :
public base_container::const_reverse_iterator
1204 const_reverse_iterator(
const SlicedTube& x, base_container::const_reverse_iterator it)
1205 : base_container::const_reverse_iterator(it), _x(x) { }
1207 std::shared_ptr<const Slice<T>> operator->()
1209 return _x.slice(*
this);
1214 return *operator->();
1236 template<
typename T>
1237 SlicedTube(
const std::shared_ptr<TDomain>& tdomain,
const AnalyticFunction<T>& f) ->
1238 SlicedTube<typename Wrapper<T>::Domain>;
1240 template<
typename T>
1241 SlicedTube(
const std::shared_ptr<TDomain>& tdomain,
const SampledTraj<T>& f) ->
1242 SlicedTube<typename Wrapper<T>::Domain>;
1244 template<
typename T>
1245 SlicedTube(
const std::shared_ptr<TDomain>& tdomain,
const AnalyticTraj<T>& f) ->
1246 SlicedTube<typename Wrapper<T>::Domain>;
1251 template<
typename... X>
1252 inline void CtcBase<X...>::contract(SlicedTube<X>&... x)
const
1254 auto&& x0 = std::get<0>(std::forward_as_tuple(x...));
1255 for(
auto it = x0.begin(); it != x0.end(); ++it)
1256 contract((x.slice(it)->codomain())...);
1259 template<
typename... X>
1260 inline void CtcBase<X...>::contract_tube(
SlicedTube<X>&... x)
const
1262 std::cout <<
"CtcInverse::contract_tube(...) is deprecated; \
1263 use CtcInverse::contract(...) with SlicedTube arguments instead" << std::endl;
1264 return contract(x...);
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:49
bool is_unbounded() const
Tests if one of the bounds of this is infinite.
Definition codac2_Interval_impl.h:220
bool is_empty() const
Tests if this is empty.
Definition codac2_Interval_impl.h:205
double ub() const
Returns the upper bound of this.
Definition codac2_Interval_impl.h:115
bool is_degenerated() const
Tests if this is degenerated, that is, in the form of .
Definition codac2_Interval_impl.h:225
bool is_subset(const Interval &x) const
Tests if this is a subset of x.
Definition codac2_Interval_impl.h:255
double lb() const
Returns the lower bound of this.
Definition codac2_Interval_impl.h:110
static Interval empty()
Provides an empty interval.
Definition codac2_Interval_impl.h:568
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:464
reverse_iterator rbegin()
Returns a reverse iterator to the last temporal slice.
Definition codac2_SlicedTube.h:1155
std::pair< T, T > enclosed_bounds(const Interval &t) const
Returns enclosed lower and upper bounds over a temporal interval.
Definition codac2_SlicedTube.h:411
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:866
void set(const T &codomain)
Sets all codomains of this tube to the same value.
Definition codac2_SlicedTube.h:443
T all_reals_value() const
Returns the unbounded codomain value associated with T.
Definition codac2_SlicedTube.h:1051
void set(const T &codomain, const Interval &t)
Sets the codomain over a temporal interval.
Definition codac2_SlicedTube.h:479
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:797
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:1120
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:1063
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:591
void set_ith_slice(const T &codomain, Index i)
Sets the codomain of the -th stored slice.
Definition codac2_SlicedTube.h:510
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:1160
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:1230
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:1225
Interval invert(const T &y) const
Returns the interval inversion .
Definition codac2_SlicedTube.h:767
SlicedTube & operator&=(const SlicedTube &x)
Intersects this tube with another one.
Definition codac2_SlicedTube.h:632
const SlicedTube< T > & inflate(const SampledTraj< V > &rad)
Inflates this tube by a time-varying sampled radius.
Definition codac2_SlicedTube.h:553
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:1125
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:609
SlicedTube< Interval > operator[](Index i) const
Extracts one scalar component of this tube.
Definition codac2_SlicedTube.h:575
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:1195
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:829
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:672
friend std::ostream & operator<<(std::ostream &os, const SlicedTube< T > &x)
Stream output for a sliced tube.
Definition codac2_SlicedTube.h:656
const SlicedTube< T > & inflate(const V &rad)
Inflates this tube by a constant radius.
Definition codac2_SlicedTube.h:530
SampledTraj< typename Scalar< T >::Type > mid() const
Returns the approximated midpoint trajectory of this tube.
Definition codac2_SlicedTube.h:1076
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:1190
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:1008
SlicedTube< T > primitive(const T &x0) const
Returns a primitive of this tube with prescribed initial condition.
Definition codac2_SlicedTube.h:1036
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:811
Interval invert(const T &y, const SlicedTube< T > &v, const Interval &t) const
Returns the optimal interval inversion .
Definition codac2_SlicedTube.h:847
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:884
Interval invert(const T &y, const Interval &t) const
Returns the interval inversion .
Definition codac2_SlicedTube.h:782
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:1166
Constant reverse iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1201
Mutable iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1096
Mutable reverse iterator over the slices of this tube.
Definition codac2_SlicedTube.h:1131