1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
Jip J. Dekker 2c8ad0004a Squashed 'software/minizinc/' changes from 4f10c82056..93be33a6c2
93be33a6c2 Add complete predicate
REVERT: 4f10c82056 Merge branch 'MiniZinc:master' into feature/on_restart
REVERT: 0848ce7ec7 Add changelog for 2.5.5
REVERT: 44e2f770d5 Add test for insertion of ArrayLits into CSE
REVERT: 8a68d3dea8 Don't insert par expressions into CSE map unless they're an ArrayLit
REVERT: 6bf6f1180f Increase version number of development build
REVERT: dcaac92a74 Make min/max on array of opt vars return non-optional var. This is consistent with other functions on optional arrays like sum, product, exists, forall.
REVERT: 32aa288884 Update changelog
REVERT: a4edf0669f Fix flattening of all-par set literals
REVERT: 8c1c9605f6 Fix chain compressor, needs to ignore par constants
REVERT: 0cad1c6306 Use file_path on include paths to ensure separator consistency
REVERT: 05ad7d1931 Update changelog
REVERT: 22f5e2557b Define HAVE_CONFIG_H only for UNIX
REVERT: 81c7778d55 Define HAVE_CONFIG_H for CBC
REVERT: 1f56608e10 mzn-test: don't check symmetry breaking constraints
REVERT: 1a9767457e mzn-test: fix parsing %%%mzn-stat: ... output
REVERT: a41533fd54 MIP: report CPU time in %%%mzn-stat: solveTime=
REVERT: 9d490acd52 Updated docs on OR-Tools v8 installation
REVERT: c513f6599f Add changelog for 2.5.4
REVERT: b2eef2772b Follow ids to declarations when flattening par arrays. Fixes #448.
REVERT: c5c846d426 Check if result of flattening rhs of a vardecl is par.
REVERT: c496052767 Escape strings when pretty printing include items
REVERT: 9e379c995e Canonicalise file names before adding include items into "already seen" list
REVERT: d5d5d0d88c Use generic flattening inside generators. Fixes #451.
REVERT: dc8630a6e9 Small fix to multi-pass library change: use original include path if it is absolute
REVERT: 79c6092bd8 Strip library paths from includes in multi-pass compilation. Fixes #455.
REVERT: 897875d6d7 Compile infinite domains with holes into constraints. Fixes #457.
REVERT: b4e700dc67 Don't create copies of global declarations when creating par versions of functions
REVERT: 0e8cc42bb1 Fix typechecker to coerce bool to int in the objective.
REVERT: e05523b344 Add test for dzn output of arrays
REVERT: 1e0269000e Don't evaluate output_only arrays when generating dzn output.
REVERT: 57018c31d6 Fix matrix transposition in lex2 globals
REVERT: 2617c0c829 Fix output variables in lex_chain tests
REVERT: ef1a250c98 another efort to fix tests
REVERT: c00e199dfd Fix test globals_lex_chain.mzn
REVERT: b5c997d045 Fix code analysis
REVERT: 3352cf0bd5 SCIP constraint handler for lex_chain_..._orbitope
REVERT: 4e71a2cc97 Globals lex_chain_..., including lex_chain_..._orbitope
REVERT: d807428baf Move test specifcation into the correct folder
REVERT: 5be74bc74d MIP decompositions for lex_less_(bool, int, float)
REVERT: 36a554ba40 Don't modify infinte domain of optional variables. Fixes #456.
REVERT: f9e5306d75 Run clang-format
REVERT: 4b57667608 Fix comment reference to relevant test case
REVERT: 648f2ab36d Fix equality of indirection annotations
REVERT: ef7be5fd78 MIP decompositions for lex_lesseq_(bool=int, float)
REVERT: 6511b14e73 Propagate cv flag correctly.
REVERT: 6f27ecf1c0 Never insert par expressions into the CSE map.
REVERT: 7414f3ca0f Fix cplex id in example configuration
REVERT: 7ad7cec506 Update strictly_decreasing with documentation and opt version
REVERT: 8029f6e957 Support undefined enums in type checker.
REVERT: 79e0f0f546 Revert using mzn_in_symmetry_breaking_constraint() for SCIP's orbisack
REVERT: e88efda76c Fix format
REVERT: 4802031dc1 Added test mzn_in_symmetry_breaking_constraint()
REVERT: e21cc2515a More format fixes 02 ...
REVERT: 5bbd67c130 More format fixes...
REVERT: d5f9b777ea Format fixes
REVERT: 43757a09a0 Remove MIP-specific fzn_less(eq)_bool(_reif).mzn
REVERT: c93b5736a3 SCIP: orbisack constraint handler 'fzn_lex_lesseq__orbisack'
REVERT: 4516bb4e2c mzn-test.py: add OR-Tools as checker
REVERT: e2176f017d Add fix and test for crash with empty enum.
REVERT: ac7db35951 Fix documentation bugs.
REVERT: 47ba245832 Fix the incorrect renaming of key in model output interface
REVERT: 925796ed20 Fail on empty var domains in agenda
REVERT: 1ec19d7025 Fix error messages in CMake FindGurobi, FindCPlex
REVERT: 6d169475c1 mzn-test.py: Use -i for intermediate solutions
REVERT: df2f3e423a Allow coercion of JSON lists to enum definitions
REVERT: 2b0b8165e5 Fix clang-tidy errors
REVERT: 6597bc1920 Change the CI build image location
REVERT: 360c988452 Remove illegal duplicate keys in .gitlab-ci.yml
REVERT: 6a5d69c64b Add missing par opt versions of coercion functions
REVERT: 63014e3d8f Don't propagate annotations into annotation calls. Avoids infinite recursion.
REVERT: 54b19428ab Don't use GRB_INT_PAR_NONCONVEX if it's undefined
REVERT: a5bb56c47d Added piecewise_linear for non-continuous intervals

git-subtree-dir: software/minizinc
git-subtree-split: 93be33a6c254e54be7cd38abb7ebd6a6022f0c46
2021-07-12 20:08:41 +10:00

181 lines
9.5 KiB
MiniZinc

/*
% Controls
%
*/
%-----------------------------------------------------------------------------%
%---------- USER and LAZY CUTS -----------------------------------------------%
/*
PLEASE NOTE:
If you export FZN file with lazy_constraint/user_cut annotations,
their declarations are not exported currently (as of 7.11.17).
WORKAROUND: when solving that fzn, add -G linear,
e.g., as follows: mzn-cplex -G linear model.fzn
* For Gurobi, the constraints marked as MIP_cut and/or MIP_lazy are added
* into the overall model and marked with the foll values of Lazy attribute:
* ::MIP_lazy 1
* ::MIP_cut ::MIP_lazy 2
* ::MIP_cut 3
*/
ann: user_cut;
ann: lazy_constraint;
%%% comment away the below assignments (leaving, e.g., ann: MIP_cut;) to have them as normal constraints
%%% In particular, they may be used by redundant_constraint() and symmetry_breaking_constraint(), see redefs-2.0.2.mzn
ann: MIP_cut = user_cut; %% MIP_cut: make sure no feasible solutions are cut off
%% -- seems better on average but in CPLEX, wrong LB e.g. on carpet-cutting
ann: MIP_lazy = lazy_constraint;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "GENERAL" constraints %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
opt bool: fIndConstr; %% User option, e.g., with -D
%% Attention: as of MZN 2.4.3, you also need -DfMIPdomains=false
bool: fMZN__UseIndicators = %% Pass on indicator constraints
if absent( fIndConstr ) then false
else deopt( fIndConstr ) endif;
%% CPLEX 12.6.2 Concert: reifs give wrong result on 2012/amaze, so using implications only
%% MAX/MIN
opt bool: MinMaxGeneral; %% User option, e.g., with -D
%% pass on min/max to the backend as fzn_array_float_minimum
bool: MZN__MinMaxGeneral = if absent(MinMaxGeneral) then false else deopt(MinMaxGeneral) endif;
%% CUMULATIVE
opt bool: CumulativeSolverConfig; %% As set in share/minizinc/Preferences.json
opt bool: Cumulative; %% User option, e.g., with -D
bool: MZN__Cumulative_Fixed_d_r = if occurs(Cumulative) then deopt(Cumulative)
elseif occurs(CumulativeSolverConfig) then deopt(CumulativeSolverConfig)
else false endif;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Quadratic expressions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --------------------------------------------------------------------------------------- %
%% Forward float_times as fzn_float_times
opt bool: QuadrFloatSolverConfig; %% As set in share/minizinc/Preferences.json
opt bool: QuadrFloat; %% User option, e.g., with -D
bool: MZN__QuadrFloat = if occurs(QuadrFloat) then deopt(QuadrFloat)
elseif occurs(QuadrFloatSolverConfig) then deopt(QuadrFloatSolverConfig)
else false endif;
%% Forward int_times as fzn_int_times
opt bool: QuadrIntSolverConfig; %% As set in share/minizinc/Preferences.json
opt bool: QuadrInt; %% User option, e.g., with -D
bool: QuadrIntFinal = if occurs(QuadrInt) then deopt(QuadrInt)
elseif occurs(QuadrIntSolverConfig) then deopt(QuadrIntSolverConfig)
else false endif;
opt int: QuadrIntCard; %% Convert int_times to fzn_int_times if the minimum
%% of x, y's domain cardinalities as at least QuadrIntCard
int: MZN__QuadrIntCard = if occurs(QuadrIntCard) then deopt(QuadrIntCard)
elseif QuadrIntFinal then 0 else infinity endif;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Subtour elimination in circuit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --------------------------------------------------------------------------------------- %
opt int: nSECcuts; %% 0,1: use MTZ formulation
int: nMZN__fSECcuts = %% 1,2: pass on circuit constraints to the MIP_solverinstance's cut gen
if absent( nSECcuts ) then 0
else deopt( nSECcuts ) endif;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MIPdomains %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --------------------------------------------------------------------------------------- %
%% Paper: % Belov, Stuckey, Tack, Wallace. Improved Linearization of Constraint Programming Models. CP 2016 Proceedings.
%%% The below option enables translation of domain constraints into the ...POST predicates.
%%% The code in MIPdomains.cpp processes them and also non-contiguous domains
%%% (only-range-domains is then standardly off). MIPdomains.cpp needs all the required
%%% __POST predicates to be declared to kick in.
opt bool: fMIPDomains; %% unified decomposition constraints (...__POST) to FlatZinc
opt bool: fMIPdomains; %% Can be defined from cmdline: -D "fMIPdomains=false"
bool: fPostprocessDomains = %% True to pass all domain-related
if absent( fMIPdomains ) /\ absent( fMIPDomains ) then true
elseif not absent( fMIPdomains ) then deopt( fMIPdomains )
else deopt( fMIPDomains )
endif;
opt bool: fMIPdomAux;
bool: fPostproDom_AUX = %% Specialized for aux_ constr
if absent( fMIPdomAux ) then false
else deopt( fMIPdomAux ) endif;
opt bool: fMIPdomDiff;
bool: fPostproDom_DIFF = %% Specialized for differences: x<y <-> z=x-y<0
if absent( fMIPdomDiff ) then false %% seems best for Gurobi, worse for CBC
else deopt( fMIPdomDiff ) endif;
mzn_opt_only_range_domains = not fPostprocessDomains; %% currently unused
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Avoid creating new int vars %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --------------------------------------------------------------------------------------- %
opt bool: fAvoidNewInts;
bool: fAvoidNI = %% Actually this is only for ..._lin_..., not for just x-y
if absent( fAvoidNewInts ) then false
else deopt( fAvoidNewInts ) endif;
opt bool: fNewVarsInAuxEq;
bool: fAuxIntEqOLD00 = if absent(fNewVarsInAuxEq) then false else deopt(fNewVarsInAuxEq) endif;
bool: fAuxFloatEqOLD00 = if absent(fNewVarsInAuxEq) then false else deopt(fNewVarsInAuxEq) endif;
%%%%%%%%%%%%%%%%%%%%% Redundant constraints ---------------------------------------------- %
bool: fMZN__IgnoreRedundantCumulative=false;
%% NOT WORKING NOW, use redefs_2.0.2.mzn:
%%%%% bool: fMZN__IgnoreAllUserRedundant=false; %% ignore all user-spec redundant constr
%%%%%%%%%%%%%%%%%%%%% Element, minimuum convex hull --------------------------------------- %
opt bool: fXBZCuts01; %% orders 0, 1
opt bool: fXBZCutGen; %% only works if Cuts01
bool: fElementCutsXZ=false; %% Use simple XZ & XZB cuts for element
bool: fElementCutsXZB = if absent(fXBZCuts01) then false else deopt(fXBZCuts01) endif;
bool: fMinimumCutsXZ=false; %% Use simple XZ & XZB cuts for minimum
bool: fMinimumCutsXZB = if absent(fXBZCuts01) then false else deopt(fXBZCuts01) endif;
bool: fUseXBZCutGen = if absent(fXBZCutGen) then false else deopt(fXBZCutGen) endif;
% ----------------------------------------------------------------------------------------- %
bool: fIntTimesBool=true; %% Special handling of multiplication with a boolean(*const)
%-----------------------------------------------------------------------------%
% If not postprocessing domains: For unary encoding: maximal domain length to invoke it
int: nMZN__UnarySizeMax_intTimes=20;
int: nMZN__UnarySizeMax_cumul=2000;
int: nMZN__UnarySizeMax_1step_regular=20000; %% network-flow decomp in the regular constraint
int: nMZN__UnaryLenMin__ALL=1; %% can be used by the indiv. cases
int: nMZN__UnaryLenMax__ALL=2000; %% can be used by the indiv. cases
% Some more detailed parameters
int: nMZN__UnaryLenMin_leq = 1;
int: nMZN__UnaryLenMin_neq = nMZN__UnaryLenMin__ALL;
int: nMZN__UnaryLenMin_eq = nMZN__UnaryLenMin__ALL;
int: nMZN__UnaryLenMax_leq = -1;
int: nMZN__UnaryLenMax_neq = nMZN__UnaryLenMax__ALL;
int: nMZN__UnaryLenMax_eq = nMZN__UnaryLenMax__ALL;
int: nMZN__UnaryLenMax_setIn = nMZN__UnaryLenMax__ALL;
int: nMZN__UnaryLenMax_setInReif = nMZN__UnaryLenMax__ALL;
%-----------------------------------------------------------------------------%
% Strict inequality
% The relative epsilon
%%% Has the problem that when relating to upper bound of various differences,
%%% getting different absolute eps...?
%% float: float_lt_EPS_coef__ = 1e-03; ABANDONED 12.4.18 due to #207
%%% Absolute one, used everywhere
%%% Might make no sense for floats with smaller domains etc.
opt float: float_EPS;
float: float_lt_EPS = if absent( float_EPS ) then 1e-6 else deopt( float_EPS ) endif;
%-----------------------------------------------------------------------------%
%%% Set =true to PRINT TRACING messages for some constraints:
opt bool: fMIPTrace;
bool: mzn__my_trace_on =
if absent( fMIPTrace ) then false else deopt( fMIPTrace ) endif;
test my_trace(string: msg) ::promise_total
= if mzn__my_trace_on then trace(msg)
else true endif;
test my_trace(string: msg, bool: bb) ::promise_total
= if mzn__my_trace_on then trace(msg, bb)
else bb endif;
function var bool: my_trace(string: msg, var bool: bb) ::promise_total
= if mzn__my_trace_on then trace(msg, bb)
else bb endif;
%%% Set =true to PRINT TRACING messages for the currently debugged constraints:
opt bool: fMIPTraceDBG;
bool: mzn__my_trace__DBG_on =
if absent( fMIPTraceDBG ) then false else deopt( fMIPTraceDBG ) endif;
test my_trace__DBG(string: msg) ::promise_total
= if mzn__my_trace__DBG_on then trace(msg)
else true endif;