Generated on for Gecode by doxygen 1.17.0
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.dev>
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.dev
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
34namespace Gecode {
35
42
43 template<class View_>
44 class ViewSel {
45 public:
47 typedef View_ View;
49 typedef typename View::VarType Var;
51
52
53 ViewSel(Space& home, const VarBranch<Var>& vb);
57
59
60 virtual int select(Space& home, ViewArray<View>& x, int s) = 0;
62 virtual int select(Space& home, ViewArray<View>& x, int s,
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,
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
88 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
99 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
116 ViewSelNone(Space& home, const VarBranch<Var>& vb);
120
122
123 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
143 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
158 ViewSelRnd(Space& home, const VarBranch<Var>& vb);
162
164
165 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
184 virtual ViewSel<View>* copy(Space& home);
186 virtual bool notice(void) const;
188 virtual void dispose(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;
220 public:
222
223
228
230
231 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
250 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:
264 using ViewSelChoose<Choose,Merit>::c;
265 using ViewSelChoose<Choose,Merit>::m;
268 public:
270
271
276
278
279 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
291 virtual bool notice(void) const;
293 virtual void dispose(Space& home);
295 };
296
298 template<class Merit>
299 class ViewSelMin : public ViewSelChoose<ChooseMin,Merit> {
300 typedef typename ViewSelChoose<ChooseMin,Merit>::View View;
301 typedef typename ViewSelChoose<ChooseMin,Merit>::Var Var;
302 public:
304
305
306 ViewSelMin(Space& home, const VarBranch<Var>& vb);
310
312
313 virtual ViewSel<View>* copy(Space& home);
315 };
316
318 template<class Merit>
319 class ViewSelMinTbl : public ViewSelChooseTbl<ChooseMin,Merit> {
320 typedef typename ViewSelChooseTbl<ChooseMin,Merit>::View View;
321 typedef typename ViewSelChooseTbl<ChooseMin,Merit>::Var Var;
322 public:
324
325
326 ViewSelMinTbl(Space& home, const VarBranch<Var>& vb);
330
332
333 virtual ViewSel<View>* copy(Space& home);
335 };
336
338 template<class Merit>
339 class ViewSelMax : public ViewSelChoose<ChooseMax,Merit> {
340 typedef typename ViewSelChoose<ChooseMax,Merit>::View View;
341 typedef typename ViewSelChoose<ChooseMax,Merit>::Var Var;
342 public:
344
345
346 ViewSelMax(Space& home, const VarBranch<Var>& vb);
350
352
353 virtual ViewSel<View>* copy(Space& home);
355 };
356
358 template<class Merit>
359 class ViewSelMaxTbl : public ViewSelChooseTbl<ChooseMax,Merit> {
360 typedef typename ViewSelChooseTbl<ChooseMax,Merit>::View View;
361 typedef typename ViewSelChooseTbl<ChooseMax,Merit>::Var Var;
362 public:
364
365
366 ViewSelMaxTbl(Space& home, const VarBranch<Var>& vb);
370
372
373 virtual ViewSel<View>* copy(Space& home);
375 };
376
377
378
379 template<class View>
380 forceinline
382 template<class View>
383 forceinline
385 template<class View>
386 int
392 template<class View>
393 void
399 template<class View>
400 bool
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
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>
424 forceinline
426 : ViewSel<View>(home,vb) {}
427 template<class View>
428 forceinline
431 template<class View>
432 int
434 return s;
435 }
436 template<class View>
437 int
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>
483 forceinline
485 : ViewSel<View>(home,vb), r(vb.rnd()) {}
486 template<class View>
487 forceinline
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,f);
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 template<class View>
547 forceinline bool
549 return true;
550 }
551 template<class View>
552 forceinline void
554 r.~Rnd();
555 }
556
557
558 template<class Val>
559 forceinline bool
561 return a < b;
562 }
563 template<class Val>
564 forceinline bool
566 return a > b;
567 }
568
569
570 template<class Choose, class Merit>
571 forceinline
573 : ViewSel<View>(home,vb), m(home,vb) {}
574
575 template<class Choose, class Merit>
576 forceinline
580
581 template<class Choose, class Merit>
582 int
584 // Consider x[s] as the so-far best view
585 int b_i = s;
586 Val b_m = m(home,x[s],s);
587 // Scan all non-assigned views from s+1 onwards
588 for (int i=s+1; i<x.size(); i++)
589 if (!x[i].assigned()) {
590 Val mxi = m(home,x[i],i);
591 if (c(mxi,b_m)) {
592 b_i = i; b_m = mxi;
593 }
594 }
595 return b_i;
596 }
597
598 template<class Choose, class Merit>
599 int
602 // Consider x[s] as the so-far best view
603 int b_i = s;
604 Val b_m = m(home,x[s],s);
605 // Scan all non-assigned views from s+1 onwards
606 for (int i=s+1; i<x.size(); i++)
607 if (!x[i].assigned() && f(home,x[i],i)) {
608 Val mxi = m(home,x[i],i);
609 if (c(mxi,b_m)) {
610 b_i = i; b_m = mxi;
611 }
612 }
613 return b_i;
614 }
615
616 template<class Choose, class Merit>
617 void
619 int* ties, int& n) {
620 // Consider x[s] as the so-far best view and record as tie
621 Val b = m(home,x[s],s);
622 int j=0; ties[j++]=s;
623 for (int i=s+1; i<x.size(); i++)
624 if (!x[i].assigned()) {
625 Val mxi = m(home,x[i],i);
626 if (c(mxi,b)) {
627 // Found a better one, reset all ties and record
628 j=0; ties[j++]=i; b=mxi;
629 } else if (mxi == b) {
630 // Found a tie, record
631 ties[j++]=i;
632 }
633 }
634 n=j;
635 // There must be at least one tie, of course!
636 assert(n > 0);
637 }
638
639 template<class Choose, class Merit>
640 void
642 int* ties, int& n,
644 // Consider x[s] as the so-far best view and record as tie
645 Val b = m(home,x[s],s);
646 int j=0; ties[j++]=s;
647 for (int i=s+1; i<x.size(); i++)
648 if (!x[i].assigned() && f(home,x[i],i)) {
649 Val mxi = m(home,x[i],i);
650 if (c(mxi,b)) {
651 // Found a better one, reset all ties and record
652 j=0; ties[j++]=i; b=mxi;
653 } else if (mxi == b) {
654 // Found a tie, record
655 ties[j++]=i;
656 }
657 }
658 n=j;
659 // There must be at least one tie, of course!
660 assert(n > 0);
661 }
662
663 template<class Choose, class Merit>
664 void
666 int* ties, int& n) {
667 // Keep first tie in place
668 Val b = m(home,x[ties[0]],ties[0]);
669 int j=1;
670 // Scan remaining ties
671 for (int i=1; i<n; i++) {
672 Val mxi = m(home,x[ties[i]],ties[i]);
673 if (c(mxi,b)) {
674 // Found a better one, reset all ties
675 b=mxi; j=0; ties[j++]=ties[i];
676 } else if (mxi == b) {
677 // Found a tie and record it
678 ties[j++]=ties[i];
679 }
680 }
681 n=j;
682 // There must be at least one tie, of course!
683 assert(n > 0);
684 }
685
686 template<class Choose, class Merit>
687 int
689 int* ties, int n) {
690 int b_i = ties[0];
691 Val b_m = m(home,x[ties[0]],ties[0]);
692 for (int i=1; i<n; i++) {
693 Val mxi = m(home,x[ties[i]],ties[i]);
694 if (c(mxi,b_m)) {
695 b_i = ties[i]; b_m = mxi;
696 }
697 }
698 return b_i;
699 }
700
701 template<class Choose, class Merit>
702 bool
704 return m.notice();
705 }
706
707 template<class Choose, class Merit>
708 void
710 m.dispose(home);
711 }
712
713
714 template<class Choose, class Merit>
715 forceinline
717 const VarBranch<Var>& vb)
718 : ViewSelChoose<Choose,Merit>(home,vb), tbl(vb.tbl()) {
719 if (!tbl())
720 throw InvalidFunction("ViewSelChooseTbl::ViewSelChooseTbl");
721 }
722
723 template<class Choose, class Merit>
724 forceinline
729
730 template<class Choose, class Merit>
731 void
733 int* ties, int& n) {
734 // Find the worst and best merit value
735 Val w = m(home,x[s],s);
736 Val b = w;
737 for (int i=s+1; i<x.size(); i++)
738 if (!x[i].assigned()) {
739 Val mxi = m(home,x[i],i);
740 if (c(mxi,b))
741 b=mxi;
742 else if (c(w,mxi))
743 w=mxi;
744 }
745 // Compute tie-break limit
747 double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
748 // If the limit is not better than the worst merit, everything is a tie
749 if (!c(l,static_cast<double>(w))) {
750 int j=0;
751 for (int i=s; i<x.size(); i++)
752 if (!x[i].assigned())
753 ties[j++]=i;
754 n=j;
755 } else {
756 // The limit is not allowed to better than the best merit value
757 if (c(l,static_cast<double>(b)))
758 l = static_cast<double>(b);
759 // Record all ties that are not worse than the limit merit value
760 int j=0;
761 for (int i=s; i<x.size(); i++)
762 if (!x[i].assigned() && !c(l,static_cast<double>(m(home,x[i],i))))
763 ties[j++]=i;
764 n=j;
765 }
766 // There will be at least one tie (the best will qualify, of course)
767 assert(n > 0);
768 }
769
770 template<class Choose, class Merit>
771 void
773 int* ties, int& n,
775 // Find the worst and best merit value
776 assert(f(home,x[s],s));
777 Val w = m(home,x[s],s);
778 Val b = w;
779 for (int i=s+1; i<x.size(); i++)
780 if (!x[i].assigned() && f(home,x[i],i)) {
781 Val mxi = m(home,x[i],i);
782 if (c(mxi,b))
783 b=mxi;
784 else if (c(w,mxi))
785 w=mxi;
786 }
787 // Compute tie-break limit
789 double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
790 // If the limit is not better than the worst merit, everything is a tie
791 if (!c(l,static_cast<double>(w))) {
792 int j=0;
793 for (int i=s; i<x.size(); i++)
794 if (!x[i].assigned() && f(home,x[i],i))
795 ties[j++]=i;
796 n=j;
797 } else {
798 // The limit is not allowed to better than the best merit value
799 if (c(l,static_cast<double>(b)))
800 l = static_cast<double>(b);
801 // Record all ties that are not worse than the limit merit value
802 int j=0;
803 for (int i=s; i<x.size(); i++)
804 if (!x[i].assigned() && f(home,x[i],i) &&
805 !c(l,static_cast<double>(m(home,x[i],i))))
806 ties[j++]=i;
807 n=j;
808 }
809 // There will be at least one tie (the best will qualify, of course)
810 assert(n > 0);
811 }
812
813 template<class Choose, class Merit>
814 void
816 int* ties, int& n) {
817 // Find the worst and best merit value
818 Val w = m(home,x[ties[0]],ties[0]);
819 Val b = w;
820 for (int i=1; i<n; i++) {
821 Val mxi = m(home,x[ties[i]],ties[i]);
822 if (c(mxi,b))
823 b=mxi;
824 else if (c(w,mxi))
825 w=mxi;
826 }
827 // Compute tie-break limit
829 double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
830 // If the limit is not better than the worst merit, everything is a tie
831 // and no breaking is required
832 if (c(l,static_cast<double>(w))) {
833 // The limit is not allowed to better than the best merit value
834 if (c(l,static_cast<double>(b)))
835 l = static_cast<double>(b);
836 // Keep all ties that are not worse than the limit merit value
837 int j=0;
838 for (int i=0; i<n; i++)
839 if (!c(l,static_cast<double>(m(home,x[ties[i]],ties[i]))))
840 ties[j++]=ties[i];
841 n=j;
842 }
843 // There will be at least one tie (the best will qualify)
844 assert(n > 0);
845 }
846 template<class Choose, class Merit>
847 bool
849 return true;
850 }
851 template<class Choose, class Merit>
852 void
856
857
858
859 template<class Merit>
860 forceinline
863
864 template<class Merit>
865 forceinline
868
869 template<class Merit>
872 return new (home) ViewSelMin<Merit>(home,*this);
873 }
874
875
876 template<class Merit>
877 forceinline
880
881 template<class Merit>
882 forceinline
885
886 template<class Merit>
889 return new (home) ViewSelMinTbl<Merit>(home,*this);
890 }
891
892
893
894 template<class Merit>
895 forceinline
898
899 template<class Merit>
900 forceinline
903
904 template<class Merit>
907 return new (home) ViewSelMax<Merit>(home,*this);
908 }
909
910
911
912 template<class Merit>
913 forceinline
916
917 template<class Merit>
918 forceinline
921
922 template<class Merit>
925 return new (home) ViewSelMaxTbl<Merit>(home,*this);
926 }
927
928
929
930}
931
932// STATISTICS: kernel-branch
Class storing a branch filter function.
Definition filter.hpp:45
Class without a branch filter function.
Definition filter.hpp:68
Choose views with larger merit values.
Definition view-sel.hpp:201
bool operator()(Val a, Val b) const
Return true if a is better than b.
Definition view-sel.hpp:565
Choose views with smaller merit values.
Definition view-sel.hpp:193
bool operator()(Val a, Val b) const
Return true if a is better than b.
Definition view-sel.hpp:560
Exception: invalid function
Random number generator.
Definition rnd.hpp:42
Class for sharing data between spaces.
Computation spaces.
Definition core.hpp:1775
Variable branching information.
Definition var.hpp:55
View arrays.
Definition array.hpp:255
int size(void) const
Return size of array (number of elements).
Definition array.hpp:1156
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed).
Definition view-sel.hpp:848
ViewSelChoose< Choose, Merit >::View View
Definition view-sel.hpp:262
ViewSelChooseTbl(Space &home, ViewSelChooseTbl< Choose, Merit > &vs)
Constructor for copying during cloning.
Definition view-sel.hpp:726
ViewSelChoose< Choose, Merit >::Var Var
Definition view-sel.hpp:263
ViewSelChooseTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition view-sel.hpp:716
ViewSelChoose< Choose, Merit >::Val Val
Definition view-sel.hpp:261
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:815
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:732
SharedData< BranchTbl > tbl
Definition view-sel.hpp:267
virtual void dispose(Space &home)
Delete view selection.
Definition view-sel.hpp:853
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n, BrancherFilter< View > &f)
Select ties from x starting from s.
Definition view-sel.hpp:772
ViewSelChoose(Space &home, ViewSelChoose< Choose, Merit > &vs)
Constructor for copying during cloning.
Definition view-sel.hpp:577
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:665
ViewSelChoose(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition view-sel.hpp:572
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n, BrancherFilter< View > &f)
Select ties from x starting from s.
Definition view-sel.hpp:641
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed).
Definition view-sel.hpp:703
Merit::Val Val
Type of merit.
Definition view-sel.hpp:215
ViewSel< typenameMerit::View >::Var Var
Definition view-sel.hpp:212
virtual void dispose(Space &home)
Delete view selection.
Definition view-sel.hpp:709
virtual int select(Space &home, ViewArray< View > &x, int *ties, int n)
Select a view from x considering views with positions in ties.
Definition view-sel.hpp:688
virtual int select(Space &home, ViewArray< View > &x, int s, BrancherFilter< View > &f)
Select a view from x starting from s and return its position.
Definition view-sel.hpp:600
ViewSel< typenameMerit::View >::View View
Definition view-sel.hpp:213
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:618
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:583
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition view-sel.hpp:924
ViewSelMaxTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition view-sel.hpp:914
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition view-sel.hpp:906
ViewSelMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition view-sel.hpp:896
ViewSelMinTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition view-sel.hpp:878
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition view-sel.hpp:888
ViewSelMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition view-sel.hpp:861
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition view-sel.hpp:871
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
ViewSel< View >::Var Var
Definition view-sel.hpp:111
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
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
ViewSelNone(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition view-sel.hpp:425
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition view-sel.hpp:477
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
Rnd r
The random number generator used.
Definition view-sel.hpp:153
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition view-sel.hpp:543
ViewSel< View >::Var Var
Definition view-sel.hpp:151
ViewSelRnd(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition view-sel.hpp:484
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed).
Definition view-sel.hpp:548
virtual void dispose(Space &home)
Delete view selection.
Definition view-sel.hpp:553
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
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
Abstract class for view selection.
Definition view-sel.hpp:44
View::VarType Var
The corresponding variable type.
Definition view-sel.hpp:49
virtual ~ViewSel(void)
Unused destructor.
Definition view-sel.hpp:408
virtual ViewSel< View > * copy(Space &home)=0
Create copy during cloning.
virtual int select(Space &home, ViewArray< View > &x, int *ties, int n)=0
Select a view from x considering views with positions in ties.
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n, BrancherFilter< View > &f)=0
Select ties from x starting from s.
ViewSel(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition view-sel.hpp:381
virtual int select(Space &home, ViewArray< View > &x, int s, BrancherFilter< View > &f)=0
Select a view from x starting from s and return its position.
virtual void brk(Space &home, ViewArray< View > &x, int *ties, int &n)=0
Break ties in x and update to new ties.
virtual void dispose(Space &home)
Dispose view selection.
Definition view-sel.hpp:406
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n, BrancherNoFilter< View > &f)
Select ties from x starting from s.
Definition view-sel.hpp:394
View_ View
Define the view type.
Definition view-sel.hpp:47
virtual int select(Space &home, ViewArray< View > &x, int s, BrancherNoFilter< View > &f)
Select a view from x starting from s and return its position.
Definition view-sel.hpp:387
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed).
Definition view-sel.hpp:401
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)=0
Select ties from x starting from s.
virtual int select(Space &home, ViewArray< View > &x, int s)=0
Select a view from x starting from s and return its position.
ViewSel(Space &home, ViewSel< View > &vs)
Constructor for copying during cloning.
Definition view-sel.hpp:384
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Definition var.hpp:48
Gecode toplevel namespace
#define GECODE_NEVER
Assert that this command is never executed.
Definition macros.hpp:56
#define GECODE_VALID_FUNCTION(f)
Assert that a function is valid.
Definition macros.hpp:94