| 1 |
/*** |
| 2 |
!Test |
| 3 |
solvers: [gecode] |
| 4 |
expected: !Result |
| 5 |
status: OPTIMAL_SOLUTION |
| 6 |
solution: !Solution |
| 7 |
aCostSupport: 0 |
| 8 |
mdl8_Z: 0 |
| 9 |
***/ |
| 10 |
|
| 11 |
%%%%%% Regression test for the "missing builtin mzn_in_root_context" resolved @227ce089 |
| 12 |
|
| 13 |
int: nOBJCOEFDIVISOR__MIP = 10000; %%% Objective coefficient divisor to adapt magnitude in MIP |
| 14 |
int: nOBJCOEFDIVISOR__CP = 1000; %%% Objective coefficient divisor to adapt magnitude in CP |
| 15 |
int: nOBJLENGTHDISCR = 1000; %%% Length measure discretizer to improve objective precision (in CP) |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CONSTRAINTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
function var int: CostScaledByDiscrLength(var int: L, float: unit_cost, float: costDivisor, float: lengthDiscr) = |
| 25 |
CostScaledByDiscrLength__useDIV(L, unit_cost, costDivisor, lengthDiscr); |
| 26 |
|
| 27 |
function var int: CostScaledByDiscrLength__useDIV(var int: L, float: unit_cost, float: costDivisor, float: lengthDiscr) = |
| 28 |
let { |
| 29 |
int: lengthDiscrCeil = ceil(lengthDiscr); |
| 30 |
} in |
| 31 |
((L + lengthDiscrCeil - 1) div lengthDiscrCeil) * ceil(unit_cost * lengthDiscrCeil / costDivisor); |
| 32 |
|
| 33 |
function var int: CostScaledByDiscrLength__useMULT(var int: L, float: unit_cost, float: costDivisor, float: lengthDiscr) = |
| 34 |
let { |
| 35 |
var int: L_scaled; %% Manual decomp: OR-TOOLS 8.0.8 says "TIMEOUT, unknown" |
| 36 |
int: lengthDiscrCeil = ceil(lengthDiscr); %% But it could be better, as suggested by Gurobi |
| 37 |
constraint L <= %% Assume L is minimized |
| 38 |
L_scaled * lengthDiscrCeil |
| 39 |
; |
| 40 |
} in |
| 41 |
L_scaled * ceil(unit_cost * lengthDiscrCeil / costDivisor); |
| 42 |
|
| 43 |
|
| 44 |
%%%%%%%%%%%%%%%% SUPPORT COSTS %%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 45 |
var 0..1000000000: aCostSupport; |
| 46 |
var 0..0: mdl8_Z; |
| 47 |
constraint |
| 48 |
aCostSupport >= CostScaledByDiscrLength( mdl8_Z, |
| 49 |
42240, nOBJCOEFDIVISOR__CP, nOBJLENGTHDISCR ) |
| 50 |
; |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SOLVE + OBJECTIVE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 56 |
|
| 57 |
|
| 58 |
solve |
| 59 |
minimize |
| 60 |
aCostSupport; |
| 61 |
|
| 62 |
|