Generated on Sat Feb 7 2015 02:01:15 for Gecode by doxygen 1.8.9.1
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  * Guido Tack <tack@gecode.org>
5  * Christian Schulte <schulte@gecode.org>
6  *
7  * Contributing authors:
8  * Gabor Szokoli <szokoli@gecode.org>
9  *
10  * Copyright:
11  * Guido Tack, 2004
12  * Christian Schulte, 2004
13  * Gabor Szokoli, 2004
14  *
15  * Last modified:
16  * $Date: 2013-07-04 17:03:13 +0200 (Thu, 04 Jul 2013) $ by $Author: schulte $
17  * $Revision: 13801 $
18  *
19  * This file is part of Gecode, the generic constraint
20  * development environment:
21  * http://www.gecode.org
22  *
23  * Permission is hereby granted, free of charge, to any person obtaining
24  * a copy of this software and associated documentation files (the
25  * "Software"), to deal in the Software without restriction, including
26  * without limitation the rights to use, copy, modify, merge, publish,
27  * distribute, sublicense, and/or sell copies of the Software, and to
28  * permit persons to whom the Software is furnished to do so, subject to
29  * the following conditions:
30  *
31  * The above copyright notice and this permission notice shall be
32  * included in all copies or substantial portions of the Software.
33  *
34  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
35  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
37  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
38  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
39  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
40  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41  *
42  */
43 
44 #ifndef __GECODE_SET_BRANCH_HH__
45 #define __GECODE_SET_BRANCH_HH__
46 
47 #include <gecode/set.hh>
48 
54 namespace Gecode { namespace Set { namespace Branch {
55 
74  class MeritMin : public MeritBase<SetView,int> {
75  public:
77  MeritMin(Space& home, const VarBranch& vb);
79  MeritMin(Space& home, bool shared, MeritMin& m);
81  int operator ()(const Space& home, SetView x, int i);
82  };
83 
90  class MeritMax : public MeritBase<SetView,int> {
91  public:
93  MeritMax(Space& home, const VarBranch& vb);
95  MeritMax(Space& home, bool shared, MeritMax& m);
97  int operator ()(const Space& home, SetView x, int i);
98  };
99 
106  class MeritSize : public MeritBase<SetView,unsigned int> {
107  public:
109  MeritSize(Space& home, const VarBranch& vb);
111  MeritSize(Space& home, bool shared, MeritSize& m);
113  unsigned int operator ()(const Space& home, SetView x, int i);
114  };
115 
122  class MeritDegreeSize : public MeritBase<SetView,double> {
123  public:
125  MeritDegreeSize(Space& home, const VarBranch& vb);
127  MeritDegreeSize(Space& home, bool shared, MeritDegreeSize& m);
129  double operator ()(const Space& home, SetView x, int i);
130  };
131 
138  class MeritAFCSize : public MeritBase<SetView,double> {
139  protected:
142  public:
144  MeritAFCSize(Space& home, const VarBranch& vb);
146  MeritAFCSize(Space& home, bool shared, MeritAFCSize& m);
148  double operator ()(const Space& home, SetView x, int i);
150  bool notice(void) const;
152  void dispose(Space& home);
153  };
154 
161  class MeritActivitySize : public MeritBase<SetView,double> {
162  protected:
165  public:
167  MeritActivitySize(Space& home, const VarBranch& vb);
171  double operator ()(const Space& home, SetView x, int i);
173  bool notice(void) const;
175  void dispose(Space& home);
176  };
177 
178 }}}
179 
181 
182 namespace Gecode { namespace Set { namespace Branch {
183 
186  ViewSel<SetView>* viewsel(Space& home, const SetVarBranch& svb);
187 
188 }}}
189 
190 namespace Gecode { namespace Set { namespace Branch {
191 
210  class ValSelMin : public ValSel<SetView,int> {
211  public:
213  ValSelMin(Space& home, const ValBranch& vb);
215  ValSelMin(Space& home, bool shared, ValSelMin& vs);
217  int val(const Space& home, SetView x, int i);
218  };
219 
226  class ValSelMax : public ValSel<SetView,int> {
227  public:
229  ValSelMax(Space& home, const ValBranch& vb);
231  ValSelMax(Space& home, bool shared, ValSelMax& vs);
233  int val(const Space& home, SetView x, int i);
234  };
235 
242  class ValSelMed : public ValSel<SetView,int> {
243  public:
245  ValSelMed(Space& home, const ValBranch& vb);
247  ValSelMed(Space& home, bool shared, ValSelMed& vs);
249  int val(const Space& home, SetView x, int i);
250  };
251 
258  class ValSelRnd : public ValSel<SetView,int> {
259  protected:
262  public:
264  ValSelRnd(Space& home, const ValBranch& vb);
266  ValSelRnd(Space& home, bool shared, ValSelRnd& vs);
268  int val(const Space& home, SetView x, int i);
270  bool notice(void) const;
272  void dispose(Space& home);
273  };
274 
275 }}}
276 
278 
279 namespace Gecode { namespace Set { namespace Branch {
280 
282  class IncNGL : public ViewValNGL<SetView,int,PC_SET_ANY> {
283  public:
285  IncNGL(Space& home, SetView x, int n);
287  IncNGL(Space& home, bool share, IncNGL& ngl);
290  virtual NGL::Status status(const Space& home) const;
293  virtual ExecStatus prune(Space& home);
296  virtual NGL* copy(Space& home, bool share);
297  };
298 
300  class ExcNGL : public ViewValNGL<SetView,int,PC_SET_ANY> {
301  public:
303  ExcNGL(Space& home, SetView x, int n);
305  ExcNGL(Space& home, bool share, ExcNGL& ngl);
308  virtual NGL::Status status(const Space& home) const;
311  virtual ExecStatus prune(Space& home);
314  virtual NGL* copy(Space& home, bool share);
315  };
316 
317 }}}
318 
319 #include <gecode/set/branch/ngl.hpp>
320 
321 namespace Gecode { namespace Set { namespace Branch {
322 
341  class ValCommitInc : public ValCommit<SetView,int> {
342  public:
344  ValCommitInc(Space& home, const ValBranch& vb);
346  ValCommitInc(Space& home, bool shared, ValCommitInc& vc);
348  ModEvent commit(Space& home, unsigned int a, SetView x, int i, int n);
350  NGL* ngl(Space& home, unsigned int a, View x, int n) const;
352  void print(const Space& home, unsigned int a, SetView x, int i, int n,
353  std::ostream& o) const;
354  };
355 
362  class ValCommitExc : public ValCommit<SetView,int> {
363  public:
365  ValCommitExc(Space& home, const ValBranch& vb);
367  ValCommitExc(Space& home, bool shared, ValCommitExc& vc);
369  ModEvent commit(Space& home, unsigned int a, SetView x, int i, int n);
371  NGL* ngl(Space& home, unsigned int a, View x, int n) const;
373  void print(const Space& home, unsigned int a, SetView x, int i, int n,
374  std::ostream& o) const;
375  };
376 
377 }}}
378 
380 
381 namespace Gecode { namespace Set { namespace Branch {
382 
385  ValSelCommitBase<SetView,int>*
386  valselcommit(Space& home, const SetValBranch& svb);
387 
390  ValSelCommitBase<SetView,int>*
391  valselcommit(Space& home, const SetAssign& ia);
392 
393 }}}
394 
395 #endif
396 
397 // STATISTICS: set-branch
398 
No-good literal for inclusion.
Definition: branch.hh:282
Merit class for size over afc.
Definition: branch.hh:138
Merit class for maximum of set view.
Definition: branch.hh:90
void print(const Space &home, unsigned int a, SetView x, int i, int n, std::ostream &o) const
Print on o the alternative with view x at position i and value n.
Definition: val-commit.hpp:64
double operator()(const Space &home, SetView x, int i)
Return size over AFC as merit for view x at position i.
Definition: merit.hpp:110
MeritMax(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:61
int val(const Space &home, SetView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:65
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:118
Value selection class for median of view.
Definition: branch.hh:242
void dispose(Space &home)
Dispose view selection.
Definition: merit.hpp:142
int val(const Space &home, SetView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:105
MeritMin(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:48
int operator()(const Space &home, SetView x, int i)
Return minimum as merit for view x at position i.
Definition: merit.hpp:54
Value selection class for mimimum of view.
Definition: branch.hh:210
ValSelMax(Space &home, const ValBranch &vb)
Constructor for initialization.
Definition: val-sel.hpp:59
Status
The status of a no-good literal.
Definition: core.hpp:977
Value commit class for exclusion.
Definition: branch.hh:362
int ModEvent
Type for modification events.
Definition: core.hpp:146
Base-class for merit class.
void print(const Space &home, unsigned int a, SetView x, int i, int n, std::ostream &o) const
Print on o the alternative with view x at position i and value n.
Definition: val-commit.hpp:88
NGL * ngl(Space &home, unsigned int a, View x, int n) const
Create no-good literal for alternative a.
Definition: val-commit.hpp:57
double operator()(const Space &home, SetView x, int i)
Return size over degree as merit for view x at position i.
Definition: merit.hpp:95
NGL * ngl(Space &home, unsigned int a, View x, int n) const
Create no-good literal for alternative a.
Definition: val-commit.hpp:81
Computation spaces.
Definition: core.hpp:1362
ValCommitInc(Space &home, const ValBranch &vb)
Constructor for initialization.
Definition: val-commit.hpp:47
ValSelMed(Space &home, const ValBranch &vb)
Constructor for initialization.
Definition: val-sel.hpp:73
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition: ngl.cpp:75
Base class for value commit.
MeritDegreeSize(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:88
Merit class for size over activity.
Definition: branch.hh:161
int val(const Space &home, SetView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:79
Gecode::IntArgs i(4, 1, 2, 3, 4)
MeritSize(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:76
Class for AFC (accumulated failure count) management.
Definition: afc.hpp:44
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
ViewSel< SetView > * viewsel(Space &home, const SetVarBranch &svb)
Return view selectors for set views.
Definition: view-sel.cpp:43
double operator()(const Space &home, SetView x, int i)
Return size over activity as merit for view x at position i.
Definition: merit.hpp:134
MeritActivitySize(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:124
AFC afc
AFC information.
Definition: branch.hh:141
virtual NGL * copy(Space &home, bool share)
Create copy.
Definition: ngl.cpp:43
ValSelCommitBase< SetView, int > * valselcommit(Space &home, const SetValBranch &svb)
Return value and commit for set views.
No-good literal for exclusion.
Definition: branch.hh:300
ModEvent commit(Space &home, unsigned int a, SetView x, int i, int n)
Commit view x at position i to value n for alternative a.
Definition: val-commit.hpp:53
virtual NGL::Status status(const Space &home) const
Test the status of the no-good literal.
Definition: ngl.cpp:66
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:138
Set view for set variables
Definition: view.hpp:60
Value branching information.
Definition: branch-val.hpp:44
Merit class for size of set view.
Definition: branch.hh:106
Variable branching information.
Definition: branch-var.hpp:55
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Value commit class for inclusion.
Definition: branch.hh:341
ValSelRnd(Space &home, const ValBranch &vb)
Constructor for initialization.
Definition: val-sel.hpp:97
ExcNGL(Space &home, SetView x, int n)
Constructor for creation.
Definition: ngl.hpp:48
int operator()(const Space &home, SetView x, int i)
Return maximum as merit for view x at position i.
Definition: merit.hpp:67
ExecStatus
Definition: core.hpp:523
Merit class for size over degree.
Definition: branch.hh:122
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: merit.hpp:114
View-value no-good literal.
Value selection class for maximum of view.
Definition: branch.hh:226
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: val-sel.hpp:117
bool shared(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether views share same variable.
Definition: view.hpp:662
ValCommitExc(Space &home, const ValBranch &vb)
Constructor for initialization.
Definition: val-commit.hpp:71
unsigned int operator()(const Space &home, SetView x, int i)
Return size as merit for view x at position i.
Definition: merit.hpp:82
Gecode toplevel namespace
virtual NGL * copy(Space &home, bool share)
Create copy.
Definition: ngl.cpp:62
MeritAFCSize(Space &home, const VarBranch &vb)
Constructor for initialization.
Definition: merit.hpp:102
virtual ExecStatus prune(Space &home)
Propagate the negation of the no-good literal.
Definition: ngl.cpp:56
Random number generator.
Definition: rnd.hpp:46
IncNGL(Space &home, SetView x, int n)
Constructor for creation.
Definition: ngl.hpp:41
ModEvent commit(Space &home, unsigned int a, SetView x, int i, int n)
Commit view x at position i to value n for alternative a.
Definition: val-commit.hpp:77
Activity activity
Activity information.
Definition: branch.hh:164
Class for activity management.
Definition: activity.hpp:44
int val(const Space &home, SetView x, int i)
Return value of view x at position i.
Definition: val-sel.hpp:53
Value selection class for random value of view.
Definition: branch.hh:258
ValSelMin(Space &home, const ValBranch &vb)
Constructor for initialization.
Definition: val-sel.hpp:47
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
#define GECODE_SET_EXPORT
Definition: set.hh:69
Merit class for mimimum of set views.
Definition: branch.hh:74
void dispose(Space &home)
Delete value selection.
Definition: val-sel.hpp:121
Rnd r
The used random number generator.
Definition: branch.hh:261
Base class for value selection.
No-good literal recorded during search.
Definition: core.hpp:971
virtual NGL::Status status(const Space &home) const
Test the status of the no-good literal.
Definition: ngl.cpp:47