44 return Gecode::IntArgs({0,0,3,4, 0,0,2,1, 3,2,0,4, 4,1,4,0});
59 "MinDistance::"+
str(n)+
"::"+
str(f)+
"::"+
str(
r)+
"::"+
74 int first = a[
alias == 1 && i == 1 ? 0 : i];
75 int second = a[
alias == 1 && j == 1 ? 0 : j];
76 int distance = m[first*4+second];
80 minimum = std::min(minimum,distance);
90 IntDistance(4,[m](
int i,
int j) {
return m[i*4+j]; }) :
95 x[i] = a[
alias == 1 && i == 1 ? 0 : i];
102 for (
int i=0; i<
r.size(); i++)
117 Model(
int n,
int sites,
int lower,
int upper,
119 std::function<
int(
int,
int)> distance)
120 :
x(*this,n,0,sites-1),
z(*this,lower,upper) {
125 x.update(*
this,s.
x);
z.update(*
this,s.
z);
143 Model forward(2,4,2,4,kind,level,
144 [](
int a,
int b) {
return std::abs(a-b); });
147 (forward.x[1].min() != 2) || (forward.z.max() != 3))
149 std::unique_ptr<Model> clone(
static_cast<Model*
>(forward.clone()));
151 if ((clone->status() ==
SS_FAILED) || !clone->z.assigned() ||
152 (clone->z.val() != 2) || forward.z.assigned())
157 auto conflicts = [](
int a,
int b) {
158 return a == b ? 0 : (a/2 == b/2 ? 1 : 3);
170 std::weak_ptr<int> lifetime;
171 std::unique_ptr<Model> clone;
173 auto data = std::make_shared<int>(1);
176 [data](
int a,
int b) {
return a == b ? 0 : *data; });
179 dom(original,original.x,0,2);
182 clone.reset(
static_cast<Model*
>(original.clone()));
184 if (lifetime.expired() || (clone->status() ==
SS_FAILED))
187 if (!lifetime.expired())
209 IntDistance invalid(2,std::function<
int(
int,
int)>());
213 IntDistance invalid(2,[](
int,
int) {
return -1; });
219 [](
int a,
int b) {
return std::abs(a-b); });
234 {Gecode::MDP_DECOMPOSED,Gecode::MDP_SINGLE};
238 for (
bool computed : {
false,
true})
239 for (
bool requirements : {
false,
true})
242 (void)
new Minimum(n,computed,requirements,0,kind,level);
245 (void)
new Minimum(3,
true,
true,1,kind,level);
248 (void)
new Minimum(3,
true,
false,2,kind,level);
Passing integer arguments.
Shared distances between indexed sites.
Passing integer variables.
int max(void) const
Return maximum of domain.
Exception: Illegal operation passed as argument
Exception: Value out of limits
Exception: Too few arguments available in argument array
Exception: invalid function
Base(std::string s)
Create and register a standard test with name s.
Base class for assignments
Matrix and callback validation.
virtual bool run(void)
Run test.
Register the compact semantic matrix.
Exhaustive assignments and incremental clone/prune checks.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &a)
Post constraint.
virtual bool solution(const Assignment &a) const
Check for solution.
Gecode::MinDistancePropKind kind
Minimum(int n, bool f, bool r, int a, Gecode::MinDistancePropKind k, Gecode::IntPropLevel level)
Small space for direct propagation checks.
virtual Gecode::Space * copy(void)
Copying member function.
Model(int n, int sites, int lower, int upper, Gecode::MinDistancePropKind kind, Gecode::IntPropLevel level, std::function< int(int, int)> distance)
Domain filtering, matching strength, and callback lifetime.
virtual bool run(void)
Run test.
static std::string str(bool b)
Map bool to string.
Gecode::IntPropLevel ipl
Propagation level.
ConTestLevel contest
Whether to test for certain consistency.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
IntPropLevel
Propagation levels for integer propagators.
@ IPL_BASIC
Use basic propagation algorithm.
@ IPL_ADVANCED
Use advanced propagation algorithm.
Space(void)
Default constructor.
SpaceStatus status(StatusStatistics &stat)
Query space status.
@ SS_FAILED
Space is failed
Gecode toplevel namespace
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
void minimum_distance(Home home, const IntVarArgs &x, IntVar z, const IntDistance &d, IntPropLevel ipl=IPL_DEF, MinDistancePropKind kind=MDP_SINGLE)
Post .
MinDistancePropKind
Organization of forward-bound minimum-distance propagation.
Gecode::IntArgs matrix(void)
Distances with both a zero off-diagonal pair and threshold boundaries.
Testing finite domain integers.
@ CTL_NONE
No consistency-test.
@ check
Basic integrity tests.