view-sel.hpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main author:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2012
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
namespace Gecode {
template<class _View>
class ViewSel {
public:
typedef _View View;
typedef typename View::VarType Var;
ViewSel(Space& home, const VarBranch<Var>& vb);
ViewSel(Space& home, ViewSel<View>& vs);
virtual int select(Space& home, ViewArray<View>& x, int s) = 0;
virtual int select(Space& home, ViewArray<View>& x, int s,
BrancherFilter<View>& f) = 0;
virtual int select(Space& home, ViewArray<View>& x, int s,
BrancherNoFilter<View>& f);
virtual void ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n) = 0;
virtual void ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n,
BrancherFilter<View>& f) = 0;
virtual void ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n,
BrancherNoFilter<View>& f);
virtual void brk(Space& home, ViewArray<View>& x,
int* ties, int& n) = 0;
virtual int select(Space& home, ViewArray<View>& x,
int* ties, int n) = 0;
virtual ViewSel<View>* copy(Space& home) = 0;
virtual bool notice(void) const;
virtual void dispose(Space& home);
virtual ~ViewSel(void);
static void* operator new(size_t s, Space& home);
static void operator delete(void* p, Space& home);
static void operator delete(void* p);
};
template<class View>
class ViewSelNone : public ViewSel<View> {
protected:
typedef typename ViewSel<View>::Var Var;
public:
ViewSelNone(Space& home, const VarBranch<Var>& vb);
ViewSelNone(Space& home, ViewSelNone<View>& vs);
virtual int select(Space& home, ViewArray<View>& x, int s);
virtual int select(Space& home, ViewArray<View>& x, int s,
BrancherFilter<View>& f);
virtual void ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n);
virtual void ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n,
BrancherFilter<View>& f);
virtual void brk(Space& home, ViewArray<View>& x,
int* ties, int& n);
virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
virtual ViewSel<View>* copy(Space& home);
};
template<class View>
class ViewSelRnd : public ViewSel<View> {
protected:
typedef typename ViewSel<View>::Var Var;
Rnd r;
public:
ViewSelRnd(Space& home, const VarBranch<Var>& vb);
ViewSelRnd(Space& home, ViewSelRnd<View>& vs);
virtual int select(Space& home, ViewArray<View>& x, int s);
virtual int select(Space& home, ViewArray<View>& x, int s,
BrancherFilter<View>& f);
virtual void ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n);
virtual void ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n,
BrancherFilter<View>& f);
virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
virtual ViewSel<View>* copy(Space& home);
};
class ChooseMin {
public:
template<class Val>
bool operator ()(Val a, Val b) const;
};
class ChooseMax {
public:
template<class Val>
bool operator ()(Val a, Val b) const;
};
template<class Choose, class Merit>
class ViewSelChoose : public ViewSel<typename Merit::View> {
protected:
typedef typename ViewSel<typename Merit::View>::Var Var;
typedef typename ViewSel<typename Merit::View>::View View;
typedef typename Merit::Val Val;
Choose c;
Merit m;
public:
ViewSelChoose(Space& home, const VarBranch<Var>& vb);
ViewSelChoose(Space& home, ViewSelChoose<Choose,Merit>& vs);
virtual int select(Space& home, ViewArray<View>& x, int s);
virtual int select(Space& home, ViewArray<View>& x, int s,
BrancherFilter<View>& f);
virtual void ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n);
virtual void ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n,
BrancherFilter<View>& f);
virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
virtual int select(Space& home, ViewArray<View>& x, int* ties, int n);
virtual bool notice(void) const;
virtual void dispose(Space& home);
};
template<class Choose, class Merit>
class ViewSelChooseTbl : public ViewSelChoose<Choose,Merit> {
protected:
typedef typename ViewSelChoose<Choose,Merit>::Val Val;
typedef typename ViewSelChoose<Choose,Merit>::View View;
typedef typename ViewSelChoose<Choose,Merit>::Var Var;
using ViewSelChoose<Choose,Merit>::c;
using ViewSelChoose<Choose,Merit>::m;
SharedData<BranchTbl> tbl;
public:
ViewSelChooseTbl(Space& home, const VarBranch<Var>& vb);
ViewSelChooseTbl(Space& home, ViewSelChooseTbl<Choose,Merit>& vs);
virtual void ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n);
virtual void ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n,
BrancherFilter<View>& f);
virtual void brk(Space& home, ViewArray<View>& x, int* ties, int& n);
virtual bool notice(void) const;
virtual void dispose(Space& home);
};
template<class Merit>
class ViewSelMin : public ViewSelChoose<ChooseMin,Merit> {
typedef typename ViewSelChoose<ChooseMin,Merit>::View View;
typedef typename ViewSelChoose<ChooseMin,Merit>::Var Var;
public:
ViewSelMin(Space& home, const VarBranch<Var>& vb);
ViewSelMin(Space& home, ViewSelMin<Merit>& vs);
virtual ViewSel<View>* copy(Space& home);
};
template<class Merit>
class ViewSelMinTbl : public ViewSelChooseTbl<ChooseMin,Merit> {
typedef typename ViewSelChooseTbl<ChooseMin,Merit>::View View;
typedef typename ViewSelChooseTbl<ChooseMin,Merit>::Var Var;
public:
ViewSelMinTbl(Space& home, const VarBranch<Var>& vb);
ViewSelMinTbl(Space& home, ViewSelMinTbl<Merit>& vs);
virtual ViewSel<View>* copy(Space& home);
};
template<class Merit>
class ViewSelMax : public ViewSelChoose<ChooseMax,Merit> {
typedef typename ViewSelChoose<ChooseMax,Merit>::View View;
typedef typename ViewSelChoose<ChooseMax,Merit>::Var Var;
public:
ViewSelMax(Space& home, const VarBranch<Var>& vb);
ViewSelMax(Space& home, ViewSelMax<Merit>& vs);
virtual ViewSel<View>* copy(Space& home);
};
template<class Merit>
class ViewSelMaxTbl : public ViewSelChooseTbl<ChooseMax,Merit> {
typedef typename ViewSelChooseTbl<ChooseMax,Merit>::View View;
typedef typename ViewSelChooseTbl<ChooseMax,Merit>::Var Var;
public:
ViewSelMaxTbl(Space& home, const VarBranch<Var>& vb);
ViewSelMaxTbl(Space& home, ViewSelMaxTbl<Merit>& vs);
virtual ViewSel<View>* copy(Space& home);
};
template<class View>
forceinline
ViewSel<View>::ViewSel(Space&, const VarBranch<Var>&) {}
template<class View>
forceinline
ViewSel<View>::ViewSel(Space&, ViewSel<View>&) {}
template<class View>
int
ViewSel<View>::select(Space&, ViewArray<View>&, int,
BrancherNoFilter<View>&) {
GECODE_NEVER;
return 0;
}
template<class View>
void
ViewSel<View>::ties(Space&, ViewArray<View>&, int,
int*, int&,
BrancherNoFilter<View>&) {
GECODE_NEVER;
}
template<class View>
bool
ViewSel<View>::notice(void) const {
return false;
}
template<class View>
void
ViewSel<View>::dispose(Space&) {}
template<class View>
ViewSel<View>::~ViewSel(void) {}
template<class View>
forceinline void
ViewSel<View>::operator delete(void*) {}
template<class View>
forceinline void
ViewSel<View>::operator delete(void*, Space&) {}
template<class View>
forceinline void*
ViewSel<View>::operator new(size_t s, Space& home) {
return home.ralloc(s);
}
template<class View>
forceinline
ViewSelNone<View>::ViewSelNone(Space& home, const VarBranch<Var>& vb)
: ViewSel<View>(home,vb) {}
template<class View>
forceinline
ViewSelNone<View>::ViewSelNone(Space& home, ViewSelNone<View>& vs)
: ViewSel<View>(home,vs) {}
template<class View>
int
ViewSelNone<View>::select(Space&, ViewArray<View>&, int s) {
return s;
}
template<class View>
int
ViewSelNone<View>::select(Space&, ViewArray<View>&, int s,
BrancherFilter<View>&) {
return s;
}
template<class View>
void
ViewSelNone<View>::ties(Space&, ViewArray<View>& x, int s,
int* ties, int& n) {
int j=0; ties[j++]=s;
for (int i=s+1; i<x.size(); i++)
if (!x[i].assigned())
ties[j++]=i;
n=j;
assert(n > 0);
}
template<class View>
void
ViewSelNone<View>::ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n,
BrancherFilter<View>& f) {
int j=0; ties[j++]=s;
for (int i=s+1; i<x.size(); i++)
if (!x[i].assigned() && f(home,x[i],i))
ties[j++]=i;
n=j;
assert(n > 0);
}
template<class View>
void
ViewSelNone<View>::brk(Space&, ViewArray<View>&, int*, int&) {
// Nothing needs to be done
}
template<class View>
int
ViewSelNone<View>::select(Space&, ViewArray<View>&, int* ties, int) {
return ties[0];
}
template<class View>
ViewSel<View>*
ViewSelNone<View>::copy(Space& home) {
return new (home) ViewSelNone<View>(home,*this);
}
template<class View>
forceinline
ViewSelRnd<View>::ViewSelRnd(Space& home, const VarBranch<Var>& vb)
: ViewSel<View>(home,vb), r(vb.rnd()) {}
template<class View>
forceinline
ViewSelRnd<View>::ViewSelRnd(Space& home, ViewSelRnd<View>& vs)
: ViewSel<View>(home,vs), r(vs.r) {}
template<class View>
int
ViewSelRnd<View>::select(Space&, ViewArray<View>& x, int s) {
unsigned int n=1;
int j=s;
for (int i=s+1; i<x.size(); i++)
if (!x[i].assigned()) {
n++;
if (r(n) == 0U)
j=i;
}
return j;
}
template<class View>
int
ViewSelRnd<View>::select(Space& home, ViewArray<View>& x, int s,
BrancherFilter<View>& f) {
unsigned int n=1;
int j=s;
for (int i=s+1; i<x.size(); i++)
if (!x[i].assigned() && f(home,x[i],i)) {
n++;
if (r(n) == 0U)
j=i;
}
return j;
}
template<class View>
void
ViewSelRnd<View>::ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n) {
n=1; ties[0] = select(home,x,s);
}
template<class View>
void
ViewSelRnd<View>::ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n,
BrancherFilter<View>&) {
n=1; ties[0] = select(home,x,s);
}
template<class View>
void
ViewSelRnd<View>::brk(Space&, ViewArray<View>&, int* ties, int& n) {
ties[0] = ties[static_cast<int>(r(static_cast<unsigned int>(n)))];
n=1;
}
template<class View>
int
ViewSelRnd<View>::select(Space&, ViewArray<View>&, int* ties, int n) {
return ties[static_cast<int>(r(static_cast<unsigned int>(n)))];
}
template<class View>
ViewSel<View>*
ViewSelRnd<View>::copy(Space& home) {
return new (home) ViewSelRnd<View>(home,*this);
}
template<class Val>
forceinline bool
ChooseMin::operator ()(Val a, Val b) const {
return a < b;
}
template<class Val>
forceinline bool
ChooseMax::operator ()(Val a, Val b) const {
return a > b;
}
template<class Choose, class Merit>
forceinline
ViewSelChoose<Choose,Merit>::ViewSelChoose(Space& home, const VarBranch<Var>& vb)
: ViewSel<View>(home,vb), m(home,vb) {}
template<class Choose, class Merit>
forceinline
ViewSelChoose<Choose,Merit>::ViewSelChoose(Space& home,
ViewSelChoose<Choose,Merit>& vs)
: ViewSel<View>(home,vs), m(home,vs.m) {}
template<class Choose, class Merit>
int
ViewSelChoose<Choose,Merit>::select(Space& home, ViewArray<View>& x, int s) {
// Consider x[s] as the so-far best view
int b_i = s;
Val b_m = m(home,x[s],s);
// Scan all non-assigned views from s+1 onwards
for (int i=s+1; i<x.size(); i++)
if (!x[i].assigned()) {
Val mxi = m(home,x[i],i);
if (c(mxi,b_m)) {
b_i = i; b_m = mxi;
}
}
return b_i;
}
template<class Choose, class Merit>
int
ViewSelChoose<Choose,Merit>::select(Space& home, ViewArray<View>& x, int s,
BrancherFilter<View>& f) {
// Consider x[s] as the so-far best view
int b_i = s;
Val b_m = m(home,x[s],s);
// Scan all non-assigned views from s+1 onwards
for (int i=s+1; i<x.size(); i++)
if (!x[i].assigned() && f(home,x[i],i)) {
Val mxi = m(home,x[i],i);
if (c(mxi,b_m)) {
b_i = i; b_m = mxi;
}
}
return b_i;
}
template<class Choose, class Merit>
void
ViewSelChoose<Choose,Merit>::ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n) {
// Consider x[s] as the so-far best view and record as tie
Val b = m(home,x[s],s);
int j=0; ties[j++]=s;
for (int i=s+1; i<x.size(); i++)
if (!x[i].assigned()) {
Val mxi = m(home,x[i],i);
if (c(mxi,b)) {
// Found a better one, reset all ties and record
j=0; ties[j++]=i; b=mxi;
} else if (mxi == b) {
// Found a tie, record
ties[j++]=i;
}
}
n=j;
// There must be at least one tie, of course!
assert(n > 0);
}
template<class Choose, class Merit>
void
ViewSelChoose<Choose,Merit>::ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n,
BrancherFilter<View>& f) {
// Consider x[s] as the so-far best view and record as tie
Val b = m(home,x[s],s);
int j=0; ties[j++]=s;
for (int i=s+1; i<x.size(); i++)
if (!x[i].assigned() && f(home,x[i],i)) {
Val mxi = m(home,x[i],i);
if (c(mxi,b)) {
// Found a better one, reset all ties and record
j=0; ties[j++]=i; b=mxi;
} else if (mxi == b) {
// Found a tie, record
ties[j++]=i;
}
}
n=j;
// There must be at least one tie, of course!
assert(n > 0);
}
template<class Choose, class Merit>
void
ViewSelChoose<Choose,Merit>::brk(Space& home, ViewArray<View>& x,
int* ties, int& n) {
// Keep first tie in place
Val b = m(home,x[ties[0]],ties[0]);
int j=1;
// Scan remaining ties
for (int i=1; i<n; i++) {
Val mxi = m(home,x[ties[i]],ties[i]);
if (c(mxi,b)) {
// Found a better one, reset all ties
b=mxi; j=0; ties[j++]=ties[i];
} else if (mxi == b) {
// Found a tie and record it
ties[j++]=ties[i];
}
}
n=j;
// There must be at least one tie, of course!
assert(n > 0);
}
template<class Choose, class Merit>
int
ViewSelChoose<Choose,Merit>::select(Space& home, ViewArray<View>& x,
int* ties, int n) {
int b_i = ties[0];
Val b_m = m(home,x[ties[0]],ties[0]);
for (int i=1; i<n; i++) {
Val mxi = m(home,x[ties[i]],ties[i]);
if (c(mxi,b_m)) {
b_i = ties[i]; b_m = mxi;
}
}
return b_i;
}
template<class Choose, class Merit>
bool
ViewSelChoose<Choose,Merit>::notice(void) const {
return m.notice();
}
template<class Choose, class Merit>
void
ViewSelChoose<Choose,Merit>::dispose(Space& home) {
m.dispose(home);
}
template<class Choose, class Merit>
forceinline
ViewSelChooseTbl<Choose,Merit>::ViewSelChooseTbl(Space& home,
const VarBranch<Var>& vb)
: ViewSelChoose<Choose,Merit>(home,vb), tbl(vb.tbl()) {
if (!tbl())
throw InvalidFunction("ViewSelChooseTbl::ViewSelChooseTbl");
}
template<class Choose, class Merit>
forceinline
ViewSelChooseTbl<Choose,Merit>::ViewSelChooseTbl
(Space& home, ViewSelChooseTbl<Choose,Merit>& vs)
: ViewSelChoose<Choose,Merit>(home,vs), tbl(vs.tbl) {
}
template<class Choose, class Merit>
void
ViewSelChooseTbl<Choose,Merit>::ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n) {
// Find the worst and best merit value
Val w = m(home,x[s],s);
Val b = w;
for (int i=s+1; i<x.size(); i++)
if (!x[i].assigned()) {
Val mxi = m(home,x[i],i);
if (c(mxi,b))
b=mxi;
else if (c(w,mxi))
w=mxi;
}
// Compute tie-break limit
GECODE_VALID_FUNCTION(tbl());
double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
// If the limit is not better than the worst merit, everything is a tie
if (!c(l,static_cast<double>(w))) {
int j=0;
for (int i=s; i<x.size(); i++)
if (!x[i].assigned())
ties[j++]=i;
n=j;
} else {
// The limit is not allowed to better than the best merit value
if (c(l,static_cast<double>(b)))
l = static_cast<double>(b);
// Record all ties that are not worse than the limit merit value
int j=0;
for (int i=s; i<x.size(); i++)
if (!x[i].assigned() && !c(l,static_cast<double>(m(home,x[i],i))))
ties[j++]=i;
n=j;
}
// There will be at least one tie (the best will qualify, of course)
assert(n > 0);
}
template<class Choose, class Merit>
void
ViewSelChooseTbl<Choose,Merit>::ties(Space& home, ViewArray<View>& x, int s,
int* ties, int& n,
BrancherFilter<View>& f) {
// Find the worst and best merit value
assert(f(home,x[s],s));
Val w = m(home,x[s],s);
Val b = w;
for (int i=s+1; i<x.size(); i++)
if (!x[i].assigned() && f(home,x[i],i)) {
Val mxi = m(home,x[i],i);
if (c(mxi,b))
b=mxi;
else if (c(w,mxi))
w=mxi;
}
// Compute tie-break limit
GECODE_VALID_FUNCTION(tbl());
double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
// If the limit is not better than the worst merit, everything is a tie
if (!c(l,static_cast<double>(w))) {
int j=0;
for (int i=s; i<x.size(); i++)
if (!x[i].assigned() && f(home,x[i],i))
ties[j++]=i;
n=j;
} else {
// The limit is not allowed to better than the best merit value
if (c(l,static_cast<double>(b)))
l = static_cast<double>(b);
// Record all ties that are not worse than the limit merit value
int j=0;
for (int i=s; i<x.size(); i++)
if (!x[i].assigned() && f(home,x[i],i) &&
!c(l,static_cast<double>(m(home,x[i],i))))
ties[j++]=i;
n=j;
}
// There will be at least one tie (the best will qualify, of course)
assert(n > 0);
}
template<class Choose, class Merit>
void
ViewSelChooseTbl<Choose,Merit>::brk(Space& home, ViewArray<View>& x,
int* ties, int& n) {
// Find the worst and best merit value
Val w = m(home,x[ties[0]],ties[0]);
Val b = w;
for (int i=1; i<n; i++) {
Val mxi = m(home,x[ties[i]],ties[i]);
if (c(mxi,b))
b=mxi;
else if (c(w,mxi))
w=mxi;
}
// Compute tie-break limit
GECODE_VALID_FUNCTION(tbl());
double l = tbl()(home,static_cast<double>(w),static_cast<double>(b));
// If the limit is not better than the worst merit, everything is a tie
// and no breaking is required
if (c(l,static_cast<double>(w))) {
// The limit is not allowed to better than the best merit value
if (c(l,static_cast<double>(b)))
l = static_cast<double>(b);
// Keep all ties that are not worse than the limit merit value
int j=0;
for (int i=0; i<n; i++)
if (!c(l,static_cast<double>(m(home,x[ties[i]],ties[i]))))
ties[j++]=ties[i];
n=j;
}
// There will be at least one tie (the best will qualify)
assert(n > 0);
}
template<class Choose, class Merit>
bool
ViewSelChooseTbl<Choose,Merit>::notice(void) const {
return true;
}
template<class Choose, class Merit>
void
ViewSelChooseTbl<Choose,Merit>::dispose(Space&) {
tbl.~SharedData<BranchTbl>();
}
template<class Merit>
forceinline
ViewSelMin<Merit>::ViewSelMin(Space& home, const VarBranch<Var>& vb)
: ViewSelChoose<ChooseMin,Merit>(home,vb) {}
template<class Merit>
forceinline
ViewSelMin<Merit>::ViewSelMin(Space& home, ViewSelMin<Merit>& vs)
: ViewSelChoose<ChooseMin,Merit>(home,vs) {}
template<class Merit>
ViewSel<typename ViewSelMin<Merit>::View>*
ViewSelMin<Merit>::copy(Space& home) {
return new (home) ViewSelMin<Merit>(home,*this);
}
template<class Merit>
forceinline
ViewSelMinTbl<Merit>::ViewSelMinTbl(Space& home, const VarBranch<Var>& vb)
: ViewSelChooseTbl<ChooseMin,Merit>(home,vb) {}
template<class Merit>
forceinline
ViewSelMinTbl<Merit>::ViewSelMinTbl(Space& home, ViewSelMinTbl<Merit>& vs)
: ViewSelChooseTbl<ChooseMin,Merit>(home,vs) {}
template<class Merit>
ViewSel<typename ViewSelMinTbl<Merit>::View>*
ViewSelMinTbl<Merit>::copy(Space& home) {
return new (home) ViewSelMinTbl<Merit>(home,*this);
}
template<class Merit>
forceinline
ViewSelMax<Merit>::ViewSelMax(Space& home, const VarBranch<Var>& vb)
: ViewSelChoose<ChooseMax,Merit>(home,vb) {}
template<class Merit>
forceinline
ViewSelMax<Merit>::ViewSelMax(Space& home, ViewSelMax<Merit>& vs)
: ViewSelChoose<ChooseMax,Merit>(home,vs) {}
template<class Merit>
ViewSel<typename ViewSelMax<Merit>::View>*
ViewSelMax<Merit>::copy(Space& home) {
return new (home) ViewSelMax<Merit>(home,*this);
}
template<class Merit>
forceinline
ViewSelMaxTbl<Merit>::ViewSelMaxTbl(Space& home, const VarBranch<Var>& vb)
: ViewSelChooseTbl<ChooseMax,Merit>(home,vb) {}
template<class Merit>
forceinline
ViewSelMaxTbl<Merit>::ViewSelMaxTbl(Space& home, ViewSelMaxTbl<Merit>& vs)
: ViewSelChooseTbl<ChooseMax,Merit>(home,vs) {}
template<class Merit>
ViewSel<typename ViewSelMaxTbl<Merit>::View>*
ViewSelMaxTbl<Merit>::copy(Space& home) {
return new (home) ViewSelMaxTbl<Merit>(home,*this);
}
}
// STATISTICS: kernel-branch
Gecode::Merit
Gecode::BrancherFilter
Class storing a branch filter function.
Definition filter.hpp:45
Gecode::BrancherNoFilter
Class withot a branch filter function.
Definition filter.hpp:68
Gecode::ChooseMax
Choose views with larger merit values.
Definition view-sel.hpp:197
Gecode::ChooseMax::operator()
bool operator()(Val a, Val b) const
Return true if a is better than b.
Definition view-sel.hpp:551
Gecode::ChooseMin
Choose views with smaller merit values.
Definition view-sel.hpp:189
Gecode::ChooseMin::operator()
bool operator()(Val a, Val b) const
Return true if a is better than b.
Definition view-sel.hpp:546
Gecode::InvalidFunction
Exception: invalid function
Definition exception.hpp:114
Gecode::Rnd
Random number generator.
Definition rnd.hpp:42
Gecode::SharedData
Class for sharing data between spaces.
Definition shared-data.hpp:38
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::Val
Gecode::VarBranch
Variable branching information.
Definition var.hpp:55
Gecode::ViewArray
View arrays.
Definition array.hpp:253
Gecode::ViewArray::size
int size(void) const
Return size of array (number of elements).
Definition array.hpp:1156
Gecode::ViewSelChooseTbl::notice
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed).
Definition view-sel.hpp:834
Gecode::ViewSelChooseTbl::View
ViewSelChoose< Choose, Merit >::View View
Definition view-sel.hpp:258
Gecode::ViewSelChooseTbl::ViewSelChooseTbl
ViewSelChooseTbl(Space &home, ViewSelChooseTbl< Choose, Merit > &vs)
Constructor for copying during cloning.
Definition view-sel.hpp:712
Gecode::ViewSelChooseTbl::Var
ViewSelChoose< Choose, Merit >::Var Var
Definition view-sel.hpp:259
Gecode::ViewSelChooseTbl::ViewSelChooseTbl
ViewSelChooseTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition view-sel.hpp:702
Gecode::ViewSelChooseTbl::Val
ViewSelChoose< Choose, Merit >::Val Val
Definition view-sel.hpp:257
Gecode::ViewSelChooseTbl::brk
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
Gecode::ViewSelChooseTbl::ties
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
Gecode::View::tbl
SharedData< BranchTbl > tbl
Definition view-sel.hpp:263
Gecode::ViewSelChooseTbl::dispose
virtual void dispose(Space &home)
Delete view selection.
Definition view-sel.hpp:839
Gecode::ViewSelChooseTbl::ties
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:758
Gecode::ViewSelChoose::ViewSelChoose
ViewSelChoose(Space &home, ViewSelChoose< Choose, Merit > &vs)
Constructor for copying during cloning.
Definition view-sel.hpp:563
Gecode::ViewSelChoose::brk
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
Gecode::ViewSelChoose::ViewSelChoose
ViewSelChoose(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition view-sel.hpp:558
Gecode::ViewSelChoose::ties
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:627
Gecode::ViewSelChoose::notice
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed).
Definition view-sel.hpp:689
Gecode::ViewSelChoose::Val
Merit::Val Val
Type of merit.
Definition view-sel.hpp:211
Gecode::ViewSelChoose::Var
ViewSel< typenameMerit::View >::Var Var
Definition view-sel.hpp:208
Gecode::Val::c
Choose c
Definition view-sel.hpp:213
Gecode::ViewSelChoose::dispose
virtual void dispose(Space &home)
Delete view selection.
Definition view-sel.hpp:695
Gecode::Val::m
Merit m
Definition view-sel.hpp:215
Gecode::ViewSelChoose::select
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:674
Gecode::ViewSelChoose::select
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:586
Gecode::ViewSelChoose::View
ViewSel< typenameMerit::View >::View View
Definition view-sel.hpp:209
Gecode::ViewSelChoose::ties
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
Gecode::ViewSelChoose::select
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
Gecode::ViewSelMaxTbl::copy
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition view-sel.hpp:910
Gecode::ViewSelMaxTbl::ViewSelMaxTbl
ViewSelMaxTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition view-sel.hpp:900
Gecode::ViewSelMax::copy
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition view-sel.hpp:892
Gecode::ViewSelMax::ViewSelMax
ViewSelMax(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition view-sel.hpp:882
Gecode::ViewSelMinTbl::ViewSelMinTbl
ViewSelMinTbl(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition view-sel.hpp:864
Gecode::ViewSelMinTbl::copy
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition view-sel.hpp:874
Gecode::ViewSelMin::ViewSelMin
ViewSelMin(Space &home, const VarBranch< Var > &vb)
Constructor for initialization.
Definition view-sel.hpp:847
Gecode::ViewSelMin::copy
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition view-sel.hpp:857
Gecode::ViewSelNone::ties
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
Gecode::ViewSelNone::Var
ViewSel< View >::Var Var
Definition view-sel.hpp:111
Gecode::ViewSelNone::brk
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
Gecode::ViewSelNone::select
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
Gecode::ViewSelNone::ViewSelNone
ViewSelNone(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition view-sel.hpp:421
Gecode::ViewSelNone::copy
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition view-sel.hpp:473
Gecode::ViewSelRnd::ties
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
Gecode::ViewSelRnd::r
Rnd r
The random number generator used.
Definition view-sel.hpp:153
Gecode::ViewSelRnd::copy
virtual ViewSel< View > * copy(Space &home)
Create copy during cloning.
Definition view-sel.hpp:539
Gecode::ViewSelRnd::Var
ViewSel< View >::Var Var
Definition view-sel.hpp:151
Gecode::ViewSelRnd::ViewSelRnd
ViewSelRnd(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition view-sel.hpp:480
Gecode::ViewSelRnd::select
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
Gecode::ViewSelRnd::brk
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
Gecode::ViewSel
Abstract class for view selection.
Definition view-sel.hpp:44
Gecode::ViewSel::View
_View View
Define the view type.
Definition view-sel.hpp:47
Gecode::ViewSel::ties
virtual void ties(Space &home, ViewArray< View > &x, int s, int *ties, int &n)=0
Select ties from x starting from s.
Gecode::ViewSel::~ViewSel
virtual ~ViewSel(void)
Unused destructor.
Definition view-sel.hpp:404
Gecode::ViewSel::brk
virtual void brk(Space &home, ViewArray< View > &x, int *ties, int &n)=0
Break ties in x and update to new ties.
Gecode::ViewSel::ViewSel
ViewSel(Space &home, const VarBranch< Var > &vb)
Constructor for creation.
Definition view-sel.hpp:377
Gecode::ViewSel::Var
View::VarType Var
The corresponding variable type.
Definition view-sel.hpp:49
Gecode::ViewSel::select
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.
Gecode::ViewSel::dispose
virtual void dispose(Space &home)
Dispose view selection.
Definition view-sel.hpp:402
Gecode::ViewSel::ties
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:390
Gecode::ViewSel::select
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:383
Gecode::ViewSel::copy
virtual ViewSel< View > * copy(Space &home)=0
Create copy during cloning.
Gecode::ViewSel::notice
virtual bool notice(void) const
Whether dispose must always be called (that is, notice is needed).
Definition view-sel.hpp:397
Gecode::ViewSel::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.
Gecode::ViewSel::select
virtual int select(Space &home, ViewArray< View > &x, int s)=0
Select a view from x starting from s and return its position.
Gecode::ViewSel::select
virtual int select(Space &home, ViewArray< View > &x, int *ties, int n)=0
Select a view from x considering views with positions in ties.
Gecode::ViewSel::ViewSel
ViewSel(Space &home, ViewSel< View > &vs)
Constructor for copying during cloning.
Definition view-sel.hpp:380
Gecode::BranchTbl
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Definition var.hpp:48
Gecode
Gecode toplevel namespace
forceinline
#define forceinline
Definition config.hpp:187
GECODE_NEVER
#define GECODE_NEVER
Assert that this command is never executed.
Definition macros.hpp:56
GECODE_VALID_FUNCTION
#define GECODE_VALID_FUNCTION(f)
Assert that a function is valid.
Definition macros.hpp:94