Skip to content

Commit 0d484a7

Browse files
committed
Allow to specify which ipl is used for different constraints in mini model
1 parent b9aa71a commit 0d484a7

File tree

12 files changed

+7488
-7011
lines changed

12 files changed

+7488
-7011
lines changed

Makefile.dep

Lines changed: 6934 additions & 6823 deletions
Large diffs are not rendered by default.

Makefile.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,12 @@ MMSRC0 = \
641641
int-expr.cpp int-rel.cpp int-arith.cpp bool-expr.cpp \
642642
set-expr.cpp set-rel.cpp dom.cpp \
643643
float-expr.cpp float-rel.cpp float-arith.cpp \
644-
reg.cpp optimize.cpp exception.cpp
644+
reg.cpp optimize.cpp exception.cpp ipl.cpp
645645
MMHDR0 = \
646646
int-rel.hpp float-rel.hpp exception.hpp matrix.hpp \
647647
bool-expr.hpp set-expr.hpp set-rel.hpp \
648-
optimize.hpp reg.hpp ldsb.hpp channel.hpp aliases.hpp
648+
optimize.hpp reg.hpp ldsb.hpp channel.hpp aliases.hpp \
649+
ipl.hpp
649650

650651
MMSRC = $(MMSRC0:%=gecode/minimodel/%)
651652
MMHDR = gecode/minimodel.hh $(MMHDR0:%=gecode/minimodel/%)

gecode/minimodel.hh

100644100755
Lines changed: 125 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,112 @@ namespace Gecode {
9595

9696
#include <gecode/minimodel/exception.hpp>
9797

98+
namespace Gecode {
99+
100+
/// Class for specifying integer propagation levels used by minimodel
101+
class IntPropLevels {
102+
protected:
103+
IntPropLevel _linear2; ///< For binary linear
104+
IntPropLevel _linear; ///< For n-ary linear
105+
IntPropLevel _abs; ///< For absolute value
106+
IntPropLevel _max2; ///< For binary maximum
107+
IntPropLevel _max; ///< For n-ary maximum
108+
IntPropLevel _min2; ///< For binary minimum
109+
IntPropLevel _min; ///< For minimum
110+
IntPropLevel _mult; ///< For multiplication
111+
IntPropLevel _div; ///< For division
112+
IntPropLevel _mod; ///< For modulo
113+
IntPropLevel _sqr; ///< For square
114+
IntPropLevel _sqrt; ///< For square root
115+
IntPropLevel _pow; ///< For power
116+
IntPropLevel _nroot; ///< For root
117+
IntPropLevel _element; ///< For element
118+
IntPropLevel _ite; ///< For if-then-else
119+
public:
120+
/// Initialize with default propagation level
121+
IntPropLevels(IntPropLevel ipl=IPL_DEF);
122+
123+
/// Return integer propagation level for binary linear constraints
124+
IntPropLevel linear2(void) const;
125+
/// Set integer propagation level for binary linear constraints
126+
IntPropLevels& linear2(IntPropLevel ipl);
127+
/// Return integer propagation level for non-binary linear constraints
128+
IntPropLevel linear(void) const;
129+
/// Set integer propagation level for non-binary linear constraints
130+
IntPropLevels& linear(IntPropLevel ipl);
131+
132+
/// Return integer propagation level for absolute value constraints
133+
IntPropLevel abs(void) const;
134+
/// Set integer propagation level for absolute value constraints
135+
IntPropLevels& abs(IntPropLevel ipl);
136+
137+
/// Return integer propagation level for binary maximum constraints
138+
IntPropLevel max2(void) const;
139+
/// Set integer propagation level for binary maximum constraints
140+
IntPropLevels& max2(IntPropLevel ipl);
141+
/// Return integer propagation level for non-binary maximum constraints
142+
IntPropLevel max(void) const;
143+
/// Set integer propagation level for non-binary maximum constraints
144+
IntPropLevels& max(IntPropLevel ipl);
145+
/// Return integer propagation level for binary minimum constraints
146+
IntPropLevel min2(void) const;
147+
/// Set integer propagation level for binary minimum constraints
148+
IntPropLevels& min2(IntPropLevel ipl);
149+
/// Return integer propagation level for non-binary minimum constraints
150+
IntPropLevel min(void) const;
151+
/// Set integer propagation level for non-binary minimum constraints
152+
IntPropLevels& min(IntPropLevel ipl);
153+
154+
/// Return integer propagation level for multiplication constraints
155+
IntPropLevel mult(void) const;
156+
/// Set integer propagation level for multiplication constraints
157+
IntPropLevels& mult(IntPropLevel ipl);
158+
/// Return integer propagation level for division constraints
159+
IntPropLevel div(void) const;
160+
/// Set integer propagation level for division constraints
161+
IntPropLevels& div(IntPropLevel ipl);
162+
/// Return integer propagation level for modulo constraints
163+
IntPropLevel mod(void) const;
164+
/// Set integer propagation level for modulo constraints
165+
IntPropLevels& mod(IntPropLevel ipl);
166+
167+
/// Return integer propagation level for square constraints
168+
IntPropLevel sqr(void) const;
169+
/// Set integer propagation level for square constraints
170+
IntPropLevels& sqr(IntPropLevel ipl);
171+
/// Return integer propagation level for square root constraints
172+
IntPropLevel sqrt(void) const;
173+
/// Set integer propagation level for square root constraints
174+
IntPropLevels& sqrt(IntPropLevel ipl);
175+
176+
/// Return integer propagation level for power constraints
177+
IntPropLevel pow(void) const;
178+
/// Set integer propagation level for power constraints
179+
IntPropLevels& pow(IntPropLevel ipl);
180+
/// Return integer propagation level for root constraints
181+
IntPropLevel nroot(void) const;
182+
/// Set integer propagation level for root constraints
183+
IntPropLevels& nroot(IntPropLevel ipl);
184+
185+
/// Return integer propagation level for element constraints
186+
IntPropLevel element(void) const;
187+
/// Set integer propagation level for element constraints
188+
IntPropLevels& element(IntPropLevel ipl);
189+
190+
/// Return integer propagation level for if-then-else constraints
191+
IntPropLevel ite(void) const;
192+
/// Set integer propagation level for if-then-else constraints
193+
IntPropLevels& ite(IntPropLevel ipl);
194+
195+
/// Default propagation levels for all constraints
196+
GECODE_MINIMODEL_EXPORT
197+
static IntPropLevels def;
198+
};
199+
200+
}
201+
202+
#include <gecode/minimodel/ipl.hpp>
203+
98204
namespace Gecode {
99205

100206
class LinIntRel;
@@ -109,13 +215,14 @@ namespace Gecode {
109215
class NonLinIntExpr {
110216
public:
111217
/// Return variable constrained to be equal to the expression
112-
virtual IntVar post(Home home, IntVar* ret, IntPropLevel ipl) const = 0;
218+
virtual IntVar post(Home home, IntVar* ret,
219+
const IntPropLevels& ipls) const = 0;
113220
/// Post expression to be in relation \a irt with \a c
114221
virtual void post(Home home, IntRelType irt, int c,
115-
IntPropLevel ipl) const = 0;
222+
const IntPropLevels& ipls) const = 0;
116223
/// Post reified expression to be in relation \a irt with \a c
117224
virtual void post(Home home, IntRelType irt, int c,
118-
BoolVar b, IntPropLevel ipl) const = 0;
225+
BoolVar b, const IntPropLevels& ipls) const = 0;
119226
/// Destructor
120227
virtual ~NonLinIntExpr(void) {}
121228
/// Return fresh variable if \a x is NULL, \a x otherwise
@@ -208,14 +315,14 @@ namespace Gecode {
208315
const LinIntExpr& operator =(const LinIntExpr& e);
209316
/// Post propagator
210317
GECODE_MINIMODEL_EXPORT
211-
void post(Home home, IntRelType irt, IntPropLevel ipl) const;
318+
void post(Home home, IntRelType irt, const IntPropLevels& ipls) const;
212319
/// Post reified propagator
213320
GECODE_MINIMODEL_EXPORT
214321
void post(Home home, IntRelType irt, const BoolVar& b,
215-
IntPropLevel ipl) const;
322+
const IntPropLevels& ipls) const;
216323
/// Post propagator and return variable for value
217324
GECODE_MINIMODEL_EXPORT
218-
IntVar post(Home home, IntPropLevel ipl) const;
325+
IntVar post(Home home, const IntPropLevels& ipls) const;
219326
/// Return non-linear expression inside, or NULL if not non-linear
220327
GECODE_MINIMODEL_EXPORT
221328
NonLinIntExpr* nle(void) const;
@@ -246,9 +353,9 @@ namespace Gecode {
246353
/// Create linear relation for integer \a l and expression \a r
247354
LinIntRel(int l, IntRelType irt, const LinIntExpr& r);
248355
/// Post propagator for relation (if \a t is false for negated relation)
249-
void post(Home home, bool t, IntPropLevel ipl) const;
356+
void post(Home home, bool t, const IntPropLevels& ipls) const;
250357
/// Post reified propagator for relation (if \a t is false for negated relation)
251-
void post(Home home, const BoolVar& b, bool t, IntPropLevel ipl) const;
358+
void post(Home home, const BoolVar& b, bool t, const IntPropLevels& ipls) const;
252359
};
253360

254361
/**
@@ -1246,7 +1353,7 @@ namespace Gecode {
12461353
* \a ipl.
12471354
*/
12481355
virtual void post(Home home, BoolVar b, bool neg,
1249-
IntPropLevel ipl) = 0;
1356+
const IntPropLevels& ipls) = 0;
12501357
/// Destructor
12511358
virtual GECODE_MINIMODEL_EXPORT ~Misc(void);
12521359
};
@@ -1292,10 +1399,10 @@ namespace Gecode {
12921399
explicit BoolExpr(Misc* m);
12931400
/// Post propagators for expression
12941401
GECODE_MINIMODEL_EXPORT
1295-
BoolVar expr(Home home, IntPropLevel ipl) const;
1402+
BoolVar expr(Home home, const IntPropLevels& ipls) const;
12961403
/// Post propagators for relation
12971404
GECODE_MINIMODEL_EXPORT
1298-
void rel(Home home, IntPropLevel ipl) const;
1405+
void rel(Home home, const IntPropLevels& ipls) const;
12991406
/// Assignment operator
13001407
GECODE_MINIMODEL_EXPORT
13011408
const BoolExpr& operator =(const BoolExpr& e);
@@ -1477,7 +1584,8 @@ namespace Gecode {
14771584
//@{
14781585
/// Post linear expression and return its value
14791586
GECODE_MINIMODEL_EXPORT IntVar
1480-
expr(Home home, const LinIntExpr& e, IntPropLevel ipl=IPL_DEF);
1587+
expr(Home home, const LinIntExpr& e,
1588+
const IntPropLevels& ipls=IntPropLevels::def);
14811589
#ifdef GECODE_HAS_FLOAT_VARS
14821590
/// Post float expression and return its value
14831591
GECODE_MINIMODEL_EXPORT FloatVar
@@ -1490,10 +1598,12 @@ namespace Gecode {
14901598
#endif
14911599
/// Post Boolean expression and return its value
14921600
GECODE_MINIMODEL_EXPORT BoolVar
1493-
expr(Home home, const BoolExpr& e, IntPropLevel ipl=IPL_DEF);
1601+
expr(Home home, const BoolExpr& e,
1602+
const IntPropLevels& ipls=IntPropLevels::def);
14941603
/// Post Boolean relation
14951604
GECODE_MINIMODEL_EXPORT void
1496-
rel(Home home, const BoolExpr& e, IntPropLevel ipl=IPL_DEF);
1605+
rel(Home home, const BoolExpr& e,
1606+
const IntPropLevels& ipls=IntPropLevels::def);
14971607
//@}
14981608

14991609
}
@@ -2178,7 +2288,7 @@ namespace Gecode {
21782288
* \relates Gecode::Matrix
21792289
*/
21802290
void element(Home home, const Matrix<BoolVarArgs>& m, IntVar x, IntVar y,
2181-
BoolVar z, IntPropLevel ipl=IPL_DEF);
2291+
BoolVar z, IntPropLevel ipln=IPL_DEF);
21822292
#ifdef GECODE_HAS_SET_VARS
21832293
/** \brief Element constraint for matrix
21842294
*

0 commit comments

Comments
 (0)