Generated on Thu Mar 16 2017 03:24:22 for Gecode by doxygen 1.8.13
brancher-view-sel.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main author:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2012
8  *
9  * Last modified:
10  * $Date: 2016-06-17 15:43:08 +0200 (Fri, 17 Jun 2016) $ by $Author: schulte $
11  * $Revision: 15116 $
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 namespace Gecode {
39 
46  template<class _View>
48  class ViewSel {
49  public:
51  typedef _View View;
55 
56  ViewSel(Space& home, const VarBranch& vb);
59  ViewSel(Space& home, bool shared, ViewSel<View>& vs);
61 
63  virtual int select(Space& home, ViewArray<View>& x, int s) = 0;
66  virtual int select(Space& home, ViewArray<View>& x, int s,
67  BranchFilter bf) = 0;
69  virtual void ties(Space& home, ViewArray<View>& x, int s,
70  int* ties, int& n) = 0;
72  virtual void ties(Space& home, ViewArray<View>& x, int s,
73  int* ties, int& n, BranchFilter bf) = 0;
75  virtual void brk(Space& home, ViewArray<View>& x,
76  int* ties, int& n) = 0;
78  virtual int select(Space& home, ViewArray<View>& x,
79  int* ties, int n) = 0;
81 
83  virtual ViewSel<View>* copy(Space& home, bool shared) = 0;
86  virtual bool notice(void) const;
88  virtual void dispose(Space& home);
90  virtual ~ViewSel(void);
92 
94  static void* operator new(size_t s, Space& home);
97  static void operator delete(void* p, Space& home);
99  static void operator delete(void* p);
101  };
102 
104  template<class View>
105  class ViewSelNone : public ViewSel<View> {
106  typedef typename ViewSel<View>::BranchFilter BranchFilter;
107  public:
109 
110  ViewSelNone(Space& home, const VarBranch& vb);
113  ViewSelNone(Space& home, bool shared, ViewSelNone<View>& vs);
115 
117  virtual int select(Space& home, ViewArray<View>& x, int s);
120  virtual int select(Space& home, ViewArray<View>& x, int s,
121  BranchFilter bf);
123  virtual void ties(Space& home, ViewArray<View>& x, int s,
124  int* ties, int& n);
126  virtual void ties(Space& home, ViewArray<View>& x, int s,
127  int* ties, int& n,
128  BranchFilter bf);
130  virtual void brk(Space& home, ViewArray<View>& x,
131  int* ties, int& n);
133  virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
135 
137  virtual ViewSel<View>* copy(Space& home, bool shared);
140  };
141 
143  template<class View>
144  class ViewSelRnd : public ViewSel<View> {
145  typedef typename ViewSel<View>::BranchFilter BranchFilter;
146  protected:
149  public:
151 
152  ViewSelRnd(Space& home, const VarBranch& vb);
155  ViewSelRnd(Space& home, bool shared, ViewSelRnd<View>& vs);
157 
159  virtual int select(Space& home, ViewArray<View>& x, int s);
162  virtual int select(Space& home, ViewArray<View>& x, int s,
163  BranchFilter bf);
165  virtual void ties(Space& home, ViewArray<View>& x, int s,
166  int* ties, int& n);
168  virtual void ties(Space& home, ViewArray<View>& x, int s,
169  int* ties, int& n, BranchFilter bf);
171  virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
173  virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
175 
177  virtual ViewSel<View>* copy(Space& home, bool shared);
180  };
181 
183  class ChooseMin {
184  public:
186  template<class Val>
187  bool operator ()(Val a, Val b) const;
188  };
189 
191  class ChooseMax {
192  public:
194  template<class Val>
195  bool operator ()(Val a, Val b) const;
196  };
197 
199  template<class Choose, class Merit>
200  class ViewSelChoose : public ViewSel<typename Merit::View> {
201  protected:
205  typedef typename Merit::Val Val;
207  Choose c;
209  Merit m;
210  public:
212 
213  ViewSelChoose(Space& home, const VarBranch& vb);
218 
220  virtual int select(Space& home, ViewArray<View>& x, int s);
223  virtual int select(Space& home, ViewArray<View>& x, int s,
224  BranchFilter bf);
226  virtual void ties(Space& home, ViewArray<View>& x, int s,
227  int* ties, int& n);
229  virtual void ties(Space& home, ViewArray<View>& x, int s,
230  int* ties, int& n, BranchFilter bf);
232  virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
234  virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
236 
238  virtual bool notice(void) const;
241  virtual void dispose(Space& home);
243  };
244 
245 
247  template<class Choose, class Merit>
248  class ViewSelChooseTbl : public ViewSelChoose<Choose,Merit> {
249  protected:
257  public:
259 
260  ViewSelChooseTbl(Space& home, const VarBranch& vb);
263  ViewSelChooseTbl(Space& home, bool shared,
266 
268  virtual void ties(Space& home, ViewArray<View>& x, int s,
270  int* ties, int& n);
272  virtual void ties(Space& home, ViewArray<View>& x, int s,
273  int* ties, int& n, BranchFilter bf);
275  virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
277  };
278 
280  template<class Merit>
281  class ViewSelMin : public ViewSelChoose<ChooseMin,Merit> {
284  public:
286 
287  ViewSelMin(Space& home, const VarBranch& vb);
290  ViewSelMin(Space& home, bool shared, ViewSelMin<Merit>& vs);
292 
294  virtual ViewSel<View>* copy(Space& home, bool shared);
297  };
298 
300  template<class Merit>
301  class ViewSelMinTbl : public ViewSelChooseTbl<ChooseMin,Merit> {
304  public:
306 
307  ViewSelMinTbl(Space& home, const VarBranch& vb);
312 
314  virtual ViewSel<View>* copy(Space& home, bool shared);
317  };
318 
320  template<class Merit>
321  class ViewSelMax : public ViewSelChoose<ChooseMax,Merit> {
324  public:
326 
327  ViewSelMax(Space& home, const VarBranch& vb);
330  ViewSelMax(Space& home, bool shared, ViewSelMax<Merit>& vs);
332 
334  virtual ViewSel<View>* copy(Space& home, bool shared);
337  };
338 
340  template<class Merit>
341  class ViewSelMaxTbl : public ViewSelChooseTbl<ChooseMax,Merit> {
344  public:
346 
347  ViewSelMaxTbl(Space& home, const VarBranch& vb);
352 
354  virtual ViewSel<View>* copy(Space& home, bool shared);
357  };
359 
360 
361  template<class View>
364  template<class View>
367  template<class View>
368  bool
369  ViewSel<View>::notice(void) const {
370  return false;
371  }
372  template<class View>
373  void
375  template<class View>
377  template<class View>
378  forceinline void
379  ViewSel<View>::operator delete(void*) {}
380  template<class View>
381  forceinline void
382  ViewSel<View>::operator delete(void*, Space&) {}
383  template<class View>
384  forceinline void*
385  ViewSel<View>::operator new(size_t s, Space& home) {
386  return home.ralloc(s);
387  }
388 
389 
390  template<class View>
393  : ViewSel<View>(home,vb) {}
394  template<class View>
397  ViewSelNone<View>& vs)
398  : ViewSel<View>(home,shared,vs) {}
399  template<class View>
400  int
402  return s;
403  }
404  template<class View>
405  int
407  return s;
408  }
409  template<class View>
410  void
412  int* ties, int& n) {
413  int j=0; ties[j++]=s;
414  for (int i=s+1; i<x.size(); i++)
415  if (!x[i].assigned())
416  ties[j++]=i;
417  n=j;
418  assert(n > 0);
419  }
420  template<class View>
421  void
423  int* ties, int& n, BranchFilter bf) {
424  int j=0; ties[j++]=s;
425  for (int i=s+1; i<x.size(); i++) {
426  typename View::VarType y(x[i].varimp());
427  if (!x[i].assigned() && bf(home,y,i))
428  ties[j++]=i;
429  }
430  n=j;
431  assert(n > 0);
432  }
433  template<class View>
434  void
436  // Nothing needs to be done
437  }
438  template<class View>
439  int
441  return ties[0];
442  }
443  template<class View>
446  return new (home) ViewSelNone<View>(home,shared,*this);
447  }
448 
449 
450  template<class View>
453  : ViewSel<View>(home,vb), r(vb.rnd()) {}
454  template<class View>
457  : ViewSel<View>(home,shared,vs), r(vs.r) {}
458  template<class View>
459  int
461  unsigned int n=1;
462  int j=s;
463  for (int i=s+1; i<x.size(); i++)
464  if (!x[i].assigned()) {
465  n++;
466  if (r(n) == 0U)
467  j=i;
468  }
469  return j;
470  }
471  template<class View>
473  BranchFilter bf) {
474  unsigned int n=1;
475  int j=s;
476  for (int i=s+1; i<x.size(); i++) {
477  typename View::VarType y(x[i].varimp());
478  if (!x[i].assigned() && bf(home,y,i)) {
479  n++;
480  if (r(n) == 0U)
481  j=i;
482  }
483  }
484  return j;
485  }
486  template<class View>
487  void
489  int* ties, int& n) {
490  n=1; ties[0] = select(home,x,s);
491  }
492  template<class View>
493  void
495  int* ties, int& n, BranchFilter bf) {
496  n=1; ties[0] = select(home,x,s,bf);
497  }
498  template<class View>
499  void
501  ties[0] = ties[static_cast<int>(r(static_cast<unsigned int>(n)))];
502  n=1;
503  }
504  template<class View>
505  int
507  return ties[static_cast<int>(r(static_cast<unsigned int>(n)))];
508  }
509  template<class View>
512  return new (home) ViewSelRnd<View>(home,shared,*this);
513  }
514 
515 
516  template<class Val>
517  forceinline bool
518  ChooseMin::operator ()(Val a, Val b) const {
519  return a < b;
520  }
521  template<class Val>
522  forceinline bool
523  ChooseMax::operator ()(Val a, Val b) const {
524  return a > b;
525  }
526 
527 
528  template<class Choose, class Merit>
531  : ViewSel<View>(home,vb), m(home,vb) {}
532 
533  template<class Choose, class Merit>
537  : ViewSel<View>(home,shared,vs), m(home,shared,vs.m) {}
538 
539  template<class Choose, class Merit>
540  int
542  // Consider x[s] as the so-far best view
543  int b_i = s;
544  Val b_m = m(home,x[s],s);
545  // Scan all non-assigned views from s+1 onwards
546  for (int i=s+1; i<x.size(); i++)
547  if (!x[i].assigned()) {
548  Val mxi = m(home,x[i],i);
549  if (c(mxi,b_m)) {
550  b_i = i; b_m = mxi;
551  }
552  }
553  return b_i;
554  }
555 
556  template<class Choose, class Merit>
557  int
559  BranchFilter bf) {
560  // Consider x[s] as the so-far best view
561  int b_i = s;
562  Val b_m = m(home,x[s],s);
563  // Scan all assigned views from s+1 onwards
564  for (int i=s+1; i<x.size(); i++) {
565  typename View::VarType y(x[i].varimp());
566  if (!x[i].assigned() && bf(home,y,i)) {
567  Val mxi = m(home,x[i],i);
568  if (c(mxi,b_m)) {
569  b_i = i; b_m = mxi;
570  }
571  }
572  }
573  return b_i;
574  }
575 
576  template<class Choose, class Merit>
577  void
579  int* ties, int& n) {
580  // Consider x[s] as the so-far best view and record as tie
581  Val b = m(home,x[s],s);
582  int j=0; ties[j++]=s;
583  for (int i=s+1; i<x.size(); i++)
584  if (!x[i].assigned()) {
585  Val mxi = m(home,x[i],i);
586  if (c(mxi,b)) {
587  // Found a better one, reset all ties and record
588  j=0; ties[j++]=i; b=mxi;
589  } else if (mxi == b) {
590  // Found a tie, record
591  ties[j++]=i;
592  }
593  }
594  n=j;
595  // There must be at least one tie, of course!
596  assert(n > 0);
597  }
598 
599  template<class Choose, class Merit>
600  void
602  int* ties, int& n, BranchFilter bf) {
603  // Consider x[s] as the so-far best view and record as tie
604  Val b = m(home,x[s],s);
605  int j=0; ties[j++]=s;
606  for (int i=s+1; i<x.size(); i++) {
607  typename View::VarType y(x[i].varimp());
608  if (!x[i].assigned() && bf(home,y,i)) {
609  Val mxi = m(home,x[i],i);
610  if (c(mxi,b)) {
611  // Found a better one, reset all ties and record
612  j=0; ties[j++]=i; b=mxi;
613  } else if (mxi == b) {
614  // Found a tie, record
615  ties[j++]=i;
616  }
617  }
618  }
619  n=j;
620  // There must be at least one tie, of course!
621  assert(n > 0);
622  }
623 
624  template<class Choose, class Merit>
625  void
627  int* ties, int& n) {
628  // Keep first tie in place
629  Val b = m(home,x[ties[0]],ties[0]);
630  int j=1;
631  // Scan remaining ties
632  for (int i=1; i<n; i++) {
633  Val mxi = m(home,x[ties[i]],ties[i]);
634  if (c(mxi,b)) {
635  // Found a better one, reset all ties
636  b=mxi; j=0; ties[j++]=ties[i];
637  } else if (mxi == b) {
638  // Found a tie and record it
639  ties[j++]=ties[i];
640  }
641  }
642  n=j;
643  // There must be at least one tie, of course!
644  assert(n > 0);
645  }
646 
647  template<class Choose, class Merit>
648  int
650  int* ties, int n) {
651  int b_i = ties[0];
652  Val b_m = m(home,x[ties[0]],ties[0]);
653  for (int i=1; i<n; i++) {
654  Val mxi = m(home,x[ties[i]],ties[i]);
655  if (c(mxi,b_m)) {
656  b_i = ties[i]; b_m = mxi;
657  }
658  }
659  return b_i;
660  }
661 
662  template<class Choose, class Merit>
663  bool
665  return m.notice();
666  }
667 
668  template<class Choose, class Merit>
669  void
671  m.dispose(home);
672  }
673 
674 
675  template<class Choose, class Merit>
678  const VarBranch& vb)
679  : ViewSelChoose<Choose,Merit>(home,vb), tbl(vb.tbl()) {}
680 
681  template<class Choose, class Merit>
684  (Space& home, bool shared,
686  : ViewSelChoose<Choose,Merit>(home,shared,vs), tbl(vs.tbl) {}
687 
688  template<class Choose, class Merit>
689  void
691  int* ties, int& n) {
692  // Find the worst and best merit value
693  Val w = m(home,x[s],s);
694  Val b = w;
695  for (int i=s+1; i<x.size(); i++)
696  if (!x[i].assigned()) {
697  Val mxi = m(home,x[i],i);
698  if (c(mxi,b))
699  b=mxi;
700  else if (c(w,mxi))
701  w=mxi;
702  }
703  // Compute tie-break limit
704  double l = tbl(home,static_cast<double>(w),static_cast<double>(b));
705  // If the limit is not better than the worst merit, everything is a tie
706  if (!c(l,static_cast<double>(w))) {
707  int j=0;
708  for (int i=s; i<x.size(); i++)
709  if (!x[i].assigned())
710  ties[j++]=i;
711  n=j;
712  } else {
713  // The limit is not allowed to better than the best merit value
714  if (c(l,static_cast<double>(b)))
715  l = static_cast<double>(b);
716  // Record all ties that are not worse than the limit merit value
717  int j=0;
718  for (int i=s; i<x.size(); i++)
719  if (!x[i].assigned() && !c(l,static_cast<double>(m(home,x[i],i))))
720  ties[j++]=i;
721  n=j;
722  }
723  // There will be at least one tie (the best will qualify, of course)
724  assert(n > 0);
725  }
726 
727  template<class Choose, class Merit>
728  void
730  int* ties, int& n, BranchFilter bf) {
731  // Find the worst and best merit value
732  Val w = m(home,x[s],s);
733  Val b = w;
734  for (int i=s+1; i<x.size(); i++) {
735  typename View::VarType y(x[i].varimp());
736  if (!x[i].assigned() && bf(home,y,i)) {
737  Val mxi = m(home,x[i],i);
738  if (c(mxi,b))
739  b=mxi;
740  else if (c(w,mxi))
741  w=mxi;
742  }
743  }
744  // Compute tie-break limit
745  double l = tbl(home,static_cast<double>(w),static_cast<double>(b));
746  // If the limit is not better than the worst merit, everything is a tie
747  if (!c(l,static_cast<double>(w))) {
748  int j=0;
749  for (int i=s; i<x.size(); i++) {
750  typename View::VarType y(x[i].varimp());
751  if (!x[i].assigned() && bf(home,y,i))
752  ties[j++]=i;
753  }
754  n=j;
755  } else {
756  // The limit is not allowed to better than the best merit value
757  if (c(l,static_cast<double>(b)))
758  l = static_cast<double>(b);
759  // Record all ties that are not worse than the limit merit value
760  int j=0;
761  for (int i=s; i<x.size(); i++) {
762  typename View::VarType y(x[i].varimp());
763  if (!x[i].assigned() && bf(home,y,i) &&
764  !c(l,static_cast<double>(m(home,x[i],i))))
765  ties[j++]=i;
766  }
767  n=j;
768  }
769  // There will be at least one tie (the best will qualify, of course)
770  assert(n > 0);
771  }
772 
773  template<class Choose, class Merit>
774  void
776  int* ties, int& n) {
777  // Find the worst and best merit value
778  Val w = m(home,x[ties[0]],ties[0]);
779  Val b = w;
780  for (int i=1; i<n; i++) {
781  Val mxi = m(home,x[ties[i]],ties[i]);
782  if (c(mxi,b))
783  b=mxi;
784  else if (c(w,mxi))
785  w=mxi;
786  }
787  // Compute tie-break limit
788  double l = tbl(home,static_cast<double>(w),static_cast<double>(b));
789  // If the limit is not better than the worst merit, everything is a tie
790  // and no breaking is required
791  if (c(l,static_cast<double>(w))) {
792  // The limit is not allowed to better than the best merit value
793  if (c(l,static_cast<double>(b)))
794  l = static_cast<double>(b);
795  // Keep all ties that are not worse than the limit merit value
796  int j=0;
797  for (int i=0; i<n; i++)
798  if (!c(l,static_cast<double>(m(home,x[ties[i]],ties[i]))))
799  ties[j++]=ties[i];
800  n=j;
801  }
802  // There will be at least one tie (the best will qualify)
803  assert(n > 0);
804  }
805 
806 
807 
808  template<class Merit>
811  : ViewSelChoose<ChooseMin,Merit>(home,vb) {}
812 
813  template<class Merit>
816  ViewSelMin<Merit>& vs)
817  : ViewSelChoose<ChooseMin,Merit>(home,shared,vs) {}
818 
819  template<class Merit>
821  ViewSelMin<Merit>::copy(Space& home, bool shared) {
822  return new (home) ViewSelMin<Merit>(home,shared,*this);
823  }
824 
825 
826  template<class Merit>
829  : ViewSelChooseTbl<ChooseMin,Merit>(home,vb) {}
830 
831  template<class Merit>
835  : ViewSelChooseTbl<ChooseMin,Merit>(home,shared,vs) {}
836 
837  template<class Merit>
839  ViewSelMinTbl<Merit>::copy(Space& home, bool shared) {
840  return new (home) ViewSelMinTbl<Merit>(home,shared,*this);
841  }
842 
843 
844 
845  template<class Merit>
848  : ViewSelChoose<ChooseMax,Merit>(home,vb) {}
849 
850  template<class Merit>
853  ViewSelMax<Merit>& vs)
854  : ViewSelChoose<ChooseMax,Merit>(home,shared,vs) {}
855 
856  template<class Merit>
858  ViewSelMax<Merit>::copy(Space& home, bool shared) {
859  return new (home) ViewSelMax<Merit>(home,shared,*this);
860  }
861 
862 
863 
864  template<class Merit>
867  : ViewSelChooseTbl<ChooseMax,Merit>(home,vb) {}
868 
869  template<class Merit>
873  : ViewSelChooseTbl<ChooseMax,Merit>(home,shared,vs) {}
874 
875  template<class Merit>
877  ViewSelMaxTbl<Merit>::copy(Space& home, bool shared) {
878  return new (home) ViewSelMaxTbl<Merit>(home,shared,*this);
879  }
880 
881 
882 
883 }
884 
885 // STATISTICS: kernel-branch
Select view with largest merit.
ViewSelChoose< Choose, Merit >::Val Val
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)
Select ties from x starting at s.
virtual ViewSel< View > * copy(Space &home, bool shared)
Create copy during cloning.
ViewSelNone(Space &home, const VarBranch &vb)
Constructor for creation.
virtual ~ViewSel(void)
Unused destructor.
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
ViewSel< typename Merit::View >::BranchFilter BranchFilter
Rnd r
The random number generator used.
ViewSelRnd(Space &home, const VarBranch &vb)
Constructor for creation.
ViewSel(Space &home, const VarBranch &vb)
Constructor for creation.
bool operator()(Val a, Val b) const
Return true if a is better than b.
Abstract class for view selection.
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)=0
Select ties from x starting from s.
Choose view according to merit taking tie-break limit into account.
Choose views with larger merit values.
Merit m
The merit object used.
ViewSelChoose< Choose, Merit >::BranchFilter BranchFilter
Computation spaces.
Definition: core.hpp:1672
bool shared(const IntSet &, VX)
Definition: view-base.hpp:122
virtual void brk(Space &home, ViewArray< View > &x, int *ties, int &n)=0
Break ties in x and update to new ties.
virtual int select(Space &home, ViewArray< View > &x, int s)
Select a view from x starting at s and return its position.
Select the first unassigned view.
Select view with least merit.
ViewSelMinTbl(Space &home, const VarBranch &vb)
Constructor for initialization.
Gecode::FloatVal c(-8, 8)
virtual void dispose(Space &home)
Dispose view selection.
struct Gecode::@554::NNF::@60::@62 a
For atomic nodes.
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
virtual ViewSel< View > * copy(Space &home, bool shared)
Create copy during cloning.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
NNF * r
Right subtree.
Definition: bool-expr.cpp:246
ViewSelMaxTbl(Space &home, const VarBranch &vb)
Constructor for initialization.
Choose c
How to choose.
Select view with largest merit taking tie-break limit into account.
virtual void brk(Space &home, ViewArray< View > &x, int *ties, int &n)
Break ties in x and update to new ties.
BranchTraits< typename View::VarType >::Filter BranchFilter
The branch filter that corresponds to the view type.
Choose view according to merit.
ViewSelMax(Space &home, const VarBranch &vb)
Constructor for initialization.
virtual ViewSel< View > * copy(Space &home, bool shared)
Create copy during cloning.
Select view with least merit taking tie-break limit into account.
virtual int select(Space &home, ViewArray< View > &x, int s)=0
Select a view from x starting from s and return its position.
Choose views with smaller merit values.
virtual ViewSel< View > * copy(Space &home, bool shared)
Create copy during cloning.
View arrays.
Definition: array.hpp:234
Select a view randomly.
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
bool operator()(Val a, Val b) const
Return true if a is better than b.
Variable branching information.
Definition: branch-var.hpp:55
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
virtual void brk(Space &home, ViewArray< View > &x, int *ties, int &n)
Break ties in x and update to new ties.
virtual ViewSel< View > * copy(Space &home, bool shared)
Create copy during cloning.
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:47
virtual ViewSel< View > * copy(Space &home, bool shared)
Create copy during cloning.
#define forceinline
Definition: config.hpp:173
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
bool shared(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether views share same variable.
Definition: view.hpp:690
Merit::Val Val
Type of merit.
Gecode toplevel namespace
Random number generator.
Definition: rnd.hpp:46
ViewSel< typename Merit::View >::View View
virtual int select(Space &home, ViewArray< View > &x, int s)
Select a view from x starting from s and return its position.
ViewSelChoose< Choose, Merit >::View View
ViewSelChoose(Space &home, const VarBranch &vb)
Constructor for creation.
struct Gecode::@554::NNF::@60::@61 b
For binary nodes (and, or, eqv)
ViewSelMin(Space &home, const VarBranch &vb)
Constructor for initialization.
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1215
virtual ViewSel< View > * copy(Space &home, bool shared)=0
Create copy during cloning.
double tbl(const Gecode::Space &, double w, double b)
Test function for tie-break limit function.
Definition: branch.cpp:65
_View View
Define the view type.
Traits for branching.
virtual void dispose(Space &home)
Delete view selection.
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)
Select ties from x starting from s.
BranchTbl tbl
Tie-break limit function.
double(* BranchTbl)(const Space &home, double w, double b)
Tie-break limit function.
Definition: branch-var.hpp:49