Generated on Sat Feb 7 2015 02:01:27 for Gecode by doxygen 1.8.9.1
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: 2012-10-30 07:46:12 +0100 (Tue, 30 Oct 2012) $ by $Author: tack $
11  * $Revision: 13166 $
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 
92  static void* operator new(size_t s, Space& home);
95  static void operator delete(void* p, Space& home);
97  static void operator delete(void* p);
99  };
100 
102  template<class View>
103  class ViewSelNone : public ViewSel<View> {
104  typedef typename ViewSel<View>::BranchFilter BranchFilter;
105  public:
107 
108  ViewSelNone(Space& home, const VarBranch& vb);
111  ViewSelNone(Space& home, bool shared, ViewSelNone<View>& vs);
113 
115  virtual int select(Space& home, ViewArray<View>& x, int s);
118  virtual int select(Space& home, ViewArray<View>& x, int s,
119  BranchFilter bf);
121  virtual void ties(Space& home, ViewArray<View>& x, int s,
122  int* ties, int& n);
124  virtual void ties(Space& home, ViewArray<View>& x, int s,
125  int* ties, int& n,
126  BranchFilter bf);
128  virtual void brk(Space& home, ViewArray<View>& x,
129  int* ties, int& n);
131  virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
133 
135  virtual ViewSel<View>* copy(Space& home, bool shared);
138  };
139 
141  template<class View>
142  class ViewSelRnd : public ViewSel<View> {
143  typedef typename ViewSel<View>::BranchFilter BranchFilter;
144  protected:
147  public:
149 
150  ViewSelRnd(Space& home, const VarBranch& vb);
153  ViewSelRnd(Space& home, bool shared, ViewSelRnd<View>& vs);
155 
157  virtual int select(Space& home, ViewArray<View>& x, int s);
160  virtual int select(Space& home, ViewArray<View>& x, int s,
161  BranchFilter bf);
163  virtual void ties(Space& home, ViewArray<View>& x, int s,
164  int* ties, int& n);
166  virtual void ties(Space& home, ViewArray<View>& x, int s,
167  int* ties, int& n, BranchFilter bf);
169  virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
171  virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
173 
175  virtual ViewSel<View>* copy(Space& home, bool shared);
178  };
179 
181  class ChooseMin {
182  public:
184  template<class Val>
185  bool operator ()(Val a, Val b) const;
186  };
187 
189  class ChooseMax {
190  public:
192  template<class Val>
193  bool operator ()(Val a, Val b) const;
194  };
195 
197  template<class Choose, class Merit>
198  class ViewSelChoose : public ViewSel<typename Merit::View> {
199  protected:
203  typedef typename Merit::Val Val;
205  Choose c;
207  Merit m;
208  public:
210 
211  ViewSelChoose(Space& home, const VarBranch& vb);
216 
218  virtual int select(Space& home, ViewArray<View>& x, int s);
221  virtual int select(Space& home, ViewArray<View>& x, int s,
222  BranchFilter bf);
224  virtual void ties(Space& home, ViewArray<View>& x, int s,
225  int* ties, int& n);
227  virtual void ties(Space& home, ViewArray<View>& x, int s,
228  int* ties, int& n, BranchFilter bf);
230  virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
232  virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
234 
236  virtual bool notice(void) const;
239  virtual void dispose(Space& home);
241  };
242 
243 
245  template<class Choose, class Merit>
246  class ViewSelChooseTbl : public ViewSelChoose<Choose,Merit> {
247  protected:
255  public:
257 
258  ViewSelChooseTbl(Space& home, const VarBranch& vb);
261  ViewSelChooseTbl(Space& home, bool shared,
264 
266  virtual void ties(Space& home, ViewArray<View>& x, int s,
268  int* ties, int& n);
270  virtual void ties(Space& home, ViewArray<View>& x, int s,
271  int* ties, int& n, BranchFilter bf);
273  virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
275  };
276 
278  template<class Merit>
279  class ViewSelMin : public ViewSelChoose<ChooseMin,Merit> {
280  typedef typename ViewSelChoose<ChooseMin,Merit>::View View;
281  typedef typename ViewSelChoose<ChooseMin,Merit>::BranchFilter BranchFilter;
282  public:
284 
285  ViewSelMin(Space& home, const VarBranch& vb);
288  ViewSelMin(Space& home, bool shared, ViewSelMin<Merit>& vs);
290 
292  virtual ViewSel<View>* copy(Space& home, bool shared);
295  };
296 
298  template<class Merit>
299  class ViewSelMinTbl : public ViewSelChooseTbl<ChooseMin,Merit> {
300  typedef typename ViewSelChooseTbl<ChooseMin,Merit>::View View;
301  typedef typename ViewSelChooseTbl<ChooseMin,Merit>::BranchFilter BranchFilter;
302  public:
304 
305  ViewSelMinTbl(Space& home, const VarBranch& vb);
310 
312  virtual ViewSel<View>* copy(Space& home, bool shared);
315  };
316 
318  template<class Merit>
319  class ViewSelMax : public ViewSelChoose<ChooseMax,Merit> {
320  typedef typename ViewSelChoose<ChooseMax,Merit>::View View;
321  typedef typename ViewSelChoose<ChooseMax,Merit>::BranchFilter BranchFilter;
322  public:
324 
325  ViewSelMax(Space& home, const VarBranch& vb);
328  ViewSelMax(Space& home, bool shared, ViewSelMax<Merit>& vs);
330 
332  virtual ViewSel<View>* copy(Space& home, bool shared);
335  };
336 
338  template<class Merit>
339  class ViewSelMaxTbl : public ViewSelChooseTbl<ChooseMax,Merit> {
340  typedef typename ViewSelChooseTbl<ChooseMax,Merit>::View View;
341  typedef typename ViewSelChooseTbl<ChooseMax,Merit>::BranchFilter BranchFilter;
342  public:
344 
345  ViewSelMaxTbl(Space& home, const VarBranch& vb);
350 
352  virtual ViewSel<View>* copy(Space& home, bool shared);
355  };
357 
358 
359  template<class View>
362  template<class View>
365  template<class View>
366  bool
367  ViewSel<View>::notice(void) const {
368  return false;
369  }
370  template<class View>
371  void
373  template<class View>
374  forceinline void
375  ViewSel<View>::operator delete(void*) {}
376  template<class View>
377  forceinline void
378  ViewSel<View>::operator delete(void*, Space&) {}
379  template<class View>
380  forceinline void*
381  ViewSel<View>::operator new(size_t s, Space& home) {
382  return home.ralloc(s);
383  }
384 
385 
386  template<class View>
389  : ViewSel<View>(home,vb) {}
390  template<class View>
393  ViewSelNone<View>& vs)
394  : ViewSel<View>(home,shared,vs) {}
395  template<class View>
396  int
398  return s;
399  }
400  template<class View>
401  int
403  return s;
404  }
405  template<class View>
406  void
408  int* ties, int& n) {
409  int j=0; ties[j++]=s;
410  for (int i=s+1; i<x.size(); i++)
411  if (!x[i].assigned())
412  ties[j++]=i;
413  n=j;
414  assert(n > 0);
415  }
416  template<class View>
417  void
419  int* ties, int& n, BranchFilter bf) {
420  int j=0; ties[j++]=s;
421  for (int i=s+1; i<x.size(); i++) {
422  typename View::VarType y(x[i].varimp());
423  if (!x[i].assigned() && bf(home,y,i))
424  ties[j++]=i;
425  }
426  n=j;
427  assert(n > 0);
428  }
429  template<class View>
430  void
432  // Nothing needs to be done
433  }
434  template<class View>
435  int
437  return ties[0];
438  }
439  template<class View>
442  return new (home) ViewSelNone<View>(home,shared,*this);
443  }
444 
445 
446  template<class View>
449  : ViewSel<View>(home,vb), r(vb.rnd()) {}
450  template<class View>
453  : ViewSel<View>(home,shared,vs), r(vs.r) {}
454  template<class View>
455  int
457  unsigned int n=1;
458  int j=s;
459  for (int i=s+1; i<x.size(); i++)
460  if (!x[i].assigned()) {
461  n++;
462  if (r(n) == 0U)
463  j=i;
464  }
465  return j;
466  }
467  template<class View>
469  BranchFilter bf) {
470  unsigned int n=1;
471  int j=s;
472  for (int i=s+1; i<x.size(); i++) {
473  typename View::VarType y(x[i].varimp());
474  if (!x[i].assigned() && bf(home,y,i)) {
475  n++;
476  if (r(n) == 0U)
477  j=i;
478  }
479  }
480  return j;
481  }
482  template<class View>
483  void
485  int* ties, int& n) {
486  n=1; ties[0] = select(home,x,s);
487  }
488  template<class View>
489  void
491  int* ties, int& n, BranchFilter bf) {
492  n=1; ties[0] = select(home,x,s,bf);
493  }
494  template<class View>
495  void
497  ties[0] = ties[static_cast<int>(r(static_cast<unsigned int>(n)))];
498  n=1;
499  }
500  template<class View>
501  int
503  return ties[static_cast<int>(r(static_cast<unsigned int>(n)))];
504  }
505  template<class View>
508  return new (home) ViewSelRnd<View>(home,shared,*this);
509  }
510 
511 
512  template<class Val>
513  forceinline bool
514  ChooseMin::operator ()(Val a, Val b) const {
515  return a < b;
516  }
517  template<class Val>
518  forceinline bool
519  ChooseMax::operator ()(Val a, Val b) const {
520  return a > b;
521  }
522 
523 
524  template<class Choose, class Merit>
527  : ViewSel<View>(home,vb), m(home,vb) {}
528 
529  template<class Choose, class Merit>
533  : ViewSel<View>(home,shared,vs), m(home,shared,vs.m) {}
534 
535  template<class Choose, class Merit>
536  int
538  // Consider x[s] as the so-far best view
539  int b_i = s;
540  Val b_m = m(home,x[s],s);
541  // Scan all non-assigned views from s+1 onwards
542  for (int i=s+1; i<x.size(); i++)
543  if (!x[i].assigned()) {
544  Val mxi = m(home,x[i],i);
545  if (c(mxi,b_m)) {
546  b_i = i; b_m = mxi;
547  }
548  }
549  return b_i;
550  }
551 
552  template<class Choose, class Merit>
553  int
555  BranchFilter bf) {
556  // Consider x[s] as the so-far best view
557  int b_i = s;
558  Val b_m = m(home,x[s],s);
559  // Scan all assigned views from s+1 onwards
560  for (int i=s+1; i<x.size(); i++) {
561  typename View::VarType y(x[i].varimp());
562  if (!x[i].assigned() && bf(home,y,i)) {
563  Val mxi = m(home,x[i],i);
564  if (c(mxi,b_m)) {
565  b_i = i; b_m = mxi;
566  }
567  }
568  }
569  return b_i;
570  }
571 
572  template<class Choose, class Merit>
573  void
575  int* ties, int& n) {
576  // Consider x[s] as the so-far best view and record as tie
577  Val b = m(home,x[s],s);
578  int j=0; ties[j++]=s;
579  for (int i=s+1; i<x.size(); i++)
580  if (!x[i].assigned()) {
581  Val mxi = m(home,x[i],i);
582  if (c(mxi,b)) {
583  // Found a better one, reset all ties and record
584  j=0; ties[j++]=i; b=mxi;
585  } else if (mxi == b) {
586  // Found a tie, record
587  ties[j++]=i;
588  }
589  }
590  n=j;
591  // There must be at least one tie, of course!
592  assert(n > 0);
593  }
594 
595  template<class Choose, class Merit>
596  void
598  int* ties, int& n, BranchFilter bf) {
599  // Consider x[s] as the so-far best view and record as tie
600  Val b = m(home,x[s],s);
601  int j=0; ties[j++]=s;
602  for (int i=s+1; i<x.size(); i++) {
603  typename View::VarType y(x[i].varimp());
604  if (!x[i].assigned() && bf(home,y,i)) {
605  Val mxi = m(home,x[i],i);
606  if (c(mxi,b)) {
607  // Found a better one, reset all ties and record
608  j=0; ties[j++]=i; b=mxi;
609  } else if (mxi == b) {
610  // Found a tie, record
611  ties[j++]=i;
612  }
613  }
614  }
615  n=j;
616  // There must be at least one tie, of course!
617  assert(n > 0);
618  }
619 
620  template<class Choose, class Merit>
621  void
623  int* ties, int& n) {
624  // Keep first tie in place
625  Val b = m(home,x[ties[0]],ties[0]);
626  int j=1;
627  // Scan remaining ties
628  for (int i=1; i<n; i++) {
629  Val mxi = m(home,x[ties[i]],ties[i]);
630  if (c(mxi,b)) {
631  // Found a better one, reset all ties
632  b=mxi; j=0; ties[j++]=ties[i];
633  } else if (mxi == b) {
634  // Found a tie and record it
635  ties[j++]=ties[i];
636  }
637  }
638  n=j;
639  // There must be at least one tie, of course!
640  assert(n > 0);
641  }
642 
643  template<class Choose, class Merit>
644  int
646  int* ties, int n) {
647  int b_i = ties[0];
648  Val b_m = m(home,x[ties[0]],ties[0]);
649  for (int i=1; i<n; i++) {
650  Val mxi = m(home,x[ties[i]],ties[i]);
651  if (c(mxi,b_m)) {
652  b_i = ties[i]; b_m = mxi;
653  }
654  }
655  return b_i;
656  }
657 
658  template<class Choose, class Merit>
659  bool
661  return m.notice();
662  }
663 
664  template<class Choose, class Merit>
665  void
667  m.dispose(home);
668  }
669 
670 
671  template<class Choose, class Merit>
674  const VarBranch& vb)
675  : ViewSelChoose<Choose,Merit>(home,vb), tbl(vb.tbl()) {}
676 
677  template<class Choose, class Merit>
680  (Space& home, bool shared,
682  : ViewSelChoose<Choose,Merit>(home,shared,vs), tbl(vs.tbl) {}
683 
684  template<class Choose, class Merit>
685  void
687  int* ties, int& n) {
688  // Find the worst and best merit value
689  Val w = m(home,x[s],s);
690  Val b = w;
691  for (int i=s+1; i<x.size(); i++)
692  if (!x[i].assigned()) {
693  Val mxi = m(home,x[i],i);
694  if (c(mxi,b))
695  b=mxi;
696  else if (c(w,mxi))
697  w=mxi;
698  }
699  // Compute tie-break limit
700  double l = tbl(home,static_cast<double>(w),static_cast<double>(b));
701  // If the limit is not better than the worst merit, everything is a tie
702  if (!c(l,static_cast<double>(w))) {
703  int j=0;
704  for (int i=s; i<x.size(); i++)
705  if (!x[i].assigned())
706  ties[j++]=i;
707  n=j;
708  } else {
709  // The limit is not allowed to better than the best merit value
710  if (c(l,static_cast<double>(b)))
711  l = static_cast<double>(b);
712  // Record all ties that are not worse than the limit merit value
713  int j=0;
714  for (int i=s; i<x.size(); i++)
715  if (!x[i].assigned() && !c(l,static_cast<double>(m(home,x[i],i))))
716  ties[j++]=i;
717  n=j;
718  }
719  // There will be at least one tie (the best will qualify, of course)
720  assert(n > 0);
721  }
722 
723  template<class Choose, class Merit>
724  void
726  int* ties, int& n, BranchFilter bf) {
727  // Find the worst and best merit value
728  Val w = m(home,x[s],s);
729  Val b = w;
730  for (int i=s+1; i<x.size(); i++) {
731  typename View::VarType y(x[i].varimp());
732  if (!x[i].assigned() && bf(home,y,i)) {
733  Val mxi = m(home,x[i],i);
734  if (c(mxi,b))
735  b=mxi;
736  else if (c(w,mxi))
737  w=mxi;
738  }
739  }
740  // Compute tie-break limit
741  double l = tbl(home,static_cast<double>(w),static_cast<double>(b));
742  // If the limit is not better than the worst merit, everything is a tie
743  if (!c(l,static_cast<double>(w))) {
744  int j=0;
745  for (int i=s; i<x.size(); i++) {
746  typename View::VarType y(x[i].varimp());
747  if (!x[i].assigned() && bf(home,y,i))
748  ties[j++]=i;
749  }
750  n=j;
751  } else {
752  // The limit is not allowed to better than the best merit value
753  if (c(l,static_cast<double>(b)))
754  l = static_cast<double>(b);
755  // Record all ties that are not worse than the limit merit value
756  int j=0;
757  for (int i=s; i<x.size(); i++) {
758  typename View::VarType y(x[i].varimp());
759  if (!x[i].assigned() && bf(home,y,i) &&
760  !c(l,static_cast<double>(m(home,x[i],i))))
761  ties[j++]=i;
762  }
763  n=j;
764  }
765  // There will be at least one tie (the best will qualify, of course)
766  assert(n > 0);
767  }
768 
769  template<class Choose, class Merit>
770  void
772  int* ties, int& n) {
773  // Find the worst and best merit value
774  Val w = m(home,x[ties[0]],ties[0]);
775  Val b = w;
776  for (int i=1; i<n; i++) {
777  Val mxi = m(home,x[ties[i]],ties[i]);
778  if (c(mxi,b))
779  b=mxi;
780  else if (c(w,mxi))
781  w=mxi;
782  }
783  // Compute tie-break limit
784  double l = tbl(home,static_cast<double>(w),static_cast<double>(b));
785  // If the limit is not better than the worst merit, everything is a tie
786  // and no breaking is required
787  if (c(l,static_cast<double>(w))) {
788  // The limit is not allowed to better than the best merit value
789  if (c(l,static_cast<double>(b)))
790  l = static_cast<double>(b);
791  // Keep all ties that are not worse than the limit merit value
792  int j=0;
793  for (int i=0; i<n; i++)
794  if (!c(l,static_cast<double>(m(home,x[ties[i]],ties[i]))))
795  ties[j++]=ties[i];
796  n=j;
797  }
798  // There will be at least one tie (the best will qualify)
799  assert(n > 0);
800  }
801 
802 
803 
804  template<class Merit>
807  : ViewSelChoose<ChooseMin,Merit>(home,vb) {}
808 
809  template<class Merit>
812  ViewSelMin<Merit>& vs)
813  : ViewSelChoose<ChooseMin,Merit>(home,shared,vs) {}
814 
815  template<class Merit>
817  ViewSelMin<Merit>::copy(Space& home, bool shared) {
818  return new (home) ViewSelMin<Merit>(home,shared,*this);
819  }
820 
821 
822  template<class Merit>
825  : ViewSelChooseTbl<ChooseMin,Merit>(home,vb) {}
826 
827  template<class Merit>
831  : ViewSelChooseTbl<ChooseMin,Merit>(home,shared,vs) {}
832 
833  template<class Merit>
835  ViewSelMinTbl<Merit>::copy(Space& home, bool shared) {
836  return new (home) ViewSelMinTbl<Merit>(home,shared,*this);
837  }
838 
839 
840 
841  template<class Merit>
844  : ViewSelChoose<ChooseMax,Merit>(home,vb) {}
845 
846  template<class Merit>
849  ViewSelMax<Merit>& vs)
850  : ViewSelChoose<ChooseMax,Merit>(home,shared,vs) {}
851 
852  template<class Merit>
854  ViewSelMax<Merit>::copy(Space& home, bool shared) {
855  return new (home) ViewSelMax<Merit>(home,shared,*this);
856  }
857 
858 
859 
860  template<class Merit>
863  : ViewSelChooseTbl<ChooseMax,Merit>(home,vb) {}
864 
865  template<class Merit>
869  : ViewSelChooseTbl<ChooseMax,Merit>(home,shared,vs) {}
870 
871  template<class Merit>
873  ViewSelMaxTbl<Merit>::copy(Space& home, bool shared) {
874  return new (home) ViewSelMaxTbl<Merit>(home,shared,*this);
875  }
876 
877 
878 
879 }
880 
881 // STATISTICS: kernel-branch
Select view with largest merit.
virtual void brk(Space &home, ViewArray< View > &x, int *ties, int &n)
Break ties in x and update to new ties.
ViewSelChoose< Choose, Merit >::Val Val
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
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.
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.
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.
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)
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:1362
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.
bool operator()(Val a, Val b) const
Return true if a is better than b.
Select view with least merit.
ViewSelMinTbl(Space &home, const VarBranch &vb)
Constructor for initialization.
bool operator()(Val a, Val b) const
Return true if a is better than b.
Gecode::FloatVal c(-8, 8)
virtual void dispose(Space &home)
Dispose view selection.
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.
virtual void brk(Space &home, ViewArray< View > &x, int *ties, int &n)
Break ties in x and update to new ties.
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
ViewSelChooseTbl(Space &home, const VarBranch &vb)
Constructor for initialization.
Select a view randomly.
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)
Select ties from x starting from s.
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 bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
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:132
virtual int select(Space &home, ViewArray< View > &x, int s)
Select a view from x starting from s and return its position.
bool shared(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether views share same variable.
Definition: view.hpp:662
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1215
Merit::Val Val
Type of merit.
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
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.
ViewSelMin(Space &home, const VarBranch &vb)
Constructor for initialization.
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.
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
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