codac 1.5.6
Loading...
Searching...
No Matches
codac_Domain.h
Go to the documentation of this file.
1
12#ifndef __CODAC_DOMAIN_H__
13#define __CODAC_DOMAIN_H__
14
15#include <functional>
16#include "codac_Interval.h"
17#include "codac_Variable.h"
19#include "codac_Slice.h"
20#include "codac_Tube.h"
21#include "codac_TubeVector.h"
22#include "codac_Contractor.h"
23#include "codac_Hashcode.h"
24
25namespace codac
26{
27 // todo: assert if structure of referenced domain changes (size, nb slices)
28
29 class DynCtc;
30 class Contractor;
31 class ContractorNetwork;
32
33 class Domain
34 {
35 public:
36
37 enum class Type { T_INTERVAL, T_INTERVAL_VECTOR, T_SLICE, T_TUBE, T_TUBE_VECTOR };
38 enum class MemoryRef { M_DOUBLE, M_INTERVAL, M_INTERVAL_VAR, M_VECTOR, M_INTERVAL_VECTOR, M_INTERVAL_VECTOR_VAR, M_SLICE, M_TUBE, M_TUBE_VECTOR };
39
40 Domain();
41 Domain(const Domain& ad);
42 // todo: constructor with non-ref double?
43 Domain(double& d);
44 Domain(Interval& i);
45 Domain(Interval& i, double& extern_d);
46 Domain(Interval& i, Interval& extern_i);
47 Domain(const Interval& i, bool interm_var = false);
48 Domain(IntervalVar& i);
49 Domain(Vector& v);
50 // todo: ? Domain(const Vector& v);
51 Domain(IntervalVector& iv);
52 Domain(const IntervalVector& iv, bool interm_var = false);
53 Domain(IntervalVectorVar& iv);
54 Domain(Slice& s);
55 Domain(Tube& t);
56 Domain(const Tube& t, bool interm_var = false);
57 Domain(TubeVector& tv);
58 Domain(const TubeVector& tv, bool interm_var = false);
59 ~Domain();
60
61 const Domain& operator=(const Domain& ad);
62 void set_ref_values(const Domain& ad);
63
64 int id() const;
65 Type type() const;
66
67 Interval& interval();
68 const Interval& interval() const;
69 IntervalVector& interval_vector();
70 const IntervalVector& interval_vector() const;
71 Slice& slice();
72 const Slice& slice() const;
73 Tube& tube();
74 const Tube& tube() const;
75 TubeVector& tube_vector();
76 const TubeVector& tube_vector() const;
77
78 std::vector<Contractor*>& contractors();
79 const std::vector<Contractor*>& contractors() const;
80 void add_ctc(Contractor *ctc);
81
82 bool is_var() const;
83 bool is_var_not_associated() const;
84
85 double compute_volume() const;
86 double get_saved_volume() const;
87 void set_volume(double vol);
88
89 bool is_interm_var() const;
90 void reset_value();
91
92 bool is_empty() const;
93
94 bool operator==(const Domain& x) const;
95 bool operator!=(const Domain& x) const;
96
97 bool is_component_of(const Domain& x) const;
98 bool is_component_of(const Domain& x, int& component_id) const;
99
100 bool is_slice_of(const Domain& x) const;
101 bool is_slice_of(const Domain& x, int& slice_id) const;
102
103 void add_data(double t, const Interval& y, ContractorNetwork& cn);
104 void add_data(double t, const IntervalVector& y, ContractorNetwork& cn);
105
106 const std::string dom_name(const std::map<DomainHashcode,Domain*> m_domains) const;
107 void set_name(const std::string& name);
108
109 static bool all_dyn(const std::vector<Domain>& v_domains);
110 static bool all_slices(const std::vector<Domain>& v_domains);
111 static bool dyn_same_slicing(const std::vector<Domain>& v_domains);
112 static int total_size(const std::vector<Domain>& v_domains);
113
114 static Domain vector_component(Domain& x, int i);
115
116 const std::string dom_type_str() const;
117 friend std::ostream& operator<<(std::ostream& str, const Domain& x);
118
119 protected:
120
121 Domain(Type type, MemoryRef memory_type);
122 const std::string var_name(const std::map<DomainHashcode,Domain*> m_domains) const;
123
124 // Theoretical type of domain
125
126 Type m_type;
127
128 union // reference to the values (in memory) this domain is made of
129 {
130 std::reference_wrapper<Interval> m_ref_values_i;
131 std::reference_wrapper<IntervalVector> m_ref_values_iv;
132 std::reference_wrapper<Slice> m_ref_values_s;
133 std::reference_wrapper<Tube> m_ref_values_t;
134 std::reference_wrapper<TubeVector> m_ref_values_tv;
135 };
136
137 union // if locally stored (such as intermediate variables or doubles to intervals):
138 {
139 Interval *m_i_ptr;
140 IntervalVector *m_iv_ptr;
141 Tube *m_t_ptr;
142 TubeVector *m_tv_ptr;
143 };
144
145 // Memory implementation of the domain
146
147 MemoryRef m_memory_type;
148
149 union // reference to the unique object (in memory) this domain represents
150 {
151 std::reference_wrapper<double> m_ref_memory_d;
152 std::reference_wrapper<Interval> m_ref_memory_i;
153 std::reference_wrapper<IntervalVar> m_ref_memory_ivar;
154 std::reference_wrapper<Vector> m_ref_memory_v;
155 std::reference_wrapper<IntervalVector> m_ref_memory_iv;
156 std::reference_wrapper<IntervalVectorVar> m_ref_memory_ivvar;
157 std::reference_wrapper<Slice> m_ref_memory_s;
158 std::reference_wrapper<Tube> m_ref_memory_t;
159 std::reference_wrapper<TubeVector> m_ref_memory_tv;
160 };
161
162 // Possibly initial value (for intermediate variables to be reset)
163
164 union // if locally stored (such as intermediate variables or doubles to intervals):
165 {
166 Interval *m_init_i_ptr;
167 IntervalVector *m_init_iv_ptr;
168 Tube *m_init_t_ptr;
169 TubeVector *m_init_tv_ptr;
170 };
171
172
173 // todo: update this:
174 std::map<double,double> m_map_data_s_lb, m_map_data_s_ub;
175 std::map<double,Vector> m_map_data_lb, m_map_data_ub;
176
177 Trajectory m_traj_lb, m_traj_ub;
178
179 std::vector<Contractor*> m_v_ctc;
180 double m_volume = -1.;
181
182 std::string m_name;
183 int m_dom_id;
184
185 static int dom_counter;
186
187 friend class ContractorNetwork; // todo: remove this
188 friend class DomainHashcode;
189 };
190}
191
192#endif
FixPoint of a separator The fixpoint of a separator is computed by calling the "::"separate function ...
Definition codac_capd_helpers.h:9