codac
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"
20 #include "codac_TrajectoryVector.h"
21 #include "codac_tube_arithmetic.h"
22 #include "codac_serialize_tubes.h"
23 #include "codac_BoolInterval.h"
24 #include "codac_TubeSynthesis.h"
25 
26 namespace codac
27 {
28  class TFnc;
29  class Tube;
30  class Trajectory;
31 
38  class TubeVector : public DynamicalItem
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 
119  TubeVector(const TubeVector& x);
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 
188  ~TubeVector();
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 
245  const TubeVector& operator=(const TubeVector& x);
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 
617  bool is_strict_interior_subset(const TubeVector& x) const;
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 
732  const TubeVector& set_empty();
733 
742  const TubeVector& inflate(double rad);
743 
752  const TubeVector& inflate(const Vector& rad);
753 
764  const TubeVector& inflate(const TrajectoryVector& rad);
765 
774  TubeVector& truncate_tdomain(const Interval& tdomain);
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 
832  const TubeVector& operator+=(const Trajectory& x);
833 
840  const TubeVector& operator+=(const Tube& x);
841 
848  const TubeVector& operator+=(const IntervalVector& x);
849 
856  const TubeVector& operator+=(const TrajectoryVector& x);
857 
864  const TubeVector& operator+=(const TubeVector& x);
865 
872  const TubeVector& operator-=(const Interval& x);
873 
880  const TubeVector& operator-=(const Trajectory& x);
881 
888  const TubeVector& operator-=(const Tube& x);
889 
896  const TubeVector& operator-=(const IntervalVector& x);
897 
904  const TubeVector& operator-=(const TrajectoryVector& x);
905 
912  const TubeVector& operator-=(const TubeVector& x);
913 
920  const TubeVector& operator*=(const Interval& x);
921 
928  const TubeVector& operator*=(const Trajectory& x);
929 
936  const TubeVector& operator*=(const Tube& x);
937 
944  const TubeVector& operator/=(const Interval& x);
945 
952  const TubeVector& operator/=(const Trajectory& x);
953 
960  const TubeVector& operator/=(const Tube& x);
961 
968  const TubeVector& operator|=(const IntervalVector& x);
969 
976  const TubeVector& operator|=(const TrajectoryVector& x);
977 
984  const TubeVector& operator|=(const TubeVector& x);
985 
992  const TubeVector& operator&=(const IntervalVector& x);
993 
1000  const TubeVector& operator&=(const TrajectoryVector& x);
1001 
1008  const TubeVector& operator&=(const TubeVector& x);
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 
1179  TubeVector();
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
bool is_interior_subset(const TubeVector &x) const
Returns true if this tube is a subset of the interior of .
const Trajectory diag(bool gates_diag=false) const
Returns the slices diagonals of the tube as a trajectory.
bool is_strict_interior_subset(const TubeVector &x) const
Returns true if this tube is a subset of the interior of , and not itself.
TubeVector()
Creates an undefined n-dimensional tube.
void serialize(const std::string &binary_file_name="x.tube", int version_number=SERIALIZATION_VERSION) const
Serializes this tube.
const TubeVector primitive() const
Returns the primitive TubeVector of this tube, with a zero constant of integration.
const TubeVector & operator|=(const IntervalVector &x)
Operates |=.
FixPoint of a separator The fixpoint of a separator is computed by calling the "::"separate function ...
Definition: codac_capd_helpers.h:9
int size() const
Returns the dimension of the tube.
const TubeVector & operator/=(const Interval &x)
Operates /=.
void resize(int n)
Resizes this TubeVector.
const TrajectoryVector diam(bool gates_thicknesses=false) const
Returns the diameters of the tube as a trajectory.
TubeVector & truncate_tdomain(const Interval &tdomain)
Truncates the tdomain of .
const IntervalVector codomain_box() const
Returns the box .
Slice of a one dimensional tube and made of an envelope and two gates.
Definition: codac_Slice.h:33
bool is_strict_superset(const TubeVector &x) const
Returns true if this tube is a superset of , and not itself.
static const TubeVector hull(const std::list< TubeVector > &l_tubes)
Computes the hull of several tubes.
const TrajectoryVector lb() const
Returns a possible lower bound of the tube.
One dimensional trajectory , defined as a temporal map of values.
Definition: codac_Trajectory.h:34
Tube & operator[](int index)
Returns the ith Tube of this TubeVector.
bool is_strict_subset(const TubeVector &x) const
Returns true if this tube is a subset of , and not itself.
static bool same_slicing(const TubeVector &x1, const Tube &x2)
Tests whether a TubeVector object shares the slicing of another Tube object.
const IntervalVector operator()(int slice_id) const
Returns the value of the ith slice.
const Slice * steepest_slice() const
Returns the slice of the Tube of this TubeVector with the largest difference between the mid values o...
bool is_empty() const
Returns true if this tube is empty.
Abstract class for common properties of Tube, TubeVector, Slice, Trajectory, TrajectoryVector objects...
Definition: codac_DynamicalItem.h:25
friend void deserialize_TubeVector(std::ifstream &bin_file, TubeVector *&tube)
Creates a TubeVector object from a binary file.
n-dimensional trajectory , defined as a temporal map of vector values
Definition: codac_TrajectoryVector.h:37
void deserialize(const std::string &binary_file_name, TrajectoryVector *&traj)
Restores a n-dimensional tube from serialization, together with a TrajectoryVector object...
int m_n
dimension of this tube
Definition: codac_TubeVector.h:1203
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 .
const TrajectoryVector ub() const
Returns a possible upper bound of the tube.
~TubeVector()
TubeVector destructor.
const TubeVector & operator+=(const Interval &x)
Operates +=.
const Vector max_diam() const
Returns a vector of the maximum diameters of the tube for each component.
n-dimensional tube , defined as an interval of n-dimensional trajectories
Definition: codac_TubeVector.h:38
const IntervalVector integral(double t) const
Computes the box integral .
One dimensional tube , defined as an interval of scalar trajectories.
Definition: codac_Tube.h:47
const TubeVector & operator &=(const IntervalVector &x)
Operates &=.
bool is_subset(const TubeVector &x) const
Returns true if this tube is a subset of .
const TubeVector & set_empty()
Sets this tube to the empty set.
const TubeVector & operator*=(const Interval &x)
Operates *=.
const TubeVector & operator=(const TubeVector &x)
Returns a copy of a TubeVector.
Tube * m_v_tubes
array of components (scalar tubes)
Definition: codac_TubeVector.h:1204
const IntervalVector interpol(double t, const TubeVector &v) const
Returns the optimal evaluation of this tube at , based on the derivative information ...
double max_gate_diam(double &t) const
Returns the maximum diameter of all gates of the tube vector in all components.
const std::pair< TubeVector, TubeVector > bisect(double t, float ratio=0.49) const
Bisects this tube.
void enable_synthesis(SynthesisMode mode=SynthesisMode::BINARY_TREE, double eps=1.e-3) const
Enables the computation of a synthesis tree.
const Interval tdomain() const
Returns the temporal definition domain of this tube.
bool operator==(const TubeVector &x) const
Returns true if this tube is equal to .
int nb_slices() const
Returns the number of slices of this tube.
const IntervalVector codomain() const
Returns the box of feasible values.
bool overlaps(const TubeVector &x, float ratio=1.) const
Returns true if this tube overlaps the tube .
const TubeVector subvector(int start_index, int end_index) const
Returns a subvector of this TubeVector.
const TubeVector & inflate(double rad)
Inflates this tube by adding to all its codomain components.
friend std::ostream & operator<<(std::ostream &str, const TubeVector &x)
Displays a synthesis of this tube.
bool is_superset(const TubeVector &x) const
Returns true if this tube is a superset of .
void put(int start_index, const TubeVector &subvec)
Puts a subvector into this TubeVector at a given position.
double volume() const
Returns the volume of this tube.
const Interval invert(const IntervalVector &y, const Interval &search_tdomain=Interval::ALL_REALS) const
Returns the interval inversion .
void sample(double t)
Samples this tube at .
void shift_tdomain(double a)
Shifts the tdomain of .
bool operator!=(const TubeVector &x) const
Returns true if this tube is different from .
const TubeVector & operator-=(const Interval &x)
Operates -=.
const std::pair< IntervalVector, IntervalVector > partial_integral(const Interval &t) const
Computes the partial box integral .
const std::string class_name() const
Returns the name of this class.
Definition: codac_TubeVector.h:1021
const BoolInterval contains(const TrajectoryVector &x) const
Returns true if this tube contains the trajectory .
int time_to_index(double t) const
Returns the Slice index related to the temporal key .