codac 1.5.6
Loading...
Searching...
No Matches
codac_Tube.h
Go to the documentation of this file.
1
12#ifndef __CODAC_TUBE_H__
13#define __CODAC_TUBE_H__
14
15#include <map>
16#include <list>
17#include <vector>
18#include "codac_TFnc.h"
19#include "codac_Slice.h"
20#include "codac_Trajectory.h"
23#include "codac_TubeTreeSynthesis.h"
24#include "codac_TubePolynomialSynthesis.h"
25#include "codac_TubeSynthesis.h"
26#include "codac_Polygon.h"
27#include "codac_BoolInterval.h"
28
29// The following define constant is now set in CMake configuration file:
30//#define AUTO_SYNTHESIS_BY_DEFAULT false
31
32namespace codac
33{
34 class TFnc;
35 class Tube;
36 class Slice;
37 class Trajectory;
38 class TubeTreeSynthesis;
39 class TubePolynomialSynthesis;
40
47 class Tube : public DynamicalItem
48 {
49 public:
50
53
60 explicit Tube(const Interval& tdomain, const Interval& codomain = Interval::ALL_REALS);
61
69 explicit Tube(const Interval& tdomain, double timestep, const Interval& codomain = Interval::ALL_REALS);
70
84 explicit Tube(const Interval& tdomain, double timestep, const TFnc& f, int f_image_id = 0);
85
95 explicit Tube(const std::vector<Interval>& v_tdomains, const std::vector<Interval>& v_codomains);
96
102 Tube(const Tube& x);
103
117 explicit Tube(const Tube& x, const TFnc& f, int f_image_id = 0);
118
130 explicit Tube(const Trajectory& traj, double timestep);
131
144 explicit Tube(const Trajectory& lb, const Trajectory& ub, double timestep);
145
153 explicit Tube(const std::string& binary_file_name);
154
164 explicit Tube(const std::string& binary_file_name, Trajectory *&traj);
165
170
176 int size() const;
177
184 const Tube primitive(const Interval& c = Interval(0.)) const;
185
192 const Tube& operator=(const Tube& x);
193
199 const Interval tdomain() const;
200
206 const Polygon polygon_envelope() const;
207
216 const Trajectory lb() const;
217
226 const Trajectory ub() const;
227
231
237 int nb_slices() const;
238
245 Slice* slice(int slice_id);
246
253 const Slice* slice(int slice_id) const;
254
264 Slice* slice(double t);
265
275 const Slice* slice(double t) const;
276
283
289 const Slice* first_slice() const;
290
297
303 const Slice* last_slice() const;
304
313
321 const Slice* wider_slice() const;
322
330
337 const Slice* largest_slice() const;
338
347
355 const Slice* steepest_slice() const;
356
363 const Interval slice_tdomain(int slice_id) const;
364
371 int time_to_index(double t) const;
372
379 int index(const Slice* slice) const;
380
390 void sample(double t);
391
404 void sample(double t, Slice *slice_to_be_sampled);
405
415 void sample(double t, const Interval& gate);
416
424 void sample(const Tube& x);
425
432 bool gate_exists(double t) const;
433
439 void remove_gate(double t);
440
448 void merge_similar_slices(double distance_threshold);
449
453
459 const Interval codomain() const;
460
469 double volume() const;
470
477 const Interval operator()(int slice_id) const;
478
485 const Interval operator()(double t) const;
486
493 const Interval operator()(const Interval& t) const;
494
502 const std::pair<Interval,Interval> eval(const Interval& t = Interval::ALL_REALS) const;
503
514 const Interval interpol(double t, const Tube& v) const;
515
526 const Interval interpol(const Interval& t, const Tube& v) const;
527
537 const Interval invert(const Interval& y, const Interval& search_tdomain = Interval::ALL_REALS) const;
538
547 void invert(const Interval& y, std::vector<Interval> &v_t, const Interval& search_tdomain = Interval::ALL_REALS) const;
548
560 const Interval invert(const Interval& y, const Tube& v, const Interval& search_tdomain = Interval::ALL_REALS) const;
561
573 void invert(const Interval& y, std::vector<Interval> &v_t, const Tube& v, const Interval& search_tdomain = Interval::ALL_REALS) const;
574
580 double max_diam() const;
581
588 double max_gate_diam(double& t) const;
589
600 const Trajectory diam(bool gates_thicknesses = false) const;
601
612 const Trajectory diam(const Tube& v) const;
613
617
627 bool operator==(const Tube& x) const;
628
638 bool operator!=(const Tube& x) const;
639
649 bool is_subset(const Tube& x) const;
650
661 bool is_strict_subset(const Tube& x) const;
662
672 bool is_interior_subset(const Tube& x) const;
673
684 bool is_strict_interior_subset(const Tube& x) const;
685
695 bool is_superset(const Tube& x) const;
696
707 bool is_strict_superset(const Tube& x) const;
708
717 bool is_empty() const;
718
731 const BoolInterval contains(const Trajectory& x) const;
732
742 bool overlaps(const Tube& x, float ratio = 1.) const;
743
747
756 const Tube& set(const Interval& y);
757
765 const Tube& set(const Interval& y, int slice_id);
766
778 const Tube& set(const Interval& y, double t);
779
791 const Tube& set(const Interval& y, const Interval& t);
792
799 const Tube& set_empty();
800
809 const Tube& inflate(double rad);
810
821 const Tube& inflate(const Trajectory& rad);
822
831 Tube& truncate_tdomain(const Interval& tdomain);
832
838 void shift_tdomain(double a);
839
843
855 const std::pair<Tube,Tube> bisect(double t, float ratio = 0.49) const;
856
860
867 const Tube& operator+=(const Interval& x);
868
875 const Tube& operator+=(const Trajectory& x);
876
883 const Tube& operator+=(const Tube& x);
884
891 const Tube& operator-=(const Interval& x);
892
899 const Tube& operator-=(const Trajectory& x);
900
907 const Tube& operator-=(const Tube& x);
908
915 const Tube& operator*=(const Interval& x);
916
923 const Tube& operator*=(const Trajectory& x);
924
931 const Tube& operator*=(const Tube& x);
932
939 const Tube& operator/=(const Interval& x);
940
947 const Tube& operator/=(const Trajectory& x);
948
955 const Tube& operator/=(const Tube& x);
956
963 const Tube& operator|=(const Interval& x);
964
971 const Tube& operator|=(const Trajectory& x);
972
979 const Tube& operator|=(const Tube& x);
980
987 const Tube& operator&=(const Interval& x);
988
995 const Tube& operator&=(const Trajectory& x);
996
1003 const Tube& operator&=(const Tube& x);
1004
1008
1016 const std::string class_name() const { return "Tube"; };
1017
1025 friend std::ostream& operator<<(std::ostream& str, const Tube& x);
1026
1027 // Tree synthesis structure
1028
1037 void enable_synthesis(SynthesisMode mode = SynthesisMode::BINARY_TREE, double eps = 1.e-3) const;
1038
1042
1052 const Interval integral(double t) const;
1053
1063 const Interval integral(const Interval& t) const;
1064
1075 const Interval integral(const Interval& t1, const Interval& t2) const;
1076
1088 const std::pair<Interval,Interval> partial_integral(const Interval& t) const;
1089
1102 const std::pair<Interval,Interval> partial_integral(const Interval& t1, const Interval& t2) const;
1103
1107
1116 void serialize(const std::string& binary_file_name = "x.tube", int version_number = SERIALIZATION_VERSION) const;
1117
1129 void serialize(const std::string& binary_file_name, const Trajectory& traj, int version_number = SERIALIZATION_VERSION) const;
1130
1132
1143 static bool same_slicing(const Tube& x1, const Tube& x2);
1144
1153 static void enable_syntheses(bool enable = true);
1154
1161 static const Tube hull(const std::list<Tube>& l_tubes);
1162
1163 protected:
1164
1171
1179 const IntervalVector codomain_box() const;
1180
1190 void deserialize(const std::string& binary_file_name, Trajectory *&traj);
1191
1198
1203
1211 void create_polynomial_synthesis(double eps) const;
1212
1217
1218 // Class variables:
1219
1221 mutable TubeTreeSynthesis *m_synthesis_tree = nullptr;
1222 mutable TubePolynomialSynthesis *m_polynomial_synthesis = nullptr;
1223 mutable SynthesisMode m_synthesis_mode = SynthesisMode::NONE;
1224 Interval m_tdomain;
1225
1226 friend void deserialize_Tube(std::ifstream& bin_file, Tube *&tube);
1227 friend void deserialize_TubeVector(std::ifstream& bin_file, TubeVector *&tube);
1228 friend class TubeVector;
1229 friend class CtcEval;
1230
1231 static bool s_enable_syntheses;
1232 };
1233}
1234
1235#endif
that contracts a tube with respect to its derivative tube and a measurement according to the const...
Definition codac_CtcEval.h:27
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
One dimensional tube , defined as an interval of scalar trajectories.
Definition codac_Tube.h:48
Slice * last_slice()
Returns a pointer to the last Slice object of this tube.
const Interval interpol(double t, const Tube &v) const
Returns the optimal evaluation of this tube at , based on the derivative information .
double max_diam() const
Returns the diameter of the interval value that is the more uncertain.
Slice * largest_slice()
Returns a pointer to the Slice object of this tube for which the interval value is the most uncertain...
Tube(const Trajectory &lb, const Trajectory &ub, double timestep)
Creates a scalar tube defined as an interval of two trajectories .
static const Tube hull(const std::list< Tube > &l_tubes)
Computes the hull of several tubes.
const Slice * largest_slice() const
Returns a constant pointer to the Slice object of this tube for which the interval value is the most ...
Slice * wider_slice()
Returns a pointer to the Slice defined over the wider temporal domain.
void delete_synthesis_tree() const
Deletes the synthesis tree of this tube.
const BoolInterval contains(const Trajectory &x) const
Returns true if this tube contains the trajectory .
void sample(double t, Slice *slice_to_be_sampled)
Samples this tube at from a pointer to the corresponding slice.
const Tube & set(const Interval &y, int slice_id)
Sets the interval value of the ith slice of this tube.
const Interval integral(double t) const
Computes the interval integral .
const Tube & operator/=(const Tube &x)
Operates /=.
Tube(const Trajectory &traj, double timestep)
Creates a scalar tube enclosing a trajectory , possibly with some temporal discretization.
const Tube & operator-=(const Interval &x)
Operates -=.
Slice * slice(int slice_id)
Returns a pointer to the ith Slice object of this tube.
const std::string class_name() const
Returns the name of this class.
Definition codac_Tube.h:1016
Tube & truncate_tdomain(const Interval &tdomain)
Truncates the tdomain of .
const Tube & operator-=(const Trajectory &x)
Operates -=.
const Tube & operator&=(const Tube &x)
Operates &=.
bool is_superset(const Tube &x) const
Returns true if this tube is a superset of .
const IntervalVector codomain_box() const
Returns the box .
TubePolynomialSynthesis * m_polynomial_synthesis
pointer to the optional synthesis tree
Definition codac_Tube.h:1222
const Tube & operator=(const Tube &x)
Returns a copy of a Tube.
void invert(const Interval &y, std::vector< Interval > &v_t, const Interval &search_tdomain=Interval::ALL_REALS) const
Computes the set of continuous values of the inversion .
Slice * first_slice()
Returns a pointer to the first Slice object of this tube.
void shift_tdomain(double a)
Shifts the tdomain of .
const Tube & operator*=(const Interval &x)
Operates *=.
const Tube & operator&=(const Interval &x)
Operates &=.
~Tube()
Tube destructor.
const Tube & operator|=(const Trajectory &x)
Operates |=.
const std::pair< Interval, Interval > partial_integral(const Interval &t) const
Computes the partial interval integral .
double max_gate_diam(double &t) const
Returns the diameter of the gate of this tube that is the more uncertain.
const Slice * steepest_slice() const
Returns a const pointer to the Slice object of this tube for which the difference between the mid val...
int index(const Slice *slice) const
Returns the Slice index related to the Slice pointer.
Slice * m_first_slice
pointer to the first Slice object of this tube
Definition codac_Tube.h:1220
Tube()
Creates a not-defined scalar tube.
const Tube & operator+=(const Trajectory &x)
Operates +=.
const Tube & operator+=(const Tube &x)
Operates +=.
const Slice * slice(double t) const
Returns a constant pointer to the Slice object of this tube that is defined at .
static void enable_syntheses(bool enable=true)
Enables the computation of a synthesis tree for any Tube object.
void sample(double t, const Interval &gate)
Samples this tube at with a specific gate value.
bool gate_exists(double t) const
Tests if a gate exists at time .
bool is_subset(const Tube &x) const
Returns true if this tube is a subset of .
const std::pair< Interval, Interval > eval(const Interval &t=Interval::ALL_REALS) const
Returns the interval evaluations of the bounds of the tube and over .
const Tube & set(const Interval &y)
Sets a constant interval value for this tube: .
Slice * slice(double t)
Returns a pointer to the Slice object of this tube that is defined at .
const Tube & set_empty()
Sets this tube to the empty set.
const Slice * wider_slice() const
Returns a constant pointer to the Slice defined over the wider temporal domain.
void create_synthesis_tree() const
Creates the synthesis tree associated to the values of this tube.
const Interval slice_tdomain(int slice_id) const
Returns the temporal definition domain of the ith Slice of this tube.
void serialize(const std::string &binary_file_name="x.tube", int version_number=SERIALIZATION_VERSION) const
Serializes this tube.
static bool same_slicing(const Tube &x1, const Tube &x2)
Tests whether the two Tube objects are sharing the same slicing.
const std::pair< Tube, Tube > bisect(double t, float ratio=0.49) const
Bisects this tube.
const Tube & inflate(double rad)
Inflates this tube by adding to all its codomain components.
const Trajectory diam(bool gates_thicknesses=false) const
Returns the diameters of the tube as a trajectory.
void create_polynomial_synthesis(double eps) const
Creates the synthesis tree associated to the values of this tube.
const Polygon polygon_envelope() const
Returns the polygon envelope of this tube.
Slice * steepest_slice()
Returns a pointer to the Slice object of this tube for which the difference between the mid values of...
const Tube & operator|=(const Tube &x)
Operates |=.
const Tube & operator*=(const Tube &x)
Operates *=.
bool operator!=(const Tube &x) const
Returns true if this tube is different from .
double volume() const
Returns the volume of this tube.
Tube(const Interval &tdomain, double timestep, const Interval &codomain=Interval::ALL_REALS)
Creates a scalar tube with some temporal discretization.
const Interval tdomain() const
Returns the temporal definition domain of this tube.
const Tube & operator*=(const Trajectory &x)
Operates *=.
const Trajectory diam(const Tube &v) const
Returns the diameters of the tube as a trajectory.
bool overlaps(const Tube &x, float ratio=1.) const
Returns true if this tube overlaps the tube .
bool operator==(const Tube &x) const
Returns true if this tube is equal to .
const Trajectory lb() const
Returns a possible lower bound of the tube.
const Interval integral(const Interval &t) const
Computes the interval integral .
friend std::ostream & operator<<(std::ostream &str, const Tube &x)
Displays a synthesis of this tube.
Tube(const std::string &binary_file_name, Trajectory *&traj)
Restore a scalar tube from serialization, together with a Trajectory object.
void sample(const Tube &x)
Samples this tube so that it will share the same sampling of .
const Interval interpol(const Interval &t, const Tube &v) const
Returns the optimal interval evaluation of this tube over , based on the derivative information .
const Tube & operator|=(const Interval &x)
Operates |=.
const Tube & set(const Interval &y, const Interval &t)
Sets the interval value of this tube over : .
SynthesisMode m_synthesis_mode
enables of the use of a synthesis tree
Definition codac_Tube.h:1223
TubeTreeSynthesis * m_synthesis_tree
pointer to the optional synthesis tree
Definition codac_Tube.h:1221
void deserialize(const std::string &binary_file_name, Trajectory *&traj)
Restores a scalar tube from serialization, together with a Trajectory object.
const Interval invert(const Interval &y, const Interval &search_tdomain=Interval::ALL_REALS) const
Returns the interval inversion .
const Interval operator()(double t) const
Returns the evaluation of this tube at .
const std::pair< Interval, Interval > partial_integral(const Interval &t1, const Interval &t2) const
Computes the partial interval integral .
const Slice * last_slice() const
Returns a constant pointer to the last Slice object of this tube.
void enable_synthesis(SynthesisMode mode=SynthesisMode::BINARY_TREE, double eps=1.e-3) const
Enables the computation of a synthesis tree.
friend void deserialize_Tube(std::ifstream &bin_file, Tube *&tube)
Creates a Tube object from a binary file.
void sample(double t)
Samples this tube at .
const Tube primitive(const Interval &c=Interval(0.)) const
Returns the primitive Tube of this tube.
bool is_empty() const
Returns true if this tube is empty.
const Trajectory ub() const
Returns a possible upper bound of the tube.
const Tube & operator/=(const Interval &x)
Operates /=.
const Interval invert(const Interval &y, const Tube &v, const Interval &search_tdomain=Interval::ALL_REALS) const
Returns the optimal interval inversion .
void invert(const Interval &y, std::vector< Interval > &v_t, const Tube &v, const Interval &search_tdomain=Interval::ALL_REALS) const
Computes the set of continuous values of the optimal inversion .
void serialize(const std::string &binary_file_name, const Trajectory &traj, int version_number=SERIALIZATION_VERSION) const
Serializes this tube together with a Trajectory object.
int size() const
Returns the dimension of the scalar tube (always 1)
const Interval codomain() const
Returns the interval of feasible values.
Tube(const Interval &tdomain, double timestep, const TFnc &f, int f_image_id=0)
Creates a scalar tube from a TFnc object and with some temporal discretization.
Tube(const Interval &tdomain, const Interval &codomain=Interval::ALL_REALS)
Creates a scalar tube made of one slice.
int nb_slices() const
Returns the number of slices of this tube.
bool is_strict_superset(const Tube &x) const
Returns true if this tube is a superset of , and not itself.
const Slice * first_slice() const
Returns a constant pointer to the first Slice object of this tube.
const Tube & operator-=(const Tube &x)
Operates -=.
const Interval integral(const Interval &t1, const Interval &t2) const
Computes the interval integral .
const Tube & set(const Interval &y, double t)
Sets the interval value of this tube at : .
void delete_polynomial_synthesis() const
Deletes the synthesis tree of this tube.
const Tube & operator&=(const Trajectory &x)
Operates &=.
void merge_similar_slices(double distance_threshold)
Merges all adjacent slices whose Hausdorff distance is less than the given threshold.
const Interval operator()(const Interval &t) const
Returns the interval evaluation of this tube over .
Tube(const std::vector< Interval > &v_tdomains, const std::vector< Interval > &v_codomains)
Creates a tube from a list of boxes .
void remove_gate(double t)
Removes the gate at and merges the two related slices.
bool is_strict_subset(const Tube &x) const
Returns true if this tube is a subset of , and not itself.
const Slice * slice(int slice_id) const
Returns a constant pointer to the ith Slice object of this tube.
bool is_interior_subset(const Tube &x) const
Returns true if this tube is a subset of the interior of .
Tube(const std::string &binary_file_name)
Restore a scalar tube from serialization.
bool is_strict_interior_subset(const Tube &x) const
Returns true if this tube is a subset of the interior of , and not itself.
const Tube & operator+=(const Interval &x)
Operates +=.
Tube(const Tube &x)
Creates a copy of a scalar tube , with the same time discretization.
const Interval operator()(int slice_id) const
Returns the value of the ith slice.
Interval m_tdomain
redundant information for fast evaluations
Definition codac_Tube.h:1224
int time_to_index(double t) const
Returns the Slice index related to the temporal key .
Tube(const Tube &x, const TFnc &f, int f_image_id=0)
Creates a copy of a scalar tube , with the same time discretization but a specific codomain defined b...
const Tube & operator/=(const Trajectory &x)
Operates /=.
const Tube & inflate(const Trajectory &rad)
Inflates this tube by adding non-constant uncertainties defined in a trajectory.
friend void deserialize_TubeVector(std::ifstream &bin_file, TubeVector *&tube)
Creates a TubeVector object from a binary file.
n-dimensional tube , defined as an interval of n-dimensional trajectories
Definition codac_TubeVector.h:39
FixPoint of a separator The fixpoint of a separator is computed by calling the "::"separate function ...
Definition codac_capd_helpers.h:9