Generated on Tue Mar 24 2020 14:04:04 for Gecode by doxygen 1.8.17
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  * This file is part of Gecode, the generic constraint
10  * development environment:
11  * http://www.gecode.org
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining
14  * a copy of this software and associated documentation files (the
15  * "Software"), to deal in the Software without restriction, including
16  * without limitation the rights to use, copy, modify, merge, publish,
17  * distribute, sublicense, and/or sell copies of the Software, and to
18  * permit persons to whom the Software is furnished to do so, subject to
19  * the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be
22  * included in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31  *
32  */
33 
34 namespace Gecode {
35 
42  template<class _View>
44  class ViewSel {
45  public:
47  typedef _View View;
49  typedef typename View::VarType Var;
51 
52  ViewSel(Space& home, const VarBranch<Var>& vb);
55  ViewSel(Space& home, ViewSel<View>& vs);
57 
59  virtual int select(Space& home, ViewArray<View>& x, int s) = 0;
62  virtual int select(Space& home, ViewArray<View>& x, int s,
63  BrancherFilter<View>& f) = 0;
65  virtual int select(Space& home, ViewArray<View>& x, int s,
68  virtual void ties(Space& home, ViewArray<View>& x, int s,
69  int* ties, int& n) = 0;
71  virtual void ties(Space& home, ViewArray<View>& x, int s,
72  int* ties, int& n,
73  BrancherFilter<View>& f) = 0;
75  virtual void ties(Space& home, ViewArray<View>& x, int s,
76  int* ties, int& n,
79  virtual void brk(Space& home, ViewArray<View>& x,
80  int* ties, int& n) = 0;
82  virtual int select(Space& home, ViewArray<View>& x,
83  int* ties, int n) = 0;
85 
87  virtual ViewSel<View>* copy(Space& home) = 0;
90  virtual bool notice(void) const;
92  virtual void dispose(Space& home);
94  virtual ~ViewSel(void);
96 
98  static void* operator new(size_t s, Space& home);
101  static void operator delete(void* p, Space& home);
103  static void operator delete(void* p);
105  };
106 
108  template<class View>
109  class ViewSelNone : public ViewSel<View> {
110  protected:
111  typedef typename ViewSel<View>::Var Var;
112  public:
114 
115  ViewSelNone(Space& home, const VarBranch<Var>& vb);
118  ViewSelNone(Space& home, ViewSelNone<View>& vs);
120 
122  virtual int select(Space& home, ViewArray<View>& x, int s);
125  virtual int select(Space& home, ViewArray<View>& x, int s,
128  virtual void ties(Space& home, ViewArray<View>& x, int s,
129  int* ties, int& n);
131  virtual void ties(Space& home, ViewArray<View>& x, int s,
132  int* ties, int& n,
135  virtual void brk(Space& home, ViewArray<View>& x,
136  int* ties, int& n);
138  virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
140 
142  virtual ViewSel<View>* copy(Space& home);
145  };
146 
148  template<class View>
149  class ViewSelRnd : public ViewSel<View> {
150  protected:
151  typedef typename ViewSel<View>::Var Var;
154  public:
156 
157  ViewSelRnd(Space& home, const VarBranch<Var>& vb);
160  ViewSelRnd(Space& home, ViewSelRnd<View>& vs);
162 
164  virtual int select(Space& home, ViewArray<View>& x, int s);
167  virtual int select(Space& home, ViewArray<View>& x, int s,
170  virtual void ties(Space& home, ViewArray<View>& x, int s,
171  int* ties, int& n);
173  virtual void ties(Space& home, ViewArray<View>& x, int s,
174  int* ties, int& n,
177  virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
179  virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
181 
183  virtual ViewSel<View>* copy(Space& home);
186  };
187 
189  class ChooseMin {
190  public:
192  template<class Val>
193  bool operator ()(Val a, Val b) const;
194  };
195 
197  class ChooseMax {
198  public:
200  template<class Val>
201  bool operator ()(Val a, Val b) const;
202  };
203 
205  template<class Choose, class Merit>
206  class ViewSelChoose : public ViewSel<typename Merit::View> {
207  protected:
211  typedef typename Merit::Val Val;
213  Choose c;
215  Merit m;
216  public:
218 
219  ViewSelChoose(Space& home, const VarBranch<Var>& vb);
224 
226  virtual int select(Space& home, ViewArray<View>& x, int s);
229  virtual int select(Space& home, ViewArray<View>& x, int s,
232  virtual void ties(Space& home, ViewArray<View>& x, int s,
233  int* ties, int& n);
235  virtual void ties(Space& home, ViewArray<View>& x, int s,
236  int* ties, int& n,
239  virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
241  virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
243 
245  virtual bool notice(void) const;
248  virtual void dispose(Space& home);
250  };
251 
252 
254  template<class Choose, class Merit>
255  class ViewSelChooseTbl : public ViewSelChoose<Choose,Merit> {
256  protected:
264  public:
266 
267  ViewSelChooseTbl(Space& home, const VarBranch<Var>& vb);
272 
274  virtual void ties(Space& home, ViewArray<View>& x, int s,
276  int* ties, int& n);
278  virtual void ties(Space& home, ViewArray<View>& x, int s,
279  int* ties, int& n,
282  virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
284 
286  virtual bool notice(void) const;
289  virtual void dispose(Space& home);
291  };
292 
294  template<class Merit>
295  class ViewSelMin : public ViewSelChoose<ChooseMin,Merit> {
296  typedef typename ViewSelChoose<ChooseMin,Merit>::View View;
297  typedef typename ViewSelChoose<ChooseMin,Merit>::Var Var;
298  public:
300 
301  ViewSelMin(Space& home, const VarBranch<Var>& vb);
304  ViewSelMin(Space& home, ViewSelMin<Merit>& vs);
306 
308  virtual ViewSel<View>* copy(Space& home);
311  };
312 
314  template<class Merit>
315  class ViewSelMinTbl : public ViewSelChooseTbl<ChooseMin,Merit> {
316  typedef typename ViewSelChooseTbl<ChooseMin,Merit>::View View;
317  typedef typename ViewSelChooseTbl<ChooseMin,Merit>::Var Var;
318  public:
320 
321  ViewSelMinTbl(Space& home, const VarBranch<Var>& vb);
326 
328  virtual ViewSel<View>* copy(Space& home);
331  };
332 
334  template<class Merit>
335  class ViewSelMax : public ViewSelChoose<ChooseMax,Merit> {
336  typedef typename ViewSelChoose<ChooseMax,Merit>::View View;
337  typedef typename ViewSelChoose<ChooseMax,Merit>::Var Var;
338  public:
340 
341  ViewSelMax(Space& home, const VarBranch<Var>& vb);
344  ViewSelMax(Space& home, ViewSelMax<Merit>& vs);
346 
348  virtual ViewSel<View>* copy(Space& home);
351  };
352 
354  template<class Merit>
355  class ViewSelMaxTbl : public ViewSelChooseTbl<ChooseMax,Merit> {
356  typedef typename ViewSelChooseTbl<ChooseMax,Merit>::View View;
357  typedef typename ViewSelChooseTbl<ChooseMax,Merit>::Var Var;
358  public:
360 
361  ViewSelMaxTbl(Space& home, const VarBranch<Var>& vb);
366 
368  virtual ViewSel<View>* copy(Space& home);
371  };
373 
374 
375  template<class View>
378  template<class View>
381  template<class View>
382  int
385  GECODE_NEVER;
386  return 0;
387  }
388  template<class View>
389  void
391  int*, int&,
393  GECODE_NEVER;
394  }
395  template<class View>
396  bool
397  ViewSel<View>::notice(void) const {
398  return false;
399  }
400  template<class View>
401  void
403  template<class View>
405  template<class View>
406  forceinline void
407  ViewSel<View>::operator delete(void*) {}
408  template<class View>
409  forceinline void
410  ViewSel<View>::operator delete(void*, Space&) {}
411  template<class View>
412  forceinline void*
413  ViewSel<View>::operator new(size_t s, Space& home) {
414  return home.ralloc(s);
415  }
416 
417 
418 
419  template<class View>
422  : ViewSel<View>(home,vb) {}
423  template<class View>
426  : ViewSel<View>(home,vs) {}
427  template<class View>
428  int
430  return s;
431  }
432  template<class View>
433  int
436  return s;
437  }
438  template<class View>
439  void
441  int* ties, int& n) {
442  int j=0; ties[j++]=s;
443  for (int i=s+1; i<x.size(); i++)
444  if (!x[i].assigned())
445  ties[j++]=i;
446  n=j;
447  assert(n > 0);
448  }
449  template<class View>
450  void
452  int* ties, int& n,
454  int j=0; ties[j++]=s;
455  for (int i=s+1; i<x.size(); i++)
456  if (!x[i].assigned() && f(home,x[i],i))
457  ties[j++]=i;
458  n=j;
459  assert(n > 0);
460  }
461  template<class View>
462  void
464  // Nothing needs to be done
465  }
466  template<class View>
467  int
469  return ties[0];
470  }
471  template<class View>
474  return new (home) ViewSelNone<View>(home,*this);
475  }
476 
477 
478  template<class View>
481  : ViewSel<View>(home,vb), r(vb.rnd()) {}
482  template<class View>
485  : ViewSel<View>(home,vs), r(vs.r) {}
486  template<class View>
487  int
489  unsigned int n=1;
490  int j=s;
491  for (int i=s+1; i<x.size(); i++)
492  if (!x[i].assigned()) {
493  n++;
494  if (r(n) == 0U)
495  j=i;
496  }
497  return j;
498  }
499  template<class View>
500  int
503  unsigned int n=1;
504  int j=s;
505  for (int i=s+1; i<x.size(); i++)
506  if (!x[i].assigned() && f(home,x[i],i)) {
507  n++;
508  if (r(n) == 0U)
509  j=i;
510  }
511  return j;
512  }
513  template<class View>
514  void
516  int* ties, int& n) {
517  n=1; ties[0] = select(home,x,s);
518  }
519  template<class View>
520  void
522  int* ties, int& n,
524  n=1; ties[0] = select(home,x,s);
525  }
526  template<class View>
527  void
529  ties[0] = ties[static_cast<int>(r(static_cast<unsigned int>(n)))];
530  n=1;
531  }
532  template<class View>
533  int
535  return ties[static_cast<int>(r(static_cast<unsigned int>(n)))];
536  }
537  template<class View>
540  return new (home) ViewSelRnd<View>(home,*this);
541  }
542 
543 
544  template<class Val>
545  forceinline bool
546  ChooseMin::operator ()(Val a, Val b) const {
547  return a < b;
548  }
549  template<class Val>
550  forceinline bool
551  ChooseMax::operator ()(Val a, Val b) const {
552  return a > b;
553  }
554 
555 
556  template<class Choose, class Merit>
559  : ViewSel<View>(home,vb), m(home,vb) {}
560 
561  template<class Choose, class Merit>
565  : ViewSel<View>(home,vs), m(home,vs.m) {}
566 
567  template<class Choose, class Merit>
568  int
570  // Consider x[s] as the so-far best view
571  int b_i = s;
572  Val b_m = m(home,x[s],s);
573  // Scan all non-assigned views from s+1 onwards
574  for (int i=s+1; i<x.size(); i++)
575  if (!x[i].assigned()) {
576  Val mxi = m(home,x[i],i);
577  if (c(mxi,b_m)) {
578  b_i = i; b_m = mxi;
579  }
580  }
581  return b_i;
582  }
583 
584  template<class Choose, class Merit>
585  int
588  // Consider x[s] as the so-far best view
589  int b_i = s;
590  Val b_m = m(home,x[s],s);
591  // Scan all non-assigned views from s+1 onwards
592  for (int i=s+1; i<x.size(); i++)
593  if (!x[i].assigned() && f(home,x[i],i)) {
594  Val mxi = m(home,x[i],i);
595  if (c(mxi,b_m)) {
596  b_i = i; b_m = mxi;
597  }
598  }
599  return b_i;
600  }
601 
602  template<class Choose, class Merit>
603  void
605  int* ties, int& n) {
606  // Consider x[s] as the so-far best view and record as tie
607  Val b = m(home,x[s],s);
608  int j=0; ties[j++]=s;
609  for (int i=s+1; i<x.size(); i++)
610  if (!x[i].assigned()) {
611  Val mxi = m(home,x[i],i);
612  if (c(mxi,b)) {
613  // Found a better one, reset all ties and record
614  j=0; ties[j++]=i; b=mxi;
615  } else if (mxi == b) {
616  // Found a tie, record
617  ties[j++]=i;
618  }
619  }
620  n=j;
621  // There must be at least one tie, of course!
622  assert(n > 0);
623  }
624 
625  template<class Choose, class Merit>
626  void
628  int* ties, int& n,
630  // Consider x[s] as the so-far best view and record as tie
631  Val b = m(home,x[s],s);
632  int j=0; ties[j++]=s;
633  for (int i=s+1; i<x.size(); i++)
634  if (!x[i].assigned() && f(home,x[i],i)) {
635  Val mxi = m(home,x[i],i);
636  if (c(mxi,b)) {
637  // Found a better one, reset all ties and record
638  j=0; ties[j++]=i; b=mxi;
639  } else if (mxi == b) {
640  // Found a tie, record
641  ties[j++]=i;
642  }
643  }
644  n=j;
645  // There must be at least one tie, of course!
646  assert(n > 0);
647  }
648 
649  template<class Choose, class Merit>
650  void
652  int* ties, int& n) {
653  // Keep first tie in place
654  Val b = m(home,x[ties[0]],ties[0]);
655  int j=1;
656  // Scan remaining ties
657  for (int i=1; i<n; i++) {
658  Val mxi = m(home,x[ties[i]],ties[i]);
659  if (c(mxi,b)) {
660  // Found a better one, reset all ties
661  b=mxi; j=0; ties[j++]=ties[i];
662  } else if (mxi == b) {
663  // Found a tie and record it
664  ties[j++]=ties[i];
665  }
666  }
667  n=j;
668  // There must be at least one tie, of course!
669  assert(n > 0);
670  }
671 
672  template<class Choose, class Merit>
673  int
675  int* ties, int n) {
676  int b_i = ties[0];
677  Val b_m = m(home,x[ties[0]],ties[0]);
678  for (int i=1; i<n; i++) {
679  Val mxi = m(home,x[ties[i]],ties[i]);
680  if (c(mxi,b_m)) {
681  b_i = ties[i]; b_m = mxi;
682  }
683  }
684  return b_i;
685  }
686 
687  template<class Choose, class Merit>
688  bool
690  return m.notice();
691  }
692 
693  template<class Choose, class Merit>
694  void
696  m.dispose(home);
697  }
698 
699 
700  template<class Choose, class Merit>
703  const VarBranch<Var>& vb)
704  : ViewSelChoose<Choose,Merit>(home,vb), tbl(vb.tbl()) {
705  if (!tbl())
706  throw InvalidFunction("ViewSelChooseTbl::ViewSelChooseTbl");
707  }
708 
709  template<class Choose, class Merit>
713  : ViewSelChoose<Choose,Merit>(home,vs), tbl(vs.tbl) {
714  }
715 
716  template<class Choose, class Merit>
717  void
719  int* ties, int& n) {
720  // Find the worst and best merit value
721  Val w = m(home,x[s],s);
722  Val b = w;
723  for (int i=s+1; i<x.size(); i++)
724  if (!x[i].assigned()) {
725  Val mxi = m(home,x[i],i);
726  if (c(mxi,b))
727  b=mxi;
728  else if (c(w,mxi))
729  w=mxi;
730  }
731  // Compute tie-break limit
733  double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
734  // If the limit is not better than the worst merit, everything is a tie
735  if (!c(l,static_cast<double>(w))) {
736  int j=0;
737  for (int i=s; i<x.size(); i++)
738  if (!x[i].assigned())
739  ties[j++]=i;
740  n=j;
741  } else {
742  // The limit is not allowed to better than the best merit value
743  if (c(l,static_cast<double>(b)))
744  l = static_cast<double>(b);
745  // Record all ties that are not worse than the limit merit value
746  int j=0;
747  for (int i=s; i<x.size(); i++)
748  if (!x[i].assigned() && !c(l,static_cast<double>(m(home,x[i],i))))
749  ties[j++]=i;
750  n=j;
751  }
752  // There will be at least one tie (the best will qualify, of course)
753  assert(n > 0);
754  }
755 
756  template<class Choose, class Merit>
757  void
759  int* ties, int& n,
761  // Find the worst and best merit value
762  assert(f(home,x[s],s));
763  Val w = m(home,x[s],s);
764  Val b = w;
765  for (int i=s+1; i<x.size(); i++)
766  if (!x[i].assigned() && f(home,x[i],i)) {
767  Val mxi = m(home,x[i],i);
768  if (c(mxi,b))
769  b=mxi;
770  else if (c(w,mxi))
771  w=mxi;
772  }
773  // Compute tie-break limit
775  double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
776  // If the limit is not better than the worst merit, everything is a tie
777  if (!c(l,static_cast<double>(w))) {
778  int j=0;
779  for (int i=s; i<x.size(); i++)
780  if (!x[i].assigned() && f(home,x[i],i))
781  ties[j++]=i;
782  n=j;
783  } else {
784  // The limit is not allowed to better than the best merit value
785  if (c(l,static_cast<double>(b)))
786  l = static_cast<double>(b);
787  // Record all ties that are not worse than the limit merit value
788  int j=0;
789  for (int i=s; i<x.size(); i++)
790  if (!x[i].assigned() && f(home,x[i],i) &&
791  !c(l,static_cast<double>(m(home,x[i],i))))
792  ties[j++]=i;
793  n=j;
794  }
795  // There will be at least one tie (the best will qualify, of course)
796  assert(n > 0);
797  }
798 
799  template<class Choose, class Merit>
800  void
802  int* ties, int& n) {
803  // Find the worst and best merit value
804  Val w = m(home,x[ties[0]],ties[0]);
805  Val b = w;
806  for (int i=1; i<n; i++) {
807  Val mxi = m(home,x[ties[i]],ties[i]);
808  if (c(mxi,b))
809  b=mxi;
810  else if (c(w,mxi))
811  w=mxi;
812  }
813  // Compute tie-break limit
815  double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
816  // If the limit is not better than the worst merit, everything is a tie
817  // and no breaking is required
818  if (c(l,static_cast<double>(w))) {
819  // The limit is not allowed to better than the best merit value
820  if (c(l,static_cast<double>(b)))
821  l = static_cast<double>(b);
822  // Keep all ties that are not worse than the limit merit value
823  int j=0;
824  for (int i=0; i<n; i++)
825  if (!c(l,static_cast<double>(m(home,x[ties[i]],ties[i]))))
826  ties[j++]=ties[i];
827  n=j;
828  }
829  // There will be at least one tie (the best will qualify)
830  assert(n > 0);
831  }
832  template<class Choose, class Merit>
833  bool
835  return true;
836  }
837  template<class Choose, class Merit>
838  void
840  tbl.~SharedData<BranchTbl>();
841  }
842 
843 
844 
845  template<class Merit>
848  : ViewSelChoose<ChooseMin,Merit>(home,vb) {}
849 
850  template<class Merit>
853  : ViewSelChoose<ChooseMin,Merit>(home,vs) {}
854 
855  template<class Merit>
858  return new (home) ViewSelMin<Merit>(home,*this);
859  }
860 
861 
862  template<class Merit>
865  : ViewSelChooseTbl<ChooseMin,Merit>(home,vb) {}
866 
867  template<class Merit>
870  : ViewSelChooseTbl<ChooseMin,Merit>(home,vs) {}
871 
872  template<class Merit>
875  return new (home) ViewSelMinTbl<Merit>(home,*this);
876  }
877 
878 
879 
880  template<class Merit>
883  : ViewSelChoose<ChooseMax,Merit>(home,vb) {}
884 
885  template<class Merit>
888  : ViewSelChoose<ChooseMax,Merit>(home,vs) {}
889 
890  template<class Merit>
893  return new (home) ViewSelMax<Merit>(home,*this);
894  }
895 
896 
897 
898  template<class Merit>
901  : ViewSelChooseTbl<ChooseMax,Merit>(home,vb) {}
902 
903  template<class Merit>
906  : ViewSelChooseTbl<ChooseMax,Merit>(home,vs) {}
907 
908  template<class Merit>
911  return new (home) ViewSelMaxTbl<Merit>(home,*this);
912  }
913 
914 
915 
916 }
917 
918 // STATISTICS: kernel-branch
virtual ~ViewSel(void)
Unused destructor.
Definition: view-sel.hpp:404
virtual int select(Space &home, ViewArray< View > &x, int s)
Select a view from x starting at s and return its position.
Definition: view-sel.hpp:429
Post propagator for SetVar x
Definition: set.hh:767
Select view with least merit taking tie-break limit into account.
Definition: view-sel.hpp:315
Select a view randomly.
Definition: view-sel.hpp:149
Select the first unassigned view.
Definition: view-sel.hpp:109
Class withot a branch filter function.
Definition: filter.hpp:68
virtual int select(Space &home, ViewArray< View > &x, int s)
Select a view from x starting from s and return its position.
Definition: view-sel.hpp:488
bool operator()(Val a, Val b) const
Return true if a is better than b.
Definition: view-sel.hpp:546
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition: view-sel.hpp:874
ViewSelChoose< Choose, Merit >::Val Val
Definition: view-sel.hpp:257
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:43
ViewSelChoose(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition: view-sel.hpp:558
ViewSelMinTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: view-sel.hpp:864
ViewSelChoose< Choose, Merit >::Var Var
Definition: view-sel.hpp:259
Computation spaces.
Definition: core.hpp:1742
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)=0
Select ties from x starting from s.
virtual void brk(Space &home, ViewArray< View > &x, int *ties, int &n)=0
Break ties in x and update to new ties.
virtual void brk(Space &home, ViewArray< View > &x, int *ties, int &n)
Break ties in x and update to new ties.
Definition: view-sel.hpp:528
virtual void dispose(Space &home)
Dispose view selection.
Definition: view-sel.hpp:402
#define GECODE_VALID_FUNCTION(f)
Assert that a function is valid.
Definition: macros.hpp:94
Merit m
The merit object used.
Definition: view-sel.hpp:215
Variable branching information.
Definition: var.hpp:55
Gecode toplevel namespace
virtual void brk(Space &home, ViewArray< View > &x, int *ties, int &n)
Break ties in x and update to new ties.
Definition: view-sel.hpp:463
double tbl(const Gecode::Space &, double w, double b)
Test function for tie-break limit function.
Definition: branch.cpp:61
Choose c
How to choose.
Definition: view-sel.hpp:213
ViewSelMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: view-sel.hpp:882
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)
Select ties from x starting from s.
Definition: view-sel.hpp:718
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:249
ViewSelMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: view-sel.hpp:847
Select view with largest merit.
Definition: view-sel.hpp:335
virtual void brk(Space &home, ViewArray< View > &x, int *ties, int &n)
Break ties in x and update to new ties.
Definition: view-sel.hpp:651
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: view-sel.hpp:834
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:767
virtual ViewSel< View > * copy(Space &home)=0
Create copy during cloning.
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
ViewSel< typename Merit::View >::Var Var
Definition: view-sel.hpp:208
Random number generator.
Definition: rnd.hpp:42
virtual int select(Space &home, ViewArray< View > &x, int s)=0
Select a view from x starting from s and return its position.
ViewSelChooseTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: view-sel.hpp:702
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:56
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
ViewSelRnd(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition: view-sel.hpp:480
Choose views with smaller merit values.
Definition: view-sel.hpp:189
ViewSelChoose< Choose, Merit >::View View
Definition: view-sel.hpp:258
ViewSel< View >::Var Var
Definition: view-sel.hpp:151
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: view-sel.hpp:397
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition: view-sel.hpp:539
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: view-sel.hpp:689
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)
Select ties from x starting from s.
Definition: view-sel.hpp:604
Class storing a branch filter function.
Definition: filter.hpp:45
Rnd r
The random number generator used.
Definition: view-sel.hpp:153
NNF * l
Left subtree.
Definition: bool-expr.cpp:240
Abstract class for view selection.
Definition: view-sel.hpp:44
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)
Select ties from x starting at s.
Definition: view-sel.hpp:440
Exception: invalid function
Definition: exception.hpp:114
Choose views with larger merit values.
Definition: view-sel.hpp:197
Choose view according to merit taking tie-break limit into account.
Definition: view-sel.hpp:255
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition: view-sel.hpp:473
Select view with largest merit taking tie-break limit into account.
Definition: view-sel.hpp:355
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition: view-sel.hpp:892
Merit::Val Val
Type of merit.
Definition: view-sel.hpp:211
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition: view-sel.hpp:857
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)
Select ties from x starting from s.
Definition: view-sel.hpp:515
#define forceinline
Definition: config.hpp:185
virtual void dispose(Space &home)
Delete view selection.
Definition: view-sel.hpp:839
ViewSel< typename Merit::View >::View View
Definition: view-sel.hpp:209
Failed f
Definition: unshare.cpp:124
ViewSel< View >::Var Var
Definition: view-sel.hpp:111
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Definition: var.hpp:48
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
SharedData< BranchTbl > tbl
Tie-break limit function.
Definition: view-sel.hpp:263
Gecode::FloatVal c(-8, 8)
virtual int select(Space &home, ViewArray< View > &x, int s)
Select a view from x starting from s and return its position.
Definition: view-sel.hpp:569
View arrays.
Definition: array.hpp:253
View::VarType Var
The corresponding variable type.
Definition: view-sel.hpp:49
Select view with least merit.
Definition: view-sel.hpp:295
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
ViewSelNone(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition: view-sel.hpp:421
Gecode::IntArgs i({1, 2, 3, 4})
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition: view-sel.hpp:910
ViewSelMaxTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: view-sel.hpp:900
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
_View View
Define the view type.
Definition: view-sel.hpp:47
ViewSel(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition: view-sel.hpp:377
bool operator()(Val a, Val b) const
Return true if a is better than b.
Definition: view-sel.hpp:551
Choose view according to merit.
Definition: view-sel.hpp:206
virtual void brk(Space &home, ViewArray< View > &x, int *ties, int &n)
Break ties in x and update to new ties.
Definition: view-sel.hpp:801
virtual void dispose(Space &home)
Delete view selection.
Definition: view-sel.hpp:695