codac
codac_ContractorNetwork.h
Go to the documentation of this file.
1 
12 #ifndef __CODAC_CONTRACTORNETWORK_H__
13 #define __CODAC_CONTRACTORNETWORK_H__
14 
15 #include <deque>
16 #include <initializer_list>
17 #include <unordered_map>
18 #include "codac_Ctc.h"
19 #include "codac_DynCtc.h"
20 #include "codac_Domain.h"
21 #include "codac_CtcDeriv.h"
22 #include "codac_Hashcode.h"
23 #include "codac_Contractor.h"
24 #include "codac_Variable.h"
25 
26 namespace ibex
27 {
28  class Ctc;
29 }
30 
31 namespace codac
32 {
33  class Variable;
34  class Domain;
35  class DynCtc;
36  class CtcDeriv;
37  class DomainHashcode;
38  class ContractorHashcode;
39 
49  {
50  public:
51 
54 
59 
64 
70  int nb_ctc() const;
71 
77  int nb_dom() const;
78 
84  bool emptiness() const;
85 
89 
101  Interval& create_interm_var(const Interval& i);
102  Interval& create_dom(const Interval& i); // deprecated
103 
115  IntervalVector& create_interm_var(const IntervalVector& iv);
116  IntervalVector& create_dom(const IntervalVector& iv); // deprecated
117 
129  Tube& create_interm_var(const Tube& t);
130  Tube& create_dom(const Tube& t); // deprecated
131 
143  TubeVector& create_interm_var(const TubeVector& tv);
144  TubeVector& create_dom(const TubeVector& tv); // deprecated
145 
157  IntervalVector& subvector(Vector& v, int start_index, int end_index);
158 
167  IntervalVector& subvector(IntervalVector& iv, int start_index, int end_index);
168 
169  // not yet suported: /**
170  // not yet suported: * \brief Creates a subvector of a TubeVector domain
171  // not yet suported: *
172  // not yet suported: * \param tv TubeVector domain
173  // not yet suported: * \param start_index first component index of the subvector to be returned
174  // not yet suported: * \param end_index last component index of the subvector to be returned
175  // not yet suported: * \return a reference to the created TubeVector extracted from the TubeVector domain
176  // not yet suported: */
177  // not yet suported: TubeVector& subvector(TubeVector& tv, int start_index, int end_index);
178 
188  void add(Ctc& static_ctc, const std::vector<Domain>& v_domains);
189 
200  void add(DynCtc& dyn_ctc, const std::vector<Domain>& v_domains);
201 
202 
203  void add(ContractorNetwork& cn);
204 
218  void add_data(Tube& x, double t, const Interval& y);
219 
233  void add_data(TubeVector& x, double t, const IntervalVector& y);
234 
238 
247  double contract(bool verbose = false);
248 
258  double contract(const std::unordered_map<Domain,Domain>& var_dom, bool verbose = false);
259 
260  double contract_ordered_mode(bool verbose = false);
261 
274  double contract_during(double dt, bool verbose = false);
275 
290  void set_fixedpoint_ratio(float r);
291 
298  void trigger_all_contractors();
299 
303  void reset_interm_vars();
304 
312  int nb_ctc_in_stack() const;
313 
314  int iteration_nb() const;
315 
316 
320 
327  void set_name(Domain dom, const std::string& name);
328 
335  void set_name(Ctc& ctc, const std::string& name);
336 
343  void set_name(DynCtc& ctc, const std::string& name);
344 
358  int print_dot_graph(const std::string& cn_name = "cn", const std::string& layer_model = "fdp") const;
359 
367  friend std::ostream& operator<<(std::ostream& str, const ContractorNetwork& cn);
368 
370 
371  protected:
372 
383  Domain* add_dom(const Domain& ad);
384 
395  Contractor* add_ctc(const Contractor& ac);
396 
403  void add_ctc_to_queue(Contractor *ac, std::deque<Contractor*>& ctc_deque);
404 
405  void reset_value(Domain *dom);
406 
413  void trigger_ctc_related_to_dom(Domain *dom, Contractor *ctc_to_avoid = nullptr);
414 
415  void replace_var_by_dom(Domain var, Domain dom);
416 
417  protected:
418 
419  std::map<DomainHashcode,Domain*> m_map_domains;
420  std::map<ContractorHashcode,Contractor*> m_map_ctc;
421  std::deque<Contractor*> m_deque;
422 
423  int m_iteration_nb = 0;
424  float m_fixedpoint_ratio = 0.0001;
425  double m_contraction_duration_max = std::numeric_limits<double>::infinity();
426 
427  CtcDeriv *m_ctc_deriv = nullptr;
428  std::list<std::pair<Domain*,Domain*> > m_domains_related_to_ctcderiv;
429 
430  friend class Domain;
431  friend class Contractor;
432  };
433 }
434 
435 #endif
FixPoint of a separator The fixpoint of a separator is computed by calling the "::"separate function ...
Definition: codac_capd_helpers.h:9
Contractor interface.
Definition: codac_DynCtc.h:60
Definition: codac_Contractor.h:22
Graph of contractors and domains that model a problem in the constraint programming framework...
Definition: codac_ContractorNetwork.h:48
std::map< DomainHashcode, Domain * > m_map_domains
pointers to the abstract Domain objects the graph is made of
Definition: codac_ContractorNetwork.h:419
std::map< ContractorHashcode, Contractor * > m_map_ctc
pointers to the abstract Contractor objects the graph is made of
Definition: codac_ContractorNetwork.h:420
n-dimensional tube , defined as an interval of n-dimensional trajectories
Definition: codac_TubeVector.h:38
One dimensional tube , defined as an interval of scalar trajectories.
Definition: codac_Tube.h:47
that contracts a tube with respect to its derivative tube according to the constraint ...
Definition: codac_CtcDeriv.h:30
std::deque< Contractor * > m_deque
queue of active contractors
Definition: codac_ContractorNetwork.h:421