Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
branch.hh
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2017
8  *
9  * Last modified:
10  * $Date$ by $Author$
11  * $Revision$
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #ifndef __GECODE_FLATZINC_BRANCH_HH__
39 #define __GECODE_FLATZINC_BRANCH_HH__
40 
41 #include <gecode/int.hh>
42 #include <gecode/int/branch.hh>
43 #include <gecode/flatzinc.hh>
44 
45 namespace Gecode { namespace FlatZinc {
46 
48  class IntBoolVarBranch : public VarBranch<IntVar> {
49  public:
51  enum Select {
58  };
59  protected:
74  public:
76  IntBoolVarBranch(Select s, double d);
84  Select select(void) const;
86  IntAFC intafc(void) const;
88  BoolAFC boolafc(void) const;
90  IntAction intaction(void) const;
92  BoolAction boolaction(void) const;
94  IntCHB intchb(void) const;
96  BoolCHB boolchb(void) const;
98  void expand(Home home, const IntVarArgs& x, const BoolVarArgs& y);
99  };
100 
102 
128 
130  class MeritMaxAFC {
131  protected:
136  public:
138  MeritMaxAFC(Space& home, const IntBoolVarBranch& ibvb);
140  MeritMaxAFC(Space& home, MeritMaxAFC& m);
142  double operator()(Int::IntView x, int i) const;
144  double operator()(Int::BoolView x, int i) const;
146  void dispose(void);
147  };
148 
151  protected:
156  public:
158  MeritMaxAFCSize(Space& home, const IntBoolVarBranch& ibvb);
162  double operator()(Int::IntView x, int i) const;
164  double operator()(Int::BoolView x, int i) const;
166  void dispose(void);
167  };
168 
171  protected:
176  public:
178  MeritMaxAction(Space& home, const IntBoolVarBranch& ibvb);
182  double operator()(Int::IntView x, int i) const;
184  double operator()(Int::BoolView x, int i) const;
186  void dispose(void);
187  };
188 
191  protected:
196  public:
198  MeritMaxActionSize(Space& home, const IntBoolVarBranch& ibvb);
202  double operator()(Int::IntView x, int i) const;
204  double operator()(Int::BoolView x, int i) const;
206  void dispose(void);
207  };
208 
210  class MeritMaxCHB {
211  protected:
216  public:
218  MeritMaxCHB(Space& home, const IntBoolVarBranch& ibvb);
220  MeritMaxCHB(Space& home, MeritMaxCHB& m);
222  double operator()(Int::IntView x, int i) const;
224  double operator()(Int::BoolView x, int i) const;
226  void dispose(void);
227  };
228 
231  protected:
236  public:
238  MeritMaxCHBSize(Space& home, const IntBoolVarBranch& ibvb);
242  double operator()(Int::IntView x, int i) const;
244  double operator()(Int::BoolView x, int i) const;
246  void dispose(void);
247  };
248 
251  private:
253  int _pos;
255  int _val;
256  public:
258  PosIntChoice(const Brancher& b, unsigned int a, int p, int n);
260  int pos(void) const;
262  int val(void) const;
264  virtual void archive(Archive& e) const;
265  };
266 
268  class IntBoolBrancherBase : public Brancher {
269  protected:
275  mutable int start;
287  public:
289  virtual bool status(const Space& home) const;
291  virtual const Choice* choice(Space& home) = 0;
293  virtual const Choice* choice(const Space& home, Archive& e);
295  virtual ExecStatus commit(Space& home, const Choice& c, unsigned int b);
297  virtual NGL* ngl(Space& home, const Choice& c, unsigned int b) const;
299  virtual void print(const Space& home, const Choice& c, unsigned int b,
300  std::ostream& o) const;
302  virtual size_t dispose(Space& home);
303  };
304 
306  template<class Merit>
308  protected:
310  Merit merit;
314  IntBoolBrancher(Home home,
316  Merit& m,
319  public:
321  virtual const Choice* choice(Space& home);
323  virtual Actor* copy(Space& home);
325  static void post(Home home,
327  Merit& m,
331  virtual size_t dispose(Space& home);
332  };
333 
335  BoolValBranch i2b(const IntValBranch& ivb);
336 
339  branch(Home home, const IntVarArgs& x, const BoolVarArgs& y,
340  IntBoolVarBranch vars, IntValBranch vals);
341 
342 }}
343 
345 
346 #endif
347 
348 // STATISTICS: flatzinc-branch
BoolCHB boolchb(void) const
Return Boolean AFC.
Definition: branch.hpp:84
BoolAction baction
Boolean action.
Definition: branch.hh:69
IntBoolVarBranch(Select s, double d)
Initialize with selection strategy s and decay factor d.
Definition: branch.hpp:41
ValSelCommitBase< Int::IntView, int > * xvsc
Integer value selection and commit object.
Definition: branch.hh:277
Merit merit
Selection by maximal merit.
Definition: branch.hh:310
With largest accumulated failure count.
Definition: branch.hh:52
IntBoolVarBranch INTBOOL_VAR_ACTION_SIZE_MAX(double d=1.0)
Select variable with largest action divided by domain size.
Definition: branch.hpp:150
IntCHB ichb
Integer CHB information.
Definition: branch.hh:233
Which values to select for branching first.
Definition: int.hh:4686
IntCHB intchb(void) const
Return integer CHB.
Definition: branch.hpp:80
Which values to select for branching first.
Definition: int.hh:4651
IntAFC iafc
Integer AFC information.
Definition: branch.hh:153
#define GECODE_FLATZINC_EXPORT
Definition: flatzinc.hh:79
bool pos(const View &x)
Test whether x is postive.
Definition: mult.hpp:45
IntAction iaction
Integer action.
Definition: branch.hh:67
int start
Unassigned views start here (might be in x or y)
Definition: branch.hh:275
Select by maximal Action over size.
Definition: branch.hh:190
Choice storing position and value
Definition: branch.hh:250
Computation spaces.
Definition: core.hpp:1668
Base class for value selection and commit.
Base-class for both propagators and branchers.
Definition: core.hpp:620
BoolAFC bafc
Boolean AFC information.
Definition: branch.hh:135
void expand(Home home, const IntVarArgs &x, const BoolVarArgs &y)
Expand AFC, action, and CHB.
Definition: branch.hpp:88
Select
Which variable selection.
Definition: branch.hh:51
Select by maximal AFC.
Definition: branch.hh:130
Gecode::IntSet d(v, 7)
BoolCHB bchb
Boolean CHB information.
Definition: branch.hh:235
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
BoolCHB bchb
Boolean CHB information.
Definition: branch.hh:215
Gecode::IntArgs i(4, 1, 2, 3, 4)
Base-class for branchers.
Definition: core.hpp:1368
With largest CHB Q-score divided by domain size.
Definition: branch.hh:57
BoolAction baction
Boolean Action information.
Definition: branch.hh:175
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
Base-class for brancher for integer and Boolean views.
Definition: branch.hh:268
Select by maximal CHB.
Definition: branch.hh:210
With largest accumulated failure count divided by domain size.
Definition: branch.hh:55
IntBoolVarBranch INTBOOL_VAR_AFC_MAX(double d=1.0)
Variable selection for both integer and Boolean variables.
Definition: branch.hpp:118
ViewArray< Int::BoolView > y
Boolean views to branch on.
Definition: branch.hh:273
Which integer or Boolean variable to select for branching.
Definition: branch.hh:48
ViewArray< Int::IntView > x
Integer views to branch on.
Definition: branch.hh:271
Recording AFC information for integer variables.
Definition: int.hh:4073
Select select(void) const
Return selection strategy.
Definition: branch.hpp:57
void branch(Home home, const IntVarArgs &x, const BoolVarArgs &y, IntBoolVarBranch vars, IntValBranch vals)
Branch function for integer and Boolean variables.
Definition: branch.cpp:124
Recording AFC information for Boolean variables.
Definition: int.hh:4113
BoolValBranch i2b(const IntValBranch &ivb)
Map respective integer value selection to Boolean value selection.
Definition: branch.hpp:425
Recording actions for Boolean variables.
Definition: int.hh:4204
IntAFC iafc
Integer AFC information.
Definition: branch.hh:133
IntCHB ichb
Integer CHB information.
Definition: branch.hh:213
Recording CHB for integer variables.
Definition: int.hh:4255
BoolAFC bafc
Boolean AFC information.
Definition: branch.hh:155
Passing integer variables.
Definition: int.hh:637
Select by maximal AFC over size.
Definition: branch.hh:150
Passing Boolean variables.
Definition: int.hh:691
Brancher for integer and Boolean views.
Definition: branch.hh:307
Select by maximal CHB over size.
Definition: branch.hh:230
IntAFC iafc
Integer AFC.
Definition: branch.hh:63
IntPropLevel ba(IntPropLevel ipl)
Extract basic or advanced from propagation level.
Definition: ipl.hpp:47
IntAction iaction
Integer Action information.
Definition: branch.hh:173
void print(std::basic_ostream< Char, Traits > &s, bool assigned, IL &lb, IU &ub, unsigned int cardMin, unsigned int cardMax)
Print set view.
Definition: print.hpp:67
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
Integer view for integer variables.
Definition: view.hpp:129
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:769
IntAction intaction(void) const
Return integer action.
Definition: branch.hpp:71
Variable branching information.
Definition: var.hpp:59
With largest action divided by domain size.
Definition: branch.hh:56
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
Choice for performing commit
Definition: core.hpp:1338
Archive representation
Definition: archive.hpp:46
Select by maximal Action.
Definition: branch.hh:170
IntBoolVarBranch INTBOOL_VAR_AFC_SIZE_MAX(double d=1.0)
Select variable with largest accumulated failure count divided by domain size.
Definition: branch.hpp:142
ExecStatus
Definition: core.hpp:464
IntCHB ichb
Integer CHB.
Definition: branch.hh:71
IntBoolVarBranch INTBOOL_VAR_CHB_MAX(double d=1.0)
Select variable with largest CHB Q-score.
Definition: branch.hpp:134
IntAFC intafc(void) const
Return integer AFC.
Definition: branch.hpp:62
ValSelCommitBase< Int::BoolView, int > * yvsc
Boolean value selection and commit object.
Definition: branch.hh:279
IntAction iaction
Integer Action information.
Definition: branch.hh:193
BoolAction baction
Boolean Action information.
Definition: branch.hh:195
Post propagator for SetVar x
Definition: set.hh:769
BoolCHB bchb
Boolean CHB.
Definition: branch.hh:73
Recording CHB for Boolean variables.
Definition: int.hh:4299
IntBoolVarBranch INTBOOL_VAR_ACTION_MAX(double d=1.0)
Select variable with highest action.
Definition: branch.hpp:126
Gecode toplevel namespace
#define GECODE_VTABLE_EXPORT
Definition: support.hh:76
BoolAction boolaction(void) const
Return Boolean action.
Definition: branch.hpp:75
BoolAFC boolafc(void) const
Return Boolean AFC.
Definition: branch.hpp:66
BoolAFC bafc
Boolean AFC.
Definition: branch.hh:65
Home class for posting propagators
Definition: core.hpp:846
IntBoolVarBranch INTBOOL_VAR_CHB_SIZE_MAX(double d=1.0)
Select variable with largest CHB Q-score divided by domain size.
Definition: branch.hpp:158
Recording actions for integer variables.
Definition: int.hh:4159
Select s
Which variable to select.
Definition: branch.hh:61
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition: filter.cpp:142
Boolean view for Boolean variables.
Definition: view.hpp:1329
No-good literal recorded during search.
Definition: core.hpp:1266