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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29opt bool: fIndConstr;          %% User option, e.g., with -D
30                               %% Attention: as of MZN 2.4.3, you also need -DfMIPdomains=false
31bool: fMZN__UseIndicators =    %% 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
37opt bool: MinMaxGeneral;       %% User option, e.g., with -D
38                               %% pass on min/max to the backend as fzn_array_float_minimum
39bool: MZN__MinMaxGeneral = if absent(MinMaxGeneral) then false else deopt(MinMaxGeneral) endif;
40
41%% CUMULATIVE
42opt bool: CumulativeSolverConfig;               %% As set in share/minizinc/Preferences.json
43opt bool: UseCumulative;       %% User option, e.g., with -D
44bool: MZN__Cumulative_Fixed_d_r = if occurs(UseCumulative) then deopt(UseCumulative)
45                      elseif occurs(CumulativeSolverConfig) then deopt(CumulativeSolverConfig)
46                      else false endif;
47
48%% ORBISACK
49opt bool: OrbisackSolverConfig;               %% As set in share/minizinc/Preferences.json
50opt bool: UseOrbisack;          %% User option, e.g., with -D
51bool: MZN__Orbisack = if occurs(UseOrbisack) then deopt(UseOrbisack)
52                      elseif occurs(OrbisackSolverConfig) then deopt(OrbisackSolverConfig)
53                      else false endif;
54
55%% ORBITOPE
56opt bool: OrbitopeSolverConfig;               %% As set in share/minizinc/Preferences.json
57opt bool: UseOrbitope;          %% User option, e.g., with -D
58bool: MZN__Orbitope = if occurs(UseOrbitope) then deopt(UseOrbitope)
59                      elseif occurs(OrbitopeSolverConfig) then deopt(OrbitopeSolverConfig)
60                      else false endif;
61
62
63%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Quadratic expressions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64% --------------------------------------------------------------------------------------- %
65%% Forward float_times as fzn_float_times
66opt bool: QuadrFloatSolverConfig;             %% As set in share/minizinc/Preferences.json
67opt bool: QuadrFloat;                         %% User option, e.g., with -D
68bool: MZN__QuadrFloat = if occurs(QuadrFloat) then deopt(QuadrFloat)
69                      elseif occurs(QuadrFloatSolverConfig) then deopt(QuadrFloatSolverConfig)
70                      else false endif;
71
72%% Forward int_times as fzn_int_times
73opt bool: QuadrIntSolverConfig;               %% As set in share/minizinc/Preferences.json
74opt bool: QuadrInt;                           %% User option, e.g., with -D
75bool: QuadrIntFinal = if occurs(QuadrInt) then deopt(QuadrInt)
76                      elseif occurs(QuadrIntSolverConfig) then deopt(QuadrIntSolverConfig)
77                      else false endif;
78opt int: QuadrIntCard;          %% Convert int_times to fzn_int_times if the minimum
79                                %% of x, y's domain cardinalities as at least QuadrIntCard
80int: MZN__QuadrIntCard = if occurs(QuadrIntCard) then deopt(QuadrIntCard)
81                         elseif QuadrIntFinal then 0 else infinity endif;
82
83%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Subtour elimination in circuit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84% --------------------------------------------------------------------------------------- %
85opt int: nSECcuts;       %% 0,1: use MTZ formulation
86int: nMZN__fSECcuts =    %% 1,2: pass on circuit constraints to the MIP_solverinstance's cut gen
87           if absent( nSECcuts ) then 0
88           else deopt( nSECcuts ) endif;
89
90
91%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MIPdomains %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92% --------------------------------------------------------------------------------------- %
93%% Paper: %   Belov, Stuckey, Tack, Wallace. Improved Linearization of Constraint Programming Models. CP 2016 Proceedings.
94  %%% The below option enables translation of domain constraints into the ...POST predicates.
95  %%% The code in MIPdomains.cpp processes them and also non-contiguous domains
96  %%% (only-range-domains is then standardly off). MIPdomains.cpp needs all the required
97  %%% __POST predicates to be declared to kick in.
98opt bool: fMIPDomains;           %% unified decomposition constraints (...__POST) to FlatZinc
99opt bool: fMIPdomains;           %% Can be defined from cmdline: -D "fMIPdomains=false"
100bool: fPostprocessDomains =      %% True to pass all domain-related
101           if absent( fMIPdomains ) /\ absent( fMIPDomains ) then true
102           elseif not absent( fMIPdomains ) then deopt( fMIPdomains )
103           else deopt( fMIPDomains )
104           endif;
105opt bool: fMIPdomAux;
106bool: fPostproDom_AUX =          %% Specialized for aux_ constr
107           if absent( fMIPdomAux ) then false
108           else deopt( fMIPdomAux ) endif;
109opt bool: fMIPdomDiff;
110bool: fPostproDom_DIFF =         %% Specialized for differences: x<y <-> z=x-y<0
111           if absent( fMIPdomDiff ) then false                             %% seems best for Gurobi, worse for CBC
112           else deopt( fMIPdomDiff ) endif;
113
114mzn_opt_only_range_domains = not fPostprocessDomains;   %% currently unused
115
116%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Avoid creating new int vars %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117% --------------------------------------------------------------------------------------- %
118opt bool: fAvoidNewInts;
119bool: fAvoidNI =                  %% Actually this is only for ..._lin_..., not for just x-y
120           if absent( fAvoidNewInts ) then false
121           else deopt( fAvoidNewInts ) endif;
122opt bool: fNewVarsInAuxEq;
123bool: fAuxIntEqOLD00 = if absent(fNewVarsInAuxEq) then false else deopt(fNewVarsInAuxEq) endif;
124bool: fAuxFloatEqOLD00 = if absent(fNewVarsInAuxEq) then false else deopt(fNewVarsInAuxEq) endif;
125
126%%%%%%%%%%%%%%%%%%%%%  Redundant constraints ---------------------------------------------- %
127bool: fMZN__IgnoreRedundantCumulative=false;
128%% NOT WORKING NOW, use redefs_2.0.2.mzn:
129%%%%% bool: fMZN__IgnoreAllUserRedundant=false;   %% ignore all user-spec redundant constr
130
131%%%%%%%%%%%%%%%%%%%%% Element, minimuum convex hull --------------------------------------- %
132opt bool: fXBZCuts01;  %% orders 0, 1
133opt bool: fXBZCutGen;  %% only works if Cuts01
134bool: fElementCutsXZ=false;       %% Use simple XZ & XZB cuts for element
135bool: fElementCutsXZB = if absent(fXBZCuts01) then false else deopt(fXBZCuts01) endif;
136bool: fMinimumCutsXZ=false;       %% Use simple XZ & XZB cuts for minimum
137bool: fMinimumCutsXZB = if absent(fXBZCuts01) then false else deopt(fXBZCuts01) endif;
138bool: fUseXBZCutGen = if absent(fXBZCutGen) then false else deopt(fXBZCutGen) endif;
139
140% ----------------------------------------------------------------------------------------- %
141bool: fIntTimesBool=true;       %% Special handling of multiplication with a boolean(*const)
142
143%-----------------------------------------------------------------------------%
144%    If not postprocessing domains: For unary encoding: maximal domain length to invoke it
145
146int: nMZN__UnarySizeMax_intTimes=20;
147int: nMZN__UnarySizeMax_cumul=2000;
148int: nMZN__UnarySizeMax_1step_regular=20000;   %% network-flow decomp in the regular constraint
149
150int: nMZN__UnaryLenMin__ALL=1;    %% can be used by the indiv. cases
151int: nMZN__UnaryLenMax__ALL=2000;    %% can be used by the indiv. cases
152%  Some more detailed parameters
153int: nMZN__UnaryLenMin_leq       = 1;
154int: nMZN__UnaryLenMin_neq       = nMZN__UnaryLenMin__ALL;
155int: nMZN__UnaryLenMin_eq        = nMZN__UnaryLenMin__ALL;
156int: nMZN__UnaryLenMax_leq       = -1;
157int: nMZN__UnaryLenMax_neq       = nMZN__UnaryLenMax__ALL;
158int: nMZN__UnaryLenMax_eq        = nMZN__UnaryLenMax__ALL;
159int: nMZN__UnaryLenMax_setIn     = nMZN__UnaryLenMax__ALL;
160int: nMZN__UnaryLenMax_setInReif = nMZN__UnaryLenMax__ALL;
161
162%-----------------------------------------------------------------------------%
163% Strict inequality
164% The relative epsilon
165%%% Has the problem that when relating to upper bound of various differences,
166%%% getting different absolute eps...?
167%% float: float_lt_EPS_coef__ = 1e-03; ABANDONED 12.4.18 due to #207
168%%% Absolute one, used everywhere
169%%% Might make no sense for floats with smaller domains etc.
170opt float: float_EPS;
171float: float_lt_EPS = if absent( float_EPS ) then 1e-6 else deopt( float_EPS ) endif;
172
173%-----------------------------------------------------------------------------%
174%%% Set =true to PRINT TRACING messages for some constraints:
175opt bool: fMIPTrace;
176bool: mzn__my_trace_on =
177    if absent( fMIPTrace ) then false else deopt( fMIPTrace ) endif;
178test my_trace(string: msg) ::promise_total
179  = if mzn__my_trace_on then trace(msg)
180    else true endif;
181test my_trace(string: msg, bool: bb) ::promise_total
182  = if mzn__my_trace_on then trace(msg, bb)
183    else bb endif;
184function var bool: my_trace(string: msg, var bool: bb) ::promise_total
185  = if mzn__my_trace_on then trace(msg, bb)
186    else bb endif;
187%%% Set =true to PRINT TRACING messages for the currently debugged constraints:
188opt bool: fMIPTraceDBG;
189bool: mzn__my_trace__DBG_on =
190    if absent( fMIPTraceDBG ) then false else deopt( fMIPTraceDBG ) endif;
191test my_trace__DBG(string: msg) ::promise_total
192  = if mzn__my_trace__DBG_on then trace(msg)
193    else true endif;
194
195