39namespace Gecode {
namespace Int {
namespace LDSB {
42 findVar(
int *indices,
unsigned int n_values,
unsigned int seq_size,
int index) {
45 for (
unsigned int i=0U ; i<n_values ; i++) {
46 if (indices[i] == index)
47 return std::pair<int,int>(seq,pos);
49 if (pos == seq_size) {
54 return std::pair<int,int>(-1,-1);
60 using namespace Int::LDSB;
64 for (
int i = 0 ; i < vars.
size() ; i++)
65 a[i] = vars[i].varimp();
70 for (
int i = 0 ; i < vars.
size() ; i++)
71 a[i] = vars[i].varimp();
77 for (
int i = 0 ; i < indices.
size() ; i++)
78 xs[i] =
x[indices[i]];
92 for (
int i = 0 ; i < vars.
size() ; i++)
93 a[i] = vars[i].varimp();
98 for (
int i = 0 ; i < vars.
size() ; i++)
99 a[i] = vars[i].varimp();
107 int n = (upper-lower+1)/2;
127namespace Gecode {
namespace Int {
namespace LDSB {
152 int* indices = home.
alloc<
int>(
n);
153 for (
int i = 0 ; i <
n ; i++) {
154 VariableMap::const_iterator index = variableMap.find(varref->
xs[i]);
155 if (index == variableMap.end())
157 indices[i] = index->second;
163 int *vs = home.
alloc<
int>(
n);
172 int n = varseqref->
nxs;
173 int* indices = home.
alloc<
int>(
n);
174 for (
int i = 0 ; i <
n ; i++) {
175 VariableMap::const_iterator index =
176 variableMap.find(varseqref->
xs[i]);
177 if (index == variableMap.end())
179 indices[i] = index->second;
186 int *vs = home.
alloc<
int>(
n);
187 for (
unsigned int i = 0 ; i <
n ; i++)
188 vs[i] = valseqref->
values[i];
209 int* indices = home.
alloc<
int>(
n);
210 for (
int i = 0 ; i <
n ; i++) {
211 VariableMap::const_iterator index = variableMap.find(varref->
xs[i]);
212 if (index == variableMap.end())
214 indices[i] = index->second;
220 int *vs = home.
alloc<
int>(
n);
229 int n = varseqref->
nxs;
230 int* indices = home.
alloc<
int>(
n);
231 for (
int i = 0 ; i <
n ; i++) {
232 VariableMap::const_iterator index =
233 variableMap.find(varseqref->
xs[i]);
234 if (index == variableMap.end())
236 indices[i] = index->second;
243 int *vs = home.
alloc<
int>(
n);
244 for (
unsigned int i = 0 ; i <
n ; i++)
245 vs[i] = valseqref->
values[i];
256 using namespace Int::LDSB;
265 if (home.
failed())
return;
289 for (
int i = 0 ; i <
x.size() ; i++)
290 variableMap[
x[i].varimp()] = i;
297 for (
int i = 0 ; i <
n ; i++) {
314 if (home.
failed())
return;
315 vars.
a.expand(home,
x);
319 vars.
b.expand(home,
x);
323 vars.
c.expand(home,
x);
327 vars.
d.expand(home,
x);
329 branch(home,
x,vars.
a,vals,syms,bf,vvp);
334 for (
int i = 0 ; i <
x.size() ; i++)
335 variableMap[
x[i].varimp()] = i;
342 for (
int i = 0 ; i <
n ; i++) {
429 if (home.
failed())
return;
439 for (
int i = 0 ; i <
x.size() ; i++)
440 variableMap[
x[i].varimp()] = i;
447 for (
int i = 0 ; i <
n ; i++) {
475 if (home.
failed())
return;
476 vars.
a.expand(home,
x);
480 vars.
b.expand(home,
x);
484 vars.
c.expand(home,
x);
488 vars.
d.expand(home,
x);
490 branch(home,
x,vars.
a,vals,syms,bf,vvp);
495 for (
int i = 0 ; i <
x.size() ; i++)
496 variableMap[
x[i].varimp()] = i;
503 for (
int i = 0 ; i <
n ; i++) {
529 postldsbbrancher<BoolView,2,int,2>(home,xv,vs,vsc,array,
n,bf,vvp);
535 postldsbbrancher<BoolView,3,int,2>(home,xv,vs,vsc,array,
n,bf,vvp);
541 postldsbbrancher<BoolView,4,int,2>(home,xv,vs,vsc,array,
n,bf,vvp);
int n
Number of negative literals for node type.
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
int size(void) const
Return size of array (number of elements)
Argument array for non-primitive types.
Which values to select for branching first.
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Select select(void) const
Return selection strategy.
Passing Boolean variables.
Which Boolean variable to select for branching.
void expand(Home home, const BoolVarArgs &x)
Expand decay factor into AFC or action.
@ SEL_RND
Random (uniform, for tie breaking)
@ SEL_NONE
First unassigned.
Home class for posting propagators
bool failed(void) const
Check whether corresponding space is failed.
Passing integer arguments.
Value iterator for integer sets.
unsigned int size(void) const
Return size (cardinality) of set.
Which values to select for branching first.
@ SEL_VALUES_MIN
Select all values starting from smallest.
@ SEL_SPLIT_MAX
Select values greater than mean of smallest and largest value.
@ SEL_RANGE_MAX
Select the largest range of the variable domain if it has several ranges, otherwise select values gre...
@ SEL_RANGE_MIN
Select the smallest range of the variable domain if it has several ranges, otherwise select values no...
@ SEL_VALUES_MAX
Select all values starting from largest.
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
@ SEL_SPLIT_MIN
Select values not greater than mean of smallest and largest value.
Select select(void) const
Return selection strategy.
Passing integer variables.
Which integer variable to select for branching.
void expand(Home home, const IntVarArgs &x)
Expand AFC, action, and CHB.
@ SEL_RND
Random (uniform, for tie breaking)
@ SEL_NONE
First unassigned.
Exception: Value selection incompatible with LDSB
Exception: Variable in symmetry not branched on
Implementation of a single symmetry.
Implementation of a value sequence symmetry.
Implementation of a value sequence symmetry at the modelling level.
IntArgs values
Array of values in symmetry.
int seq_size
Size of each sequence in symmetry.
Implementation of a value symmetry.
Implementation of a value symmetry at the modelling level.
IntSet values
Set of symmetric values.
Map from variable implementation to index.
Implementation of a variable sequence symmetry.
Implementation of a variable sequence symmetry at the modelling level.
int seq_size
Size of each sequence in symmetry.
int nxs
Number of variables in symmetry.
VarImpBase ** xs
Array of variables in symmetry.
Implementation of a variable symmetry.
Implementation of a variable symmetry at the modelling level.
int nxs
Number of variables in symmetry.
VarImpBase ** xs
Array of variables in symmetry.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
Collection of symmetries.
A reference-counted pointer to a SymmetryObject.
Int::LDSB::SymmetryObject * ref
Symmetry object that this handle refers to.
Combine variable selection criteria for tie-breaking.
VarBranch a
Branching criteria to try in order.
BranchCommit commit(void) const
Return commit function.
Base class for value selection and commit.
Abstract class for view selection.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
std::function< bool(const Space &home, IntVar x, int i)> IntBranchFilter
Branch filter function type for integer variables.
std::function< bool(const Space &home, BoolVar x, int i)> BoolBranchFilter
Branch filter function type for Boolean variables.
ViewSel< IntView > * viewsel(Space &home, const IntVarBranch &ivb)
Return view selectors for integer views.
ValSelCommitBase< IntView, int > * valselcommit(Space &home, const IntValBranch &ivb)
Return value and commit for integer views.
std::pair< int, int > findVar(int *indices, unsigned int n_values, unsigned int seq_size, int index)
Find the location of an integer in a collection of sequences.
SymmetryImp< BoolView > * createBoolSym(Space &home, const SymmetryHandle &s, VariableMap variableMap)
Create a boolean symmetry implementation from a symmetry handle.
void postldsbbrancher(Home home, ViewArray< View > &x, ViewSel< View > *vs[n], ValSelCommitBase< View, Val > *vsc, SymmetryImp< View > **syms, int nsyms, BranchFilter< typename View::VarType > bf, VarValPrint< typename View::VarType, Val > vvp)
Post LDSB brancher.
SymmetryImp< IntView > * createIntSym(Space &home, const SymmetryHandle &s, VariableMap variableMap)
Create an integer symmetry implementation from a symmetry handle.
Gecode toplevel namespace
SymmetryHandle ValueSymmetry(const IntArgs &v)
Values in v are interchangeable.
SymmetryHandle ValueSequenceSymmetry(const IntArgs &v, int ss)
Value sequences in v of size ss are interchangeable.
SymmetryHandle values_reflect(int lower, int upper)
The values from lower to upper (inclusive) can be reflected.
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
BoolVarBranch BOOL_VAR_NONE(void)
Select first unassigned variable.
std::function< void(const Space &home, const Brancher &b, unsigned int a, IntVar x, int i, const int &n, std::ostream &o)> IntVarValPrint
Function type for printing branching alternatives for integer variables.
SymmetryHandle VariableSymmetry(const IntVarArgs &x)
Variables in x are interchangeable.
SymmetryHandle VariableSequenceSymmetry(const IntVarArgs &x, int ss)
Variable sequences in x of size ss are interchangeable.
std::function< void(const Space &home, const Brancher &b, unsigned int a, BoolVar x, int i, const int &n, std::ostream &o)> BoolVarValPrint
Function type for printing branching alternatives for Boolean variables.
Post propagator for SetVar x
#define GECODE_NEVER
Assert that this command is never executed.