this repo has no description
1/*
2% Controls
3%
4*/
5
6%-----------------------------------------------------------------------------%
7%---------- USER and LAZY CUTS -----------------------------------------------%
8/*
9 PLEASE NOTE:
10 If you export FZN file with lazy_constraint/user_cut annotations,
11 their declarations are not exported currently (as of 7.11.17).
12 WORKAROUND: when solving that fzn, add -G linear,
13 e.g., as follows: mzn-cplex -G linear model.fzn
14 * For Gurobi, the constraints marked as MIP_cut and/or MIP_lazy are added
15 * into the overall model and marked with the foll values of Lazy attribute:
16 * ::MIP_lazy 1
17 * ::MIP_cut ::MIP_lazy 2
18 * ::MIP_cut 3
19 */
20ann: user_cut;
21ann: lazy_constraint;
22%%% comment away the below assignments (leaving, e.g., ann: MIP_cut;) to have them as normal constraints
23%%% In particular, they may be used by redundant_constraint() and symmetry_breaking_constraint(), see redefs-2.0.2.mzn
24ann: MIP_cut = user_cut; %% MIP_cut: make sure no feasible solutions are cut off
25 %% -- seems better on average but in CPLEX, wrong LB e.g. on carpet-cutting
26ann: MIP_lazy = lazy_constraint;
27
28%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "GENERAL" constraints %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29% opt bool: fIndConstr; %% User option, e.g., with -D
30 %% Attention: as of MZN 2.4.3, you also need -DfMIPdomains=false
31bool: fMZN__UseIndicators = false; %% Pass on indicator constraints
32 % if absent( fIndConstr ) then false
33 % else deopt( fIndConstr ) endif;
34 %% CPLEX 12.6.2 Concert: reifs give wrong result on 2012/amaze, so using implications only
35
36%% MAX/MIN
37% opt bool: MinMaxGeneral; %% User option, e.g., with -D
38 %% pass on min/max to the backend as fzn_array_float_minimum
39bool: MZN__MinMaxGeneral = false; % if absent(MinMaxGeneral) then false else deopt(MinMaxGeneral) endif;
40
41%% CUMULATIVE
42% opt bool: CumulativeSolverConfig; %% As set in share/minizinc/Preferences.json
43% opt bool: Cumulative; %% User option, e.g., with -D
44bool: MZN__Cumulative_Fixed_d_r = false; % if occurs(Cumulative) then deopt(Cumulative)
45 % elseif occurs(CumulativeSolverConfig) then deopt(CumulativeSolverConfig)
46 % else false endif;
47
48
49%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Quadratic expressions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50% --------------------------------------------------------------------------------------- %
51%% Forward float_times as fzn_float_times
52% opt bool: QuadrFloatSolverConfig; %% As set in share/minizinc/Preferences.json
53% opt bool: QuadrFloat; %% User option, e.g., with -D
54bool: MZN__QuadrFloat = false; % if occurs(QuadrFloat) then deopt(QuadrFloat)
55 % elseif occurs(QuadrFloatSolverConfig) then deopt(QuadrFloatSolverConfig)
56 % else false endif;
57
58%% Forward int_times as fzn_int_times
59% opt bool: QuadrIntSolverConfig; %% As set in share/minizinc/Preferences.json
60% opt bool: QuadrInt; %% User option, e.g., with -D
61bool: QuadrIntFinal = false; % if occurs(QuadrInt) then deopt(QuadrInt)
62 % elseif occurs(QuadrIntSolverConfig) then deopt(QuadrIntSolverConfig)
63 % else false endif;
64% opt int: QuadrIntCard; %% Convert int_times to fzn_int_times if the minimum
65 %% of x, y's domain cardinalities as at least QuadrIntCard
66int: MZN__QuadrIntCard = 0; % if occurs(QuadrIntCard) then deopt(QuadrIntCard)
67 % elseif QuadrIntFinal then 0 else infinity endif;
68
69%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Subtour elimination in circuit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70% --------------------------------------------------------------------------------------- %
71% opt int: nSECcuts; %% 0,1: use MTZ formulation
72int: nMZN__fSECcuts = 0; %% 1,2: pass on circuit constraints to the MIP_solverinstance's cut gen
73 % if absent( nSECcuts ) then 0
74 % else deopt( nSECcuts ) endif;
75
76
77%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MIPdomains %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78% --------------------------------------------------------------------------------------- %
79%% Paper: % Belov, Stuckey, Tack, Wallace. Improved Linearization of Constraint Programming Models. CP 2016 Proceedings.
80 %%% The below option enables translation of domain constraints into the ...POST predicates.
81 %%% The code in MIPdomains.cpp processes them and also non-contiguous domains
82 %%% (only-range-domains is then standardly off). MIPdomains.cpp needs all the required
83 %%% __POST predicates to be declared to kick in.
84% opt bool: fMIPDomains; %% unified decomposition constraints (...__POST) to FlatZinc
85% opt bool: fMIPdomains; %% Can be defined from cmdline: -D "fMIPdomains=false"
86bool: fPostprocessDomains = false; %% True to pass all domain-related
87 % if absent( fMIPdomains ) /\ absent( fMIPDomains ) then true
88 % elseif not absent( fMIPdomains ) then deopt( fMIPdomains )
89 % else deopt( fMIPDomains )
90 % endif;
91% opt bool: fMIPdomAux;
92bool: fPostproDom_AUX = false; %% Specialized for aux_ constr
93 % if absent( fMIPdomAux ) then false
94 % else deopt( fMIPdomAux ) endif;
95% opt bool: fMIPdomDiff;
96bool: fPostproDom_DIFF = false; %% Specialized for differences: x<y <-> z=x-y<0
97 % if absent( fMIPdomDiff ) then false %% seems best for Gurobi, worse for CBC
98 % else deopt( fMIPdomDiff ) endif;
99
100% mzn_opt_only_range_domains = not fPostprocessDomains; %% currently unused
101
102%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Avoid creating new int vars %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103% --------------------------------------------------------------------------------------- %
104% opt bool: fAvoidNewInts;
105bool: fAvoidNI = false; %% Actually this is only for ..._lin_..., not for just x-y
106 % if absent( fAvoidNewInts ) then false
107 % else deopt( fAvoidNewInts ) endif;
108% opt bool: fNewVarsInAuxEq;
109bool: fAuxIntEqOLD00 = false; % if absent(fNewVarsInAuxEq) then false else deopt(fNewVarsInAuxEq) endif;
110bool: fAuxFloatEqOLD00 = false; % if absent(fNewVarsInAuxEq) then false else deopt(fNewVarsInAuxEq) endif;
111
112%%%%%%%%%%%%%%%%%%%%% Redundant constraints ---------------------------------------------- %
113bool: fMZN__IgnoreRedundantCumulative=false;
114%% NOT WORKING NOW, use redefs_2.0.2.mzn:
115%%%%% bool: fMZN__IgnoreAllUserRedundant=false; %% ignore all user-spec redundant constr
116
117%%%%%%%%%%%%%%%%%%%%% Element, minimuum convex hull --------------------------------------- %
118% opt bool: fXBZCuts01; %% orders 0, 1
119% opt bool: fXBZCutGen; %% only works if Cuts01
120bool: fElementCutsXZ=false; %% Use simple XZ & XZB cuts for element
121bool: fElementCutsXZB = false; % if absent(fXBZCuts01) then false else deopt(fXBZCuts01) endif;
122bool: fMinimumCutsXZ=false; %% Use simple XZ & XZB cuts for minimum
123bool: fMinimumCutsXZB = false; % if absent(fXBZCuts01) then false else deopt(fXBZCuts01) endif;
124bool: fUseXBZCutGen = false; % if absent(fXBZCutGen) then false else deopt(fXBZCutGen) endif;
125
126% ----------------------------------------------------------------------------------------- %
127bool: fIntTimesBool=true; %% Special handling of multiplication with a boolean(*const)
128
129%-----------------------------------------------------------------------------%
130% If not postprocessing domains: For unary encoding: maximal domain length to invoke it
131
132int: nMZN__UnarySizeMax_intTimes=20;
133int: nMZN__UnarySizeMax_cumul=2000;
134int: nMZN__UnarySizeMax_1step_regular=20000; %% network-flow decomp in the regular constraint
135
136int: nMZN__UnaryLenMin__ALL=1; %% can be used by the indiv. cases
137int: nMZN__UnaryLenMax__ALL=2000; %% can be used by the indiv. cases
138% Some more detailed parameters
139int: nMZN__UnaryLenMin_leq = 1;
140int: nMZN__UnaryLenMin_neq = nMZN__UnaryLenMin__ALL;
141int: nMZN__UnaryLenMin_eq = nMZN__UnaryLenMin__ALL;
142int: nMZN__UnaryLenMax_leq = -1;
143int: nMZN__UnaryLenMax_neq = nMZN__UnaryLenMax__ALL;
144int: nMZN__UnaryLenMax_eq = nMZN__UnaryLenMax__ALL;
145int: nMZN__UnaryLenMax_setIn = nMZN__UnaryLenMax__ALL;
146int: nMZN__UnaryLenMax_setInReif = nMZN__UnaryLenMax__ALL;
147
148%-----------------------------------------------------------------------------%
149% Strict inequality
150% The relative epsilon
151%%% Has the problem that when relating to upper bound of various differences,
152%%% getting different absolute eps...?
153%% float: float_lt_EPS_coef__ = 1e-03; ABANDONED 12.4.18 due to #207
154%%% Absolute one, used everywhere
155%%% Might make no sense for floats with smaller domains etc.
156% opt float: float_EPS;
157float: float_lt_EPS = 1e-6; % if absent( float_EPS ) then 1e-6 else deopt( float_EPS ) endif;
158
159%-----------------------------------------------------------------------------%
160%%% Set =true to PRINT TRACING messages for some constraints:
161% opt bool: fMIPTrace;
162bool: mzn__my_trace_on = false;
163 % if absent( fMIPTrace ) then false else deopt( fMIPTrace ) endif;
164test my_trace(string: msg) ::promise_total
165 = if mzn__my_trace_on then trace(msg)
166 else true endif;
167test my_trace(string: msg, bool: bb) ::promise_total
168 = if mzn__my_trace_on then trace(msg, bb)
169 else bb endif;
170function var bool: my_trace(string: msg, var bool: bb) ::promise_total
171 = if mzn__my_trace_on then trace(msg, bb)
172 else bb endif;
173%%% Set =true to PRINT TRACING messages for the currently debugged constraints:
174% opt bool: fMIPTraceDBG;
175bool: mzn__my_trace__DBG_on = false;
176 % if absent( fMIPTraceDBG ) then false else deopt( fMIPTraceDBG ) endif;
177test my_trace__DBG(string: msg) ::promise_total
178 = if mzn__my_trace__DBG_on then trace(msg)
179 else true endif;
180