Generated on Thu Jul 25 2019 00:00:00 for Gecode by doxygen 1.8.15
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: 2017-04-01 20:27:10 +0200 (Sat, 01 Apr 2017) $ by $Author: schulte $
11  * $Revision: 15623 $
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;
53  typedef typename View::VarType Var;
55 
56  ViewSel(Space& home, const VarBranch<Var>& 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  BrancherFilter<View>& f) = 0;
69  virtual int select(Space& home, ViewArray<View>& x, int s,
72  virtual void ties(Space& home, ViewArray<View>& x, int s,
73  int* ties, int& n) = 0;
75  virtual void ties(Space& home, ViewArray<View>& x, int s,
76  int* ties, int& n,
77  BrancherFilter<View>& f) = 0;
79  virtual void ties(Space& home, ViewArray<View>& x, int s,
80  int* ties, int& n,
83  virtual void brk(Space& home, ViewArray<View>& x,
84  int* ties, int& n) = 0;
86  virtual int select(Space& home, ViewArray<View>& x,
87  int* ties, int n) = 0;
89 
91  virtual ViewSel<View>* copy(Space& home, bool shared) = 0;
94  virtual bool notice(void) const;
96  virtual void dispose(Space& home);
98  virtual ~ViewSel(void);
100 
102  static void* operator new(size_t s, Space& home);
105  static void operator delete(void* p, Space& home);
107  static void operator delete(void* p);
109  };
110 
112  template<class View>
113  class ViewSelNone : public ViewSel<View> {
114  protected:
115  typedef typename ViewSel<View>::Var Var;
116  public:
118 
119  ViewSelNone(Space& home, const VarBranch<Var>& vb);
122  ViewSelNone(Space& home, bool shared, ViewSelNone<View>& vs);
124 
126  virtual int select(Space& home, ViewArray<View>& x, int s);
129  virtual int select(Space& home, ViewArray<View>& x, int s,
132  virtual void ties(Space& home, ViewArray<View>& x, int s,
133  int* ties, int& n);
135  virtual void ties(Space& home, ViewArray<View>& x, int s,
136  int* ties, int& n,
139  virtual void brk(Space& home, ViewArray<View>& x,
140  int* ties, int& n);
142  virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
144 
146  virtual ViewSel<View>* copy(Space& home, bool shared);
149  };
150 
152  template<class View>
153  class ViewSelRnd : public ViewSel<View> {
154  protected:
155  typedef typename ViewSel<View>::Var Var;
158  public:
160 
161  ViewSelRnd(Space& home, const VarBranch<Var>& vb);
164  ViewSelRnd(Space& home, bool shared, ViewSelRnd<View>& vs);
166 
168  virtual int select(Space& home, ViewArray<View>& x, int s);
171  virtual int select(Space& home, ViewArray<View>& x, int s,
174  virtual void ties(Space& home, ViewArray<View>& x, int s,
175  int* ties, int& n);
177  virtual void ties(Space& home, ViewArray<View>& x, int s,
178  int* ties, int& n,
181  virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
183  virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
185 
187  virtual ViewSel<View>* copy(Space& home, bool shared);
190  };
191 
193  class ChooseMin {
194  public:
196  template<class Val>
197  bool operator ()(Val a, Val b) const;
198  };
199 
201  class ChooseMax {
202  public:
204  template<class Val>
205  bool operator ()(Val a, Val b) const;
206  };
207 
209  template<class Choose, class Merit>
210  class ViewSelChoose : public ViewSel<typename Merit::View> {
211  protected:
215  typedef typename Merit::Val Val;
217  Choose c;
219  Merit m;
220  public:
222 
223  ViewSelChoose(Space& home, const VarBranch<Var>& vb);
228 
230  virtual int select(Space& home, ViewArray<View>& x, int s);
233  virtual int select(Space& home, ViewArray<View>& x, int s,
236  virtual void ties(Space& home, ViewArray<View>& x, int s,
237  int* ties, int& n);
239  virtual void ties(Space& home, ViewArray<View>& x, int s,
240  int* ties, int& n,
243  virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
245  virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
247 
249  virtual bool notice(void) const;
252  virtual void dispose(Space& home);
254  };
255 
256 
258  template<class Choose, class Merit>
259  class ViewSelChooseTbl : public ViewSelChoose<Choose,Merit> {
260  protected:
268  public:
270 
271  ViewSelChooseTbl(Space& home, const VarBranch<Var>& vb);
274  ViewSelChooseTbl(Space& home, bool shared,
277 
279  virtual void ties(Space& home, ViewArray<View>& x, int s,
281  int* ties, int& n);
283  virtual void ties(Space& home, ViewArray<View>& x, int s,
284  int* ties, int& n,
287  virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
289 
291  virtual bool notice(void) const;
294  virtual void dispose(Space& home);
296  };
297 
299  template<class Merit>
300  class ViewSelMin : public ViewSelChoose<ChooseMin,Merit> {
301  typedef typename ViewSelChoose<ChooseMin,Merit>::View View;
302  typedef typename ViewSelChoose<ChooseMin,Merit>::Var Var;
303  public:
305 
306  ViewSelMin(Space& home, const VarBranch<Var>& vb);
309  ViewSelMin(Space& home, bool shared, ViewSelMin<Merit>& vs);
311 
313  virtual ViewSel<View>* copy(Space& home, bool shared);
316  };
317 
319  template<class Merit>
320  class ViewSelMinTbl : public ViewSelChooseTbl<ChooseMin,Merit> {
321  typedef typename ViewSelChooseTbl<ChooseMin,Merit>::View View;
322  typedef typename ViewSelChooseTbl<ChooseMin,Merit>::Var Var;
323  public:
325 
326  ViewSelMinTbl(Space& home, const VarBranch<Var>& vb);
331 
333  virtual ViewSel<View>* copy(Space& home, bool shared);
336  };
337 
339  template<class Merit>
340  class ViewSelMax : public ViewSelChoose<ChooseMax,Merit> {
341  typedef typename ViewSelChoose<ChooseMax,Merit>::View View;
342  typedef typename ViewSelChoose<ChooseMax,Merit>::Var Var;
343  public:
345 
346  ViewSelMax(Space& home, const VarBranch<Var>& vb);
349  ViewSelMax(Space& home, bool shared, ViewSelMax<Merit>& vs);
351 
353  virtual ViewSel<View>* copy(Space& home, bool shared);
356  };
357 
359  template<class Merit>
360  class ViewSelMaxTbl : public ViewSelChooseTbl<ChooseMax,Merit> {
361  typedef typename ViewSelChooseTbl<ChooseMax,Merit>::View View;
362  typedef typename ViewSelChooseTbl<ChooseMax,Merit>::Var Var;
363  public:
365 
366  ViewSelMaxTbl(Space& home, const VarBranch<Var>& vb);
371 
373  virtual ViewSel<View>* copy(Space& home, bool shared);
376  };
378 
379 
380  template<class View>
383  template<class View>
386  template<class View>
387  int
390  GECODE_NEVER;
391  return 0;
392  }
393  template<class View>
394  void
396  int*, int&,
398  GECODE_NEVER;
399  }
400  template<class View>
401  bool
402  ViewSel<View>::notice(void) const {
403  return false;
404  }
405  template<class View>
406  void
408  template<class View>
410  template<class View>
411  forceinline void
412  ViewSel<View>::operator delete(void*) {}
413  template<class View>
414  forceinline void
415  ViewSel<View>::operator delete(void*, Space&) {}
416  template<class View>
417  forceinline void*
418  ViewSel<View>::operator new(size_t s, Space& home) {
419  return home.ralloc(s);
420  }
421 
422 
423 
424  template<class View>
427  : ViewSel<View>(home,vb) {}
428  template<class View>
431  ViewSelNone<View>& vs)
432  : ViewSel<View>(home,shared,vs) {}
433  template<class View>
434  int
436  return s;
437  }
438  template<class View>
439  int
442  return s;
443  }
444  template<class View>
445  void
447  int* ties, int& n) {
448  int j=0; ties[j++]=s;
449  for (int i=s+1; i<x.size(); i++)
450  if (!x[i].assigned())
451  ties[j++]=i;
452  n=j;
453  assert(n > 0);
454  }
455  template<class View>
456  void
458  int* ties, int& n,
460  int j=0; ties[j++]=s;
461  for (int i=s+1; i<x.size(); i++)
462  if (!x[i].assigned() && f(home,x[i],i))
463  ties[j++]=i;
464  n=j;
465  assert(n > 0);
466  }
467  template<class View>
468  void
470  // Nothing needs to be done
471  }
472  template<class View>
473  int
475  return ties[0];
476  }
477  template<class View>
480  return new (home) ViewSelNone<View>(home,shared,*this);
481  }
482 
483 
484  template<class View>
487  : ViewSel<View>(home,vb), r(vb.rnd()) {}
488  template<class View>
491  : ViewSel<View>(home,shared,vs), r(vs.r) {}
492  template<class View>
493  int
495  unsigned int n=1;
496  int j=s;
497  for (int i=s+1; i<x.size(); i++)
498  if (!x[i].assigned()) {
499  n++;
500  if (r(n) == 0U)
501  j=i;
502  }
503  return j;
504  }
505  template<class View>
506  int
509  unsigned int n=1;
510  int j=s;
511  for (int i=s+1; i<x.size(); i++)
512  if (!x[i].assigned() && f(home,x[i],i)) {
513  n++;
514  if (r(n) == 0U)
515  j=i;
516  }
517  return j;
518  }
519  template<class View>
520  void
522  int* ties, int& n) {
523  n=1; ties[0] = select(home,x,s);
524  }
525  template<class View>
526  void
528  int* ties, int& n,
530  n=1; ties[0] = select(home,x,s);
531  }
532  template<class View>
533  void
535  ties[0] = ties[static_cast<int>(r(static_cast<unsigned int>(n)))];
536  n=1;
537  }
538  template<class View>
539  int
541  return ties[static_cast<int>(r(static_cast<unsigned int>(n)))];
542  }
543  template<class View>
546  return new (home) ViewSelRnd<View>(home,shared,*this);
547  }
548 
549 
550  template<class Val>
551  forceinline bool
552  ChooseMin::operator ()(Val a, Val b) const {
553  return a < b;
554  }
555  template<class Val>
556  forceinline bool
557  ChooseMax::operator ()(Val a, Val b) const {
558  return a > b;
559  }
560 
561 
562  template<class Choose, class Merit>
565  : ViewSel<View>(home,vb), m(home,vb) {}
566 
567  template<class Choose, class Merit>
571  : ViewSel<View>(home,shared,vs), m(home,shared,vs.m) {}
572 
573  template<class Choose, class Merit>
574  int
576  // Consider x[s] as the so-far best view
577  int b_i = s;
578  Val b_m = m(home,x[s],s);
579  // Scan all non-assigned views from s+1 onwards
580  for (int i=s+1; i<x.size(); i++)
581  if (!x[i].assigned()) {
582  Val mxi = m(home,x[i],i);
583  if (c(mxi,b_m)) {
584  b_i = i; b_m = mxi;
585  }
586  }
587  return b_i;
588  }
589 
590  template<class Choose, class Merit>
591  int
594  // Consider x[s] as the so-far best view
595  int b_i = s;
596  Val b_m = m(home,x[s],s);
597  // Scan all non-assigned views from s+1 onwards
598  for (int i=s+1; i<x.size(); i++)
599  if (!x[i].assigned() && f(home,x[i],i)) {
600  Val mxi = m(home,x[i],i);
601  if (c(mxi,b_m)) {
602  b_i = i; b_m = mxi;
603  }
604  }
605  return b_i;
606  }
607 
608  template<class Choose, class Merit>
609  void
611  int* ties, int& n) {
612  // Consider x[s] as the so-far best view and record as tie
613  Val b = m(home,x[s],s);
614  int j=0; ties[j++]=s;
615  for (int i=s+1; i<x.size(); i++)
616  if (!x[i].assigned()) {
617  Val mxi = m(home,x[i],i);
618  if (c(mxi,b)) {
619  // Found a better one, reset all ties and record
620  j=0; ties[j++]=i; b=mxi;
621  } else if (mxi == b) {
622  // Found a tie, record
623  ties[j++]=i;
624  }
625  }
626  n=j;
627  // There must be at least one tie, of course!
628  assert(n > 0);
629  }
630 
631  template<class Choose, class Merit>
632  void
634  int* ties, int& n,
636  // Consider x[s] as the so-far best view and record as tie
637  Val b = m(home,x[s],s);
638  int j=0; ties[j++]=s;
639  for (int i=s+1; i<x.size(); i++)
640  if (!x[i].assigned() && f(home,x[i],i)) {
641  Val mxi = m(home,x[i],i);
642  if (c(mxi,b)) {
643  // Found a better one, reset all ties and record
644  j=0; ties[j++]=i; b=mxi;
645  } else if (mxi == b) {
646  // Found a tie, record
647  ties[j++]=i;
648  }
649  }
650  n=j;
651  // There must be at least one tie, of course!
652  assert(n > 0);
653  }
654 
655  template<class Choose, class Merit>
656  void
658  int* ties, int& n) {
659  // Keep first tie in place
660  Val b = m(home,x[ties[0]],ties[0]);
661  int j=1;
662  // Scan remaining ties
663  for (int i=1; i<n; i++) {
664  Val mxi = m(home,x[ties[i]],ties[i]);
665  if (c(mxi,b)) {
666  // Found a better one, reset all ties
667  b=mxi; j=0; ties[j++]=ties[i];
668  } else if (mxi == b) {
669  // Found a tie and record it
670  ties[j++]=ties[i];
671  }
672  }
673  n=j;
674  // There must be at least one tie, of course!
675  assert(n > 0);
676  }
677 
678  template<class Choose, class Merit>
679  int
681  int* ties, int n) {
682  int b_i = ties[0];
683  Val b_m = m(home,x[ties[0]],ties[0]);
684  for (int i=1; i<n; i++) {
685  Val mxi = m(home,x[ties[i]],ties[i]);
686  if (c(mxi,b_m)) {
687  b_i = ties[i]; b_m = mxi;
688  }
689  }
690  return b_i;
691  }
692 
693  template<class Choose, class Merit>
694  bool
696  return m.notice();
697  }
698 
699  template<class Choose, class Merit>
700  void
702  m.dispose(home);
703  }
704 
705 
706  template<class Choose, class Merit>
709  const VarBranch<Var>& vb)
710  : ViewSelChoose<Choose,Merit>(home,vb), tbl(vb.tbl()) {
711  if (!tbl())
712  throw InvalidFunction("ViewSelChooseTbl::ViewSelChooseTbl");
713  }
714 
715  template<class Choose, class Merit>
718  (Space& home, bool shared,
721  tbl.update(home,shared,vs.tbl);
722  }
723 
724  template<class Choose, class Merit>
725  void
727  int* ties, int& n) {
728  // Find the worst and best merit value
729  Val w = m(home,x[s],s);
730  Val b = w;
731  for (int i=s+1; i<x.size(); i++)
732  if (!x[i].assigned()) {
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  // 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  if (!x[i].assigned())
747  ties[j++]=i;
748  n=j;
749  } else {
750  // The limit is not allowed to better than the best merit value
751  if (c(l,static_cast<double>(b)))
752  l = static_cast<double>(b);
753  // Record all ties that are not worse than the limit merit value
754  int j=0;
755  for (int i=s; i<x.size(); i++)
756  if (!x[i].assigned() && !c(l,static_cast<double>(m(home,x[i],i))))
757  ties[j++]=i;
758  n=j;
759  }
760  // There will be at least one tie (the best will qualify, of course)
761  assert(n > 0);
762  }
763 
764  template<class Choose, class Merit>
765  void
767  int* ties, int& n,
769  // Find the worst and best merit value
770  assert(f(home,x[s],s));
771  Val w = m(home,x[s],s);
772  Val b = w;
773  for (int i=s+1; i<x.size(); i++)
774  if (!x[i].assigned() && f(home,x[i],i)) {
775  Val mxi = m(home,x[i],i);
776  if (c(mxi,b))
777  b=mxi;
778  else if (c(w,mxi))
779  w=mxi;
780  }
781  // Compute tie-break limit
783  double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
784  // If the limit is not better than the worst merit, everything is a tie
785  if (!c(l,static_cast<double>(w))) {
786  int j=0;
787  for (int i=s; i<x.size(); i++)
788  if (!x[i].assigned() && f(home,x[i],i))
789  ties[j++]=i;
790  n=j;
791  } else {
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  // Record all ties that are not worse than the limit merit value
796  int j=0;
797  for (int i=s; i<x.size(); i++)
798  if (!x[i].assigned() && f(home,x[i],i) &&
799  !c(l,static_cast<double>(m(home,x[i],i))))
800  ties[j++]=i;
801  n=j;
802  }
803  // There will be at least one tie (the best will qualify, of course)
804  assert(n > 0);
805  }
806 
807  template<class Choose, class Merit>
808  void
810  int* ties, int& n) {
811  // Find the worst and best merit value
812  Val w = m(home,x[ties[0]],ties[0]);
813  Val b = w;
814  for (int i=1; i<n; i++) {
815  Val mxi = m(home,x[ties[i]],ties[i]);
816  if (c(mxi,b))
817  b=mxi;
818  else if (c(w,mxi))
819  w=mxi;
820  }
821  // Compute tie-break limit
823  double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
824  // If the limit is not better than the worst merit, everything is a tie
825  // and no breaking is required
826  if (c(l,static_cast<double>(w))) {
827  // The limit is not allowed to better than the best merit value
828  if (c(l,static_cast<double>(b)))
829  l = static_cast<double>(b);
830  // Keep all ties that are not worse than the limit merit value
831  int j=0;
832  for (int i=0; i<n; i++)
833  if (!c(l,static_cast<double>(m(home,x[ties[i]],ties[i]))))
834  ties[j++]=ties[i];
835  n=j;
836  }
837  // There will be at least one tie (the best will qualify)
838  assert(n > 0);
839  }
840  template<class Choose, class Merit>
841  bool
843  return true;
844  }
845  template<class Choose, class Merit>
846  void
848  tbl.~SharedData<BranchTbl>();
849  }
850 
851 
852 
853  template<class Merit>
856  : ViewSelChoose<ChooseMin,Merit>(home,vb) {}
857 
858  template<class Merit>
861  ViewSelMin<Merit>& vs)
862  : ViewSelChoose<ChooseMin,Merit>(home,shared,vs) {}
863 
864  template<class Merit>
867  return new (home) ViewSelMin<Merit>(home,shared,*this);
868  }
869 
870 
871  template<class Merit>
874  : ViewSelChooseTbl<ChooseMin,Merit>(home,vb) {}
875 
876  template<class Merit>
880  : ViewSelChooseTbl<ChooseMin,Merit>(home,shared,vs) {}
881 
882  template<class Merit>
885  return new (home) ViewSelMinTbl<Merit>(home,shared,*this);
886  }
887 
888 
889 
890  template<class Merit>
893  : ViewSelChoose<ChooseMax,Merit>(home,vb) {}
894 
895  template<class Merit>
898  ViewSelMax<Merit>& vs)
899  : ViewSelChoose<ChooseMax,Merit>(home,shared,vs) {}
900 
901  template<class Merit>
904  return new (home) ViewSelMax<Merit>(home,shared,*this);
905  }
906 
907 
908 
909  template<class Merit>
912  : ViewSelChooseTbl<ChooseMax,Merit>(home,vb) {}
913 
914  template<class Merit>
918  : ViewSelChooseTbl<ChooseMax,Merit>(home,shared,vs) {}
919 
920  template<class Merit>
923  return new (home) ViewSelMaxTbl<Merit>(home,shared,*this);
924  }
925 
926 
927 
928 }
929 
930 // 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
ViewSelNone(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
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.
virtual ~ViewSel(void)
Unused destructor.
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
Rnd r
The random number generator used.
bool operator()(Val a, Val b) const
Return true if a is better than b.
Class withot a branch filter function.
ViewSelMinTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
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.
ViewSelMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
ViewSelChoose(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
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.
Computation spaces.
Definition: core.hpp:1748
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.
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
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.
ViewSel< View >::Var Var
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
Class storing a branch filter function.
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.
Choose view according to merit.
ViewSelMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Definition: branch-var.hpp:52
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
ViewSel< typename Merit::View >::Var Var
virtual ViewSel< View > * copy(Space &home, bool shared)
Create copy during cloning.
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
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
Select a view randomly.
Exception: invalid function
Definition: exception.hpp:118
SharedData< BranchTbl > tbl
Tie-break limit function.
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:784
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
#define GECODE_VALID_FUNCTION(f)
Assert that a function is valid.
Definition: macros.hpp:98
bool operator()(Val a, Val b) const
Return true if a is better than b.
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)
Select ties from x starting from s.
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
Variable branching information.
Definition: branch-var.hpp:59
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.
ViewSelRnd(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
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)
Post propagator for SetVar x
Definition: set.hh:784
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:702
View::VarType Var
The corresponding variable type.
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
virtual void dispose(Space &home)
Delete view selection.
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.
ViewSel(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:60
virtual void dispose(Space &home)
Delete view selection.
ViewSelChoose< Choose, Merit >::Var Var
ViewSel< View >::Var Var
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)
Select ties from x starting from s.
ViewSelChooseTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
ViewSelMaxTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.