Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
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$ by $Author$
11  * $Revision$
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, 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) = 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, 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);
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, 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);
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);
276 
278  virtual void ties(Space& home, ViewArray<View>& x, int s,
280  int* ties, int& n);
282  virtual void ties(Space& home, ViewArray<View>& x, int s,
283  int* ties, int& n,
286  virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
288 
290  virtual bool notice(void) const;
293  virtual void dispose(Space& home);
295  };
296 
298  template<class Merit>
299  class ViewSelMin : public ViewSelChoose<ChooseMin,Merit> {
301  typedef typename ViewSelChoose<ChooseMin,Merit>::Var Var;
302  public:
304 
305  ViewSelMin(Space& home, const VarBranch<Var>& vb);
308  ViewSelMin(Space& home, ViewSelMin<Merit>& vs);
310 
312  virtual ViewSel<View>* copy(Space& home);
315  };
316 
318  template<class Merit>
319  class ViewSelMinTbl : public ViewSelChooseTbl<ChooseMin,Merit> {
322  public:
324 
325  ViewSelMinTbl(Space& home, const VarBranch<Var>& vb);
330 
332  virtual ViewSel<View>* copy(Space& home);
335  };
336 
338  template<class Merit>
339  class ViewSelMax : public ViewSelChoose<ChooseMax,Merit> {
341  typedef typename ViewSelChoose<ChooseMax,Merit>::Var Var;
342  public:
344 
345  ViewSelMax(Space& home, const VarBranch<Var>& vb);
348  ViewSelMax(Space& home, ViewSelMax<Merit>& vs);
350 
352  virtual ViewSel<View>* copy(Space& home);
355  };
356 
358  template<class Merit>
359  class ViewSelMaxTbl : public ViewSelChooseTbl<ChooseMax,Merit> {
362  public:
364 
365  ViewSelMaxTbl(Space& home, const VarBranch<Var>& vb);
370 
372  virtual ViewSel<View>* copy(Space& home);
375  };
377 
378 
379  template<class View>
382  template<class View>
385  template<class View>
386  int
389  GECODE_NEVER;
390  return 0;
391  }
392  template<class View>
393  void
395  int*, int&,
397  GECODE_NEVER;
398  }
399  template<class View>
400  bool
401  ViewSel<View>::notice(void) const {
402  return false;
403  }
404  template<class View>
405  void
407  template<class View>
409  template<class View>
410  forceinline void
411  ViewSel<View>::operator delete(void*) {}
412  template<class View>
413  forceinline void
414  ViewSel<View>::operator delete(void*, Space&) {}
415  template<class View>
416  forceinline void*
417  ViewSel<View>::operator new(size_t s, Space& home) {
418  return home.ralloc(s);
419  }
420 
421 
422 
423  template<class View>
426  : ViewSel<View>(home,vb) {}
427  template<class View>
430  : ViewSel<View>(home,vs) {}
431  template<class View>
432  int
434  return s;
435  }
436  template<class View>
437  int
440  return s;
441  }
442  template<class View>
443  void
445  int* ties, int& n) {
446  int j=0; ties[j++]=s;
447  for (int i=s+1; i<x.size(); i++)
448  if (!x[i].assigned())
449  ties[j++]=i;
450  n=j;
451  assert(n > 0);
452  }
453  template<class View>
454  void
456  int* ties, int& n,
458  int j=0; ties[j++]=s;
459  for (int i=s+1; i<x.size(); i++)
460  if (!x[i].assigned() && f(home,x[i],i))
461  ties[j++]=i;
462  n=j;
463  assert(n > 0);
464  }
465  template<class View>
466  void
468  // Nothing needs to be done
469  }
470  template<class View>
471  int
473  return ties[0];
474  }
475  template<class View>
478  return new (home) ViewSelNone<View>(home,*this);
479  }
480 
481 
482  template<class View>
485  : ViewSel<View>(home,vb), r(vb.rnd()) {}
486  template<class View>
489  : ViewSel<View>(home,vs), r(vs.r) {}
490  template<class View>
491  int
493  unsigned int n=1;
494  int j=s;
495  for (int i=s+1; i<x.size(); i++)
496  if (!x[i].assigned()) {
497  n++;
498  if (r(n) == 0U)
499  j=i;
500  }
501  return j;
502  }
503  template<class View>
504  int
507  unsigned int n=1;
508  int j=s;
509  for (int i=s+1; i<x.size(); i++)
510  if (!x[i].assigned() && f(home,x[i],i)) {
511  n++;
512  if (r(n) == 0U)
513  j=i;
514  }
515  return j;
516  }
517  template<class View>
518  void
520  int* ties, int& n) {
521  n=1; ties[0] = select(home,x,s);
522  }
523  template<class View>
524  void
526  int* ties, int& n,
528  n=1; ties[0] = select(home,x,s);
529  }
530  template<class View>
531  void
533  ties[0] = ties[static_cast<int>(r(static_cast<unsigned int>(n)))];
534  n=1;
535  }
536  template<class View>
537  int
539  return ties[static_cast<int>(r(static_cast<unsigned int>(n)))];
540  }
541  template<class View>
544  return new (home) ViewSelRnd<View>(home,*this);
545  }
546 
547 
548  template<class Val>
549  forceinline bool
550  ChooseMin::operator ()(Val a, Val b) const {
551  return a < b;
552  }
553  template<class Val>
554  forceinline bool
555  ChooseMax::operator ()(Val a, Val b) const {
556  return a > b;
557  }
558 
559 
560  template<class Choose, class Merit>
563  : ViewSel<View>(home,vb), m(home,vb) {}
564 
565  template<class Choose, class Merit>
569  : ViewSel<View>(home,vs), m(home,vs.m) {}
570 
571  template<class Choose, class Merit>
572  int
574  // Consider x[s] as the so-far best view
575  int b_i = s;
576  Val b_m = m(home,x[s],s);
577  // Scan all non-assigned views from s+1 onwards
578  for (int i=s+1; i<x.size(); i++)
579  if (!x[i].assigned()) {
580  Val mxi = m(home,x[i],i);
581  if (c(mxi,b_m)) {
582  b_i = i; b_m = mxi;
583  }
584  }
585  return b_i;
586  }
587 
588  template<class Choose, class Merit>
589  int
592  // Consider x[s] as the so-far best view
593  int b_i = s;
594  Val b_m = m(home,x[s],s);
595  // Scan all non-assigned views from s+1 onwards
596  for (int i=s+1; i<x.size(); i++)
597  if (!x[i].assigned() && f(home,x[i],i)) {
598  Val mxi = m(home,x[i],i);
599  if (c(mxi,b_m)) {
600  b_i = i; b_m = mxi;
601  }
602  }
603  return b_i;
604  }
605 
606  template<class Choose, class Merit>
607  void
609  int* ties, int& n) {
610  // Consider x[s] as the so-far best view and record as tie
611  Val b = m(home,x[s],s);
612  int j=0; ties[j++]=s;
613  for (int i=s+1; i<x.size(); i++)
614  if (!x[i].assigned()) {
615  Val mxi = m(home,x[i],i);
616  if (c(mxi,b)) {
617  // Found a better one, reset all ties and record
618  j=0; ties[j++]=i; b=mxi;
619  } else if (mxi == b) {
620  // Found a tie, record
621  ties[j++]=i;
622  }
623  }
624  n=j;
625  // There must be at least one tie, of course!
626  assert(n > 0);
627  }
628 
629  template<class Choose, class Merit>
630  void
632  int* ties, int& n,
634  // Consider x[s] as the so-far best view and record as tie
635  Val b = m(home,x[s],s);
636  int j=0; ties[j++]=s;
637  for (int i=s+1; i<x.size(); i++)
638  if (!x[i].assigned() && f(home,x[i],i)) {
639  Val mxi = m(home,x[i],i);
640  if (c(mxi,b)) {
641  // Found a better one, reset all ties and record
642  j=0; ties[j++]=i; b=mxi;
643  } else if (mxi == b) {
644  // Found a tie, record
645  ties[j++]=i;
646  }
647  }
648  n=j;
649  // There must be at least one tie, of course!
650  assert(n > 0);
651  }
652 
653  template<class Choose, class Merit>
654  void
656  int* ties, int& n) {
657  // Keep first tie in place
658  Val b = m(home,x[ties[0]],ties[0]);
659  int j=1;
660  // Scan remaining ties
661  for (int i=1; i<n; i++) {
662  Val mxi = m(home,x[ties[i]],ties[i]);
663  if (c(mxi,b)) {
664  // Found a better one, reset all ties
665  b=mxi; j=0; ties[j++]=ties[i];
666  } else if (mxi == b) {
667  // Found a tie and record it
668  ties[j++]=ties[i];
669  }
670  }
671  n=j;
672  // There must be at least one tie, of course!
673  assert(n > 0);
674  }
675 
676  template<class Choose, class Merit>
677  int
679  int* ties, int n) {
680  int b_i = ties[0];
681  Val b_m = m(home,x[ties[0]],ties[0]);
682  for (int i=1; i<n; i++) {
683  Val mxi = m(home,x[ties[i]],ties[i]);
684  if (c(mxi,b_m)) {
685  b_i = ties[i]; b_m = mxi;
686  }
687  }
688  return b_i;
689  }
690 
691  template<class Choose, class Merit>
692  bool
694  return m.notice();
695  }
696 
697  template<class Choose, class Merit>
698  void
700  m.dispose(home);
701  }
702 
703 
704  template<class Choose, class Merit>
707  const VarBranch<Var>& vb)
708  : ViewSelChoose<Choose,Merit>(home,vb), tbl(vb.tbl()) {
709  if (!tbl())
710  throw InvalidFunction("ViewSelChooseTbl::ViewSelChooseTbl");
711  }
712 
713  template<class Choose, class Merit>
717  : ViewSelChoose<Choose,Merit>(home,vs), tbl(vs.tbl) {
718  }
719 
720  template<class Choose, class Merit>
721  void
723  int* ties, int& n) {
724  // Find the worst and best merit value
725  Val w = m(home,x[s],s);
726  Val b = w;
727  for (int i=s+1; i<x.size(); i++)
728  if (!x[i].assigned()) {
729  Val mxi = m(home,x[i],i);
730  if (c(mxi,b))
731  b=mxi;
732  else if (c(w,mxi))
733  w=mxi;
734  }
735  // Compute tie-break limit
737  double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
738  // If the limit is not better than the worst merit, everything is a tie
739  if (!c(l,static_cast<double>(w))) {
740  int j=0;
741  for (int i=s; i<x.size(); i++)
742  if (!x[i].assigned())
743  ties[j++]=i;
744  n=j;
745  } else {
746  // The limit is not allowed to better than the best merit value
747  if (c(l,static_cast<double>(b)))
748  l = static_cast<double>(b);
749  // Record all ties that are not worse than the limit merit value
750  int j=0;
751  for (int i=s; i<x.size(); i++)
752  if (!x[i].assigned() && !c(l,static_cast<double>(m(home,x[i],i))))
753  ties[j++]=i;
754  n=j;
755  }
756  // There will be at least one tie (the best will qualify, of course)
757  assert(n > 0);
758  }
759 
760  template<class Choose, class Merit>
761  void
763  int* ties, int& n,
765  // Find the worst and best merit value
766  assert(f(home,x[s],s));
767  Val w = m(home,x[s],s);
768  Val b = w;
769  for (int i=s+1; i<x.size(); i++)
770  if (!x[i].assigned() && f(home,x[i],i)) {
771  Val mxi = m(home,x[i],i);
772  if (c(mxi,b))
773  b=mxi;
774  else if (c(w,mxi))
775  w=mxi;
776  }
777  // Compute tie-break limit
779  double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
780  // If the limit is not better than the worst merit, everything is a tie
781  if (!c(l,static_cast<double>(w))) {
782  int j=0;
783  for (int i=s; i<x.size(); i++)
784  if (!x[i].assigned() && f(home,x[i],i))
785  ties[j++]=i;
786  n=j;
787  } else {
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  // Record all ties that are not worse than the limit merit value
792  int j=0;
793  for (int i=s; i<x.size(); i++)
794  if (!x[i].assigned() && f(home,x[i],i) &&
795  !c(l,static_cast<double>(m(home,x[i],i))))
796  ties[j++]=i;
797  n=j;
798  }
799  // There will be at least one tie (the best will qualify, of course)
800  assert(n > 0);
801  }
802 
803  template<class Choose, class Merit>
804  void
806  int* ties, int& n) {
807  // Find the worst and best merit value
808  Val w = m(home,x[ties[0]],ties[0]);
809  Val b = w;
810  for (int i=1; i<n; i++) {
811  Val mxi = m(home,x[ties[i]],ties[i]);
812  if (c(mxi,b))
813  b=mxi;
814  else if (c(w,mxi))
815  w=mxi;
816  }
817  // Compute tie-break limit
819  double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
820  // If the limit is not better than the worst merit, everything is a tie
821  // and no breaking is required
822  if (c(l,static_cast<double>(w))) {
823  // The limit is not allowed to better than the best merit value
824  if (c(l,static_cast<double>(b)))
825  l = static_cast<double>(b);
826  // Keep all ties that are not worse than the limit merit value
827  int j=0;
828  for (int i=0; i<n; i++)
829  if (!c(l,static_cast<double>(m(home,x[ties[i]],ties[i]))))
830  ties[j++]=ties[i];
831  n=j;
832  }
833  // There will be at least one tie (the best will qualify)
834  assert(n > 0);
835  }
836  template<class Choose, class Merit>
837  bool
839  return true;
840  }
841  template<class Choose, class Merit>
842  void
844  tbl.~SharedData<BranchTbl>();
845  }
846 
847 
848 
849  template<class Merit>
852  : ViewSelChoose<ChooseMin,Merit>(home,vb) {}
853 
854  template<class Merit>
857  : ViewSelChoose<ChooseMin,Merit>(home,vs) {}
858 
859  template<class Merit>
862  return new (home) ViewSelMin<Merit>(home,*this);
863  }
864 
865 
866  template<class Merit>
869  : ViewSelChooseTbl<ChooseMin,Merit>(home,vb) {}
870 
871  template<class Merit>
874  : ViewSelChooseTbl<ChooseMin,Merit>(home,vs) {}
875 
876  template<class Merit>
879  return new (home) ViewSelMinTbl<Merit>(home,*this);
880  }
881 
882 
883 
884  template<class Merit>
887  : ViewSelChoose<ChooseMax,Merit>(home,vb) {}
888 
889  template<class Merit>
892  : ViewSelChoose<ChooseMax,Merit>(home,vs) {}
893 
894  template<class Merit>
897  return new (home) ViewSelMax<Merit>(home,*this);
898  }
899 
900 
901 
902  template<class Merit>
905  : ViewSelChooseTbl<ChooseMax,Merit>(home,vb) {}
906 
907  template<class Merit>
910  : ViewSelChooseTbl<ChooseMax,Merit>(home,vs) {}
911 
912  template<class Merit>
915  return new (home) ViewSelMaxTbl<Merit>(home,*this);
916  }
917 
918 
919 
920 }
921 
922 // STATISTICS: kernel-branch
Select view with largest merit.
Definition: view-sel.hpp:339
ViewSelChoose< Choose, Merit >::Val Val
Definition: view-sel.hpp:261
ViewSelNone(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition: view-sel.hpp:425
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:444
virtual ~ViewSel(void)
Unused destructor.
Definition: view-sel.hpp:408
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
Rnd r
The random number generator used.
Definition: view-sel.hpp:157
bool operator()(Val a, Val b) const
Return true if a is better than b.
Definition: view-sel.hpp:555
Class withot a branch filter function.
Definition: filter.hpp:72
ViewSelMinTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: view-sel.hpp:868
Abstract class for view selection.
Definition: view-sel.hpp:48
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition: view-sel.hpp:878
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)=0
Select ties from x starting from s.
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition: view-sel.hpp:861
ViewSelMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: view-sel.hpp:851
ViewSelChoose(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition: view-sel.hpp:562
Choose view according to merit taking tie-break limit into account.
Definition: view-sel.hpp:259
Choose views with larger merit values.
Definition: view-sel.hpp:201
Merit m
The merit object used.
Definition: view-sel.hpp:219
#define forceinline
Definition: config.hpp:182
Computation spaces.
Definition: core.hpp:1668
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.
Definition: view-sel.hpp:433
Select the first unassigned view.
Definition: view-sel.hpp:113
Select view with least merit.
Definition: view-sel.hpp:299
Gecode::FloatVal c(-8, 8)
virtual void dispose(Space &home)
Dispose view selection.
Definition: view-sel.hpp:406
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
ViewSel< View >::Var Var
Definition: view-sel.hpp:155
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.
Definition: filter.hpp:49
Choose c
How to choose.
Definition: view-sel.hpp:217
Select view with largest merit taking tie-break limit into account.
Definition: view-sel.hpp:359
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:532
Choose view according to merit.
Definition: view-sel.hpp:210
ViewSelMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: view-sel.hpp:886
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Definition: var.hpp:52
ViewSel< typename Merit::View >::Var Var
Definition: view-sel.hpp:212
Select view with least merit taking tie-break limit into account.
Definition: view-sel.hpp:319
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.
Definition: view-sel.hpp:193
View arrays.
Definition: array.hpp:228
Select a view randomly.
Definition: view-sel.hpp:153
virtual ViewSel< View > * copy(Space &home)=0
Create copy during cloning.
Exception: invalid function
Definition: exception.hpp:118
SharedData< BranchTbl > tbl
Tie-break limit function.
Definition: view-sel.hpp:267
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:769
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: view-sel.hpp:401
#define GECODE_VALID_FUNCTION(f)
Assert that a function is valid.
Definition: macros.hpp:98
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
bool operator()(Val a, Val b) const
Return true if a is better than b.
Definition: view-sel.hpp:550
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
Variable branching information.
Definition: 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.
Definition: view-sel.hpp:467
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition: view-sel.hpp:896
ViewSelRnd(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition: view-sel.hpp:484
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:47
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: view-sel.hpp:693
Post propagator for SetVar x
Definition: set.hh:769
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition: view-sel.hpp:543
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition: view-sel.hpp:477
View::VarType Var
The corresponding variable type.
Definition: view-sel.hpp:53
Merit::Val Val
Type of merit.
Definition: view-sel.hpp:215
Gecode toplevel namespace
Random number generator.
Definition: rnd.hpp:46
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition: view-sel.hpp:914
ViewSel< typename Merit::View >::View View
Definition: view-sel.hpp:213
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:492
ViewSelChoose< Choose, Merit >::View View
Definition: view-sel.hpp:262
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1203
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.
Definition: view-sel.hpp:51
ViewSel(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition: view-sel.hpp:381
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:60
virtual void dispose(Space &home)
Delete view selection.
Definition: view-sel.hpp:699
ViewSelChoose< Choose, Merit >::Var Var
Definition: view-sel.hpp:263
ViewSel< View >::Var Var
Definition: view-sel.hpp:115
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:519
ViewSelMaxTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition: view-sel.hpp:904