codac 1.5.6
Loading...
Searching...
No Matches
codac_TubeVector.h
Go to the documentation of this file.
1
12#ifndef __CODAC_TUBEVECTOR_H__
13#define __CODAC_TUBEVECTOR_H__
14
15#include <map>
16#include <list>
17#include <vector>
18#include <initializer_list>
19#include "codac_TFnc.h"
23#include "codac_BoolInterval.h"
24#include "codac_TubeSynthesis.h"
25
26namespace codac
27{
28 class TFnc;
29 class Tube;
30 class Trajectory;
31
39 {
40 public:
41
44
51 explicit TubeVector(const Interval& tdomain, int n);
52
61 explicit TubeVector(const Interval& tdomain, const IntervalVector& codomain);
62
70 explicit TubeVector(const Interval& tdomain, double timestep, int n);
71
79 explicit TubeVector(const Interval& tdomain, double timestep, const IntervalVector& codomain);
80
94 explicit TubeVector(const Interval& tdomain, double timestep, const TFnc& f);
95
105 explicit TubeVector(const std::vector<Interval>& v_tdomains, const std::vector<IntervalVector>& v_codomains);
106
112 TubeVector(std::initializer_list<Tube> list);
113
120
128 explicit TubeVector(const TubeVector& x, const IntervalVector& codomain);
129
138 explicit TubeVector(int n, const Tube& x);
139
150 explicit TubeVector(const TrajectoryVector& traj, double timestep);
151
163 explicit TubeVector(const TrajectoryVector& lb, const TrajectoryVector& ub, double timestep);
164
172 explicit TubeVector(const std::string& binary_file_name);
173
183 explicit TubeVector(const std::string& binary_file_name, TrajectoryVector *&traj);
184
189
195 int size() const;
196
205 void resize(int n);
206
214 const TubeVector subvector(int start_index, int end_index) const;
215
222 void put(int start_index, const TubeVector& subvec);
223
229 const TubeVector primitive() const;
230
237 const TubeVector primitive(const IntervalVector& c) const;
238
246
252 const Interval tdomain() const;
253
262 const TrajectoryVector lb() const;
263
272 const TrajectoryVector ub() const;
273
277
283 int nb_slices() const;
284
291 int time_to_index(double t) const;
292
301 void sample(double t);
302
312 void sample(double t, const IntervalVector& gate);
313
322 void sample(const Tube& x);
323
332 void sample(const TubeVector& x);
333
337
343 const IntervalVector codomain() const;
344
353 double volume() const;
354
361 Tube& operator[](int index);
362
369 const Tube& operator[](int index) const;
370
377 const IntervalVector operator()(int slice_id) const;
378
385 const IntervalVector operator()(double t) const;
386
393 const IntervalVector operator()(const Interval& t) const;
394
402 const std::pair<IntervalVector,IntervalVector> eval(const Interval& t = Interval::ALL_REALS) const;
403
414 const IntervalVector interpol(double t, const TubeVector& v) const;
415
426 const IntervalVector interpol(const Interval& t, const TubeVector& v) const;
427
437 const Interval invert(const IntervalVector& y, const Interval& search_tdomain = Interval::ALL_REALS) const;
438
447 void invert(const IntervalVector& y, std::vector<Interval> &v_t, const Interval& search_tdomain = Interval::ALL_REALS) const;
448
460 const Interval invert(const IntervalVector& y, const TubeVector& v, const Interval& search_tdomain = Interval::ALL_REALS) const;
461
473 void invert(const IntervalVector& y, std::vector<Interval> &v_t, const TubeVector& v, const Interval& search_tdomain = Interval::ALL_REALS) const;
474
485 const TrajectoryVector diam(bool gates_thicknesses = false) const;
486
497 const TrajectoryVector diam(const TubeVector& v) const;
498
504 const Vector max_diam() const;
505
512 double max_gate_diam(double& t) const;
513
519 const Slice* steepest_slice() const;
520
531 const Trajectory diag(bool gates_diag = false) const;
532
545 const Trajectory diag(int start_index, int end_index, bool gates_diag = false) const;
546
550
560 bool operator==(const TubeVector& x) const;
561
571 bool operator!=(const TubeVector& x) const;
572
582 bool is_subset(const TubeVector& x) const;
583
594 bool is_strict_subset(const TubeVector& x) const;
595
605 bool is_interior_subset(const TubeVector& x) const;
606
618
628 bool is_superset(const TubeVector& x) const;
629
640 bool is_strict_superset(const TubeVector& x) const;
641
650 bool is_empty() const;
651
664 const BoolInterval contains(const TrajectoryVector& x) const;
665
675 bool overlaps(const TubeVector& x, float ratio = 1.) const;
676
680
689 const TubeVector& set(const IntervalVector& y);
690
698 const TubeVector& set(const IntervalVector& y, int slice_id);
699
711 const TubeVector& set(const IntervalVector& y, double t);
712
724 const TubeVector& set(const IntervalVector& y, const Interval& t);
725
733
742 const TubeVector& inflate(double rad);
743
752 const TubeVector& inflate(const Vector& rad);
753
765
775
781 void shift_tdomain(double a);
782
786
798 const std::pair<TubeVector,TubeVector> bisect(double t, float ratio = 0.49) const;
799
812 const std::pair<TubeVector,TubeVector> bisect(double t, int dim, float ratio = 0.49) const;
813
817
824 const TubeVector& operator+=(const Interval& x);
825
833
840 const TubeVector& operator+=(const Tube& x);
841
848 const TubeVector& operator+=(const IntervalVector& x);
849
857
865
872 const TubeVector& operator-=(const Interval& x);
873
881
888 const TubeVector& operator-=(const Tube& x);
889
896 const TubeVector& operator-=(const IntervalVector& x);
897
905
913
920 const TubeVector& operator*=(const Interval& x);
921
929
936 const TubeVector& operator*=(const Tube& x);
937
944 const TubeVector& operator/=(const Interval& x);
945
953
960 const TubeVector& operator/=(const Tube& x);
961
968 const TubeVector& operator|=(const IntervalVector& x);
969
977
985
992 const TubeVector& operator&=(const IntervalVector& x);
993
1001
1009
1013
1021 const std::string class_name() const { return "TubeVector"; };
1022
1030 friend std::ostream& operator<<(std::ostream& str, const TubeVector& x);
1031
1035
1044 void enable_synthesis(SynthesisMode mode = SynthesisMode::BINARY_TREE, double eps = 1.e-3) const;
1045
1049
1059 const IntervalVector integral(double t) const;
1060
1070 const IntervalVector integral(const Interval& t) const;
1071
1082 const IntervalVector integral(const Interval& t1, const Interval& t2) const;
1083
1095 const std::pair<IntervalVector,IntervalVector> partial_integral(const Interval& t) const;
1096
1109 const std::pair<IntervalVector,IntervalVector> partial_integral(const Interval& t1, const Interval& t2) const;
1110
1114
1123 void serialize(const std::string& binary_file_name = "x.tube", int version_number = SERIALIZATION_VERSION) const;
1124
1136 void serialize(const std::string& binary_file_name, const TrajectoryVector& traj, int version_number = SERIALIZATION_VERSION) const;
1137
1139
1150 static bool same_slicing(const TubeVector& x1, const Tube& x2);
1151
1162 static bool same_slicing(const TubeVector& x1, const TubeVector& x2);
1163
1170 static const TubeVector hull(const std::list<TubeVector>& l_tubes);
1171
1172 protected:
1173
1180
1188 const IntervalVector codomain_box() const;
1189
1199 void deserialize(const std::string& binary_file_name, TrajectoryVector *&traj);
1200
1201 // Class variables:
1202
1203 int m_n = 0;
1204 Tube *m_v_tubes = nullptr;
1205
1206 friend void deserialize_TubeVector(std::ifstream& bin_file, TubeVector *&tube);
1207 };
1208}
1209
1210#endif
Abstract class for common properties of Tube, TubeVector, Slice, Trajectory, TrajectoryVector objects...
Definition codac_DynamicalItem.h:26
Slice of a one dimensional tube and made of an envelope and two gates.
Definition codac_Slice.h:34
One dimensional trajectory , defined as a temporal map of values.
Definition codac_Trajectory.h:35
n-dimensional trajectory , defined as a temporal map of vector values
Definition codac_TrajectoryVector.h:38
One dimensional tube , defined as an interval of scalar trajectories.
Definition codac_Tube.h:48
n-dimensional tube , defined as an interval of n-dimensional trajectories
Definition codac_TubeVector.h:39
TubeVector(const Interval &tdomain, double timestep, const TFnc &f)
Creates a n-dimensional tube from a TFnc object and with some temporal discretization.
const TrajectoryVector ub() const
Returns a possible upper bound of the tube.
void sample(double t, const IntervalVector &gate)
Samples this tube at with a specific gate value.
const TubeVector primitive(const IntervalVector &c) const
Returns the primitive TubeVector of this tube.
const TubeVector & operator-=(const Interval &x)
Operates -=.
TubeVector(const std::string &binary_file_name)
Restore a n-dimensional tube from serialization.
bool is_strict_superset(const TubeVector &x) const
Returns true if this tube is a superset of , and not itself.
TubeVector & truncate_tdomain(const Interval &tdomain)
Truncates the tdomain of .
void sample(const Tube &x)
Samples this tube so that each component will share the same sampling of the scalar .
const IntervalVector integral(const Interval &t) const
Computes the box integral .
const TubeVector & operator|=(const IntervalVector &x)
Operates |=.
TubeVector(const std::string &binary_file_name, TrajectoryVector *&traj)
Restore a n-dimensional tube from serialization, together with a TrajectoryVector object.
const std::pair< IntervalVector, IntervalVector > partial_integral(const Interval &t1, const Interval &t2) const
Computes the partial box integral .
const TubeVector & operator-=(const Trajectory &x)
Operates -=.
const TubeVector subvector(int start_index, int end_index) const
Returns a subvector of this TubeVector.
const TubeVector & operator*=(const Tube &x)
Operates *=.
void serialize(const std::string &binary_file_name, const TrajectoryVector &traj, int version_number=SERIALIZATION_VERSION) const
Serializes this tube together with a TrajectoryVector object.
bool is_empty() const
Returns true if this tube is empty.
const TubeVector & operator-=(const Tube &x)
Operates -=.
void invert(const IntervalVector &y, std::vector< Interval > &v_t, const Interval &search_tdomain=Interval::ALL_REALS) const
Computes the set of continuous values of the inversion .
const IntervalVector integral(double t) const
Computes the box integral .
const IntervalVector operator()(const Interval &t) const
Returns the interval evaluation of this tube over .
bool operator!=(const TubeVector &x) const
Returns true if this tube is different from .
void deserialize(const std::string &binary_file_name, TrajectoryVector *&traj)
Restores a n-dimensional tube from serialization, together with a TrajectoryVector object.
bool is_interior_subset(const TubeVector &x) const
Returns true if this tube is a subset of the interior of .
static bool same_slicing(const TubeVector &x1, const Tube &x2)
Tests whether a TubeVector object shares the slicing of another Tube object.
const TubeVector & inflate(const TrajectoryVector &rad)
Inflates this tube by adding non-constant uncertainties defined in a trajectory.
const IntervalVector operator()(int slice_id) const
Returns the value of the ith slice.
const TubeVector & operator=(const TubeVector &x)
Returns a copy of a TubeVector.
bool overlaps(const TubeVector &x, float ratio=1.) const
Returns true if this tube overlaps the tube .
TubeVector(const Interval &tdomain, const IntervalVector &codomain)
Creates a n-dimensional tube made of one slice.
const Trajectory diag(bool gates_diag=false) const
Returns the slices diagonals of the tube as a trajectory.
const TubeVector & set_empty()
Sets this tube to the empty set.
const TubeVector & operator+=(const TrajectoryVector &x)
Operates +=.
void resize(int n)
Resizes this TubeVector.
const TubeVector & operator/=(const Tube &x)
Operates /=.
const Interval tdomain() const
Returns the temporal definition domain of this tube.
Tube * m_v_tubes
array of components (scalar tubes)
Definition codac_TubeVector.h:1204
const BoolInterval contains(const TrajectoryVector &x) const
Returns true if this tube contains the trajectory .
TubeVector(const TubeVector &x, const IntervalVector &codomain)
Creates a copy of a n-dimensional tube , with the same time discretization but a specific constant co...
bool is_strict_interior_subset(const TubeVector &x) const
Returns true if this tube is a subset of the interior of , and not itself.
bool is_strict_subset(const TubeVector &x) const
Returns true if this tube is a subset of , and not itself.
static const TubeVector hull(const std::list< TubeVector > &l_tubes)
Computes the hull of several tubes.
const TubeVector & operator+=(const Trajectory &x)
Operates +=.
const TubeVector & operator-=(const TubeVector &x)
Operates -=.
TubeVector(const Interval &tdomain, double timestep, int n)
Creates a n-dimensional tube with some temporal discretization.
void sample(const TubeVector &x)
Samples this tube so that its components will share the same sampling of the components of the n-dime...
TubeVector(int n, const Tube &x)
Creates a n-dimensional tube with all the components initialized to .
void shift_tdomain(double a)
Shifts the tdomain of .
bool operator==(const TubeVector &x) const
Returns true if this tube is equal to .
const TrajectoryVector lb() const
Returns a possible lower bound of the tube.
const TubeVector & operator&=(const TrajectoryVector &x)
Operates &=.
const Tube & operator[](int index) const
Returns a const reference to the ith Tube of this TubeVector.
bool is_subset(const TubeVector &x) const
Returns true if this tube is a subset of .
const TubeVector & inflate(double rad)
Inflates this tube by adding to all its codomain components.
TubeVector(const TrajectoryVector &traj, double timestep)
Creates a n-dimensional tube enclosing a n-dimensional trajectory , possibly with some temporal disc...
TubeVector(const std::vector< Interval > &v_tdomains, const std::vector< IntervalVector > &v_codomains)
Creates a n-dimensional tube from a list of boxes .
void sample(double t)
Samples this tube at .
int m_n
dimension of this tube
Definition codac_TubeVector.h:1203
const Interval invert(const IntervalVector &y, const TubeVector &v, const Interval &search_tdomain=Interval::ALL_REALS) const
Returns the optimal interval inversion .
bool is_superset(const TubeVector &x) const
Returns true if this tube is a superset of .
const TubeVector & operator&=(const TubeVector &x)
Operates &=.
double volume() const
Returns the volume of this tube.
const IntervalVector interpol(const Interval &t, const TubeVector &v) const
Returns the optimal interval evaluation of this tube over , based on the derivative information .
int size() const
Returns the dimension of the tube.
const TubeVector & set(const IntervalVector &y, double t)
Sets the box value of this tube at : .
const Trajectory diag(int start_index, int end_index, bool gates_diag=false) const
Returns the slices diagonals of a subvector of this tube as a trajectory.
const TubeVector & operator|=(const TubeVector &x)
Operates |=.
friend std::ostream & operator<<(std::ostream &str, const TubeVector &x)
Displays a synthesis of this tube.
const Interval invert(const IntervalVector &y, const Interval &search_tdomain=Interval::ALL_REALS) const
Returns the interval inversion .
const TubeVector & operator-=(const TrajectoryVector &x)
Operates -=.
const TubeVector & operator-=(const IntervalVector &x)
Operates -=.
static bool same_slicing(const TubeVector &x1, const TubeVector &x2)
Tests whether the two TubeVector objects are sharing the same slicing.
const TubeVector & operator*=(const Interval &x)
Operates *=.
const IntervalVector codomain_box() const
Returns the box .
const std::string class_name() const
Returns the name of this class.
Definition codac_TubeVector.h:1021
const TubeVector & operator+=(const Interval &x)
Operates +=.
TubeVector()
Creates an undefined n-dimensional tube.
const TubeVector primitive() const
Returns the primitive TubeVector of this tube, with a zero constant of integration.
const std::pair< IntervalVector, IntervalVector > partial_integral(const Interval &t) const
Computes the partial box integral .
const TrajectoryVector diam(const TubeVector &v) const
Returns the diameters of the tube as a trajectory.
void invert(const IntervalVector &y, std::vector< Interval > &v_t, const TubeVector &v, const Interval &search_tdomain=Interval::ALL_REALS) const
Computes the set of continuous values of the optimal inversion .
const TubeVector & operator/=(const Trajectory &x)
Operates /=.
const TubeVector & set(const IntervalVector &y)
Sets a constant box value for this tube: .
const TubeVector & operator+=(const TubeVector &x)
Operates +=.
void put(int start_index, const TubeVector &subvec)
Puts a subvector into this TubeVector at a given position.
const TubeVector & operator/=(const Interval &x)
Operates /=.
const IntervalVector codomain() const
Returns the box of feasible values.
void enable_synthesis(SynthesisMode mode=SynthesisMode::BINARY_TREE, double eps=1.e-3) const
Enables the computation of a synthesis tree.
const std::pair< TubeVector, TubeVector > bisect(double t, float ratio=0.49) const
Bisects this tube.
const TrajectoryVector diam(bool gates_thicknesses=false) const
Returns the diameters of the tube as a trajectory.
int nb_slices() const
Returns the number of slices of this tube.
TubeVector(const TrajectoryVector &lb, const TrajectoryVector &ub, double timestep)
Creates a n-dimensional tube defined as an interval of two n-dimensional trajectories .
TubeVector(const Interval &tdomain, int n)
Creates a n-dimensional tube made of one slice.
const IntervalVector interpol(double t, const TubeVector &v) const
Returns the optimal evaluation of this tube at , based on the derivative information .
const TubeVector & operator|=(const TrajectoryVector &x)
Operates |=.
const TubeVector & operator*=(const Trajectory &x)
Operates *=.
const IntervalVector integral(const Interval &t1, const Interval &t2) const
Computes the box integral .
double max_gate_diam(double &t) const
Returns the maximum diameter of all gates of the tube vector in all components.
Tube & operator[](int index)
Returns the ith Tube of this TubeVector.
void serialize(const std::string &binary_file_name="x.tube", int version_number=SERIALIZATION_VERSION) const
Serializes this tube.
const TubeVector & operator+=(const Tube &x)
Operates +=.
TubeVector(const TubeVector &x)
Creates a copy of a n-dimensional tube , with the same time discretization.
const TubeVector & set(const IntervalVector &y, const Interval &t)
Sets the box value of this tube over : .
const Vector max_diam() const
Returns a vector of the maximum diameters of the tube for each component.
TubeVector(const Interval &tdomain, double timestep, const IntervalVector &codomain)
Creates a n-dimensional tube with some temporal discretization.
const TubeVector & set(const IntervalVector &y, int slice_id)
Sets the box value of the ith slice of this tube.
~TubeVector()
TubeVector destructor.
const Slice * steepest_slice() const
Returns the slice of the Tube of this TubeVector with the largest difference between the mid values o...
const TubeVector & operator&=(const IntervalVector &x)
Operates &=.
const std::pair< TubeVector, TubeVector > bisect(double t, int dim, float ratio=0.49) const
Bisects this tube along a specific dimension.
const std::pair< IntervalVector, IntervalVector > eval(const Interval &t=Interval::ALL_REALS) const
Returns the interval evaluations of the bounds of the tube and over .
int time_to_index(double t) const
Returns the Slice index related to the temporal key .
const TubeVector & inflate(const Vector &rad)
Inflates this tube by adding to all its codomain components.
const TubeVector & operator+=(const IntervalVector &x)
Operates +=.
TubeVector(std::initializer_list< Tube > list)
Creates a n-dimensional tube from a list of Tube objects.
const IntervalVector operator()(double t) const
Returns the evaluation of this tube at .
friend void deserialize_TubeVector(std::ifstream &bin_file, TubeVector *&tube)
Creates a TubeVector object from a binary file.
FixPoint of a separator The fixpoint of a separator is computed by calling the "::"separate function ...
Definition codac_capd_helpers.h:9