investment_problem_mip.fzn 4 KB
Newer Older
Valentin Platzgummer's avatar
Valentin Platzgummer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
array [1..40] of int: returns = [0, 0, 0, 0, 0, 0, 0, 0, 41, 18, 15, 22, 13, 42, 22, 10, 58, 30, 25, 38, 24, 59, 35, 17, 65, 39, 33, 48, 32, 66, 42, 23, 68, 45, 38, 55, 39, 68, 46, 28];
var 0..1000: INT____00001 :: is_defined_var :: var_is_introduced;
array [1..8] of var 0..4: choices :: output_array([1..8]);
var 0..10: not_invested :: output_var;
array [1..8] of var int: the_returns :: output_array([1..8]);
array [1..40] of var 0..1: x :: output_array([0..4, 1..8]);
var 0..1000: z :: output_var = INT____00001;
constraint int_le(0, the_returns[1]);
constraint int_le(0, the_returns[2]);
constraint int_le(0, the_returns[3]);
constraint int_le(0, the_returns[4]);
constraint int_le(0, the_returns[5]);
constraint int_le(0, the_returns[6]);
constraint int_le(0, the_returns[7]);
constraint int_le(0, the_returns[8]);
constraint int_lin_eq([1, -42, -59, -66, -68], [the_returns[6], x[14], x[22], x[30], x[38]], 0);
constraint int_lin_eq([1, -41, -58, -65, -68], [the_returns[1], x[9], x[17], x[25], x[33]], 0);
constraint int_lin_eq([1, -22, -38, -48, -55], [the_returns[4], x[12], x[20], x[28], x[36]], 0);
constraint int_lin_eq([1, -22, -35, -42, -46], [the_returns[7], x[15], x[23], x[31], x[39]], 0);
constraint int_lin_eq([1, -18, -30, -39, -45], [the_returns[2], x[10], x[18], x[26], x[34]], 0);
constraint int_lin_eq([1, -15, -25, -33, -38], [the_returns[3], x[11], x[19], x[27], x[35]], 0);
constraint int_lin_eq([1, -13, -24, -32, -39], [the_returns[5], x[13], x[21], x[29], x[37]], 0);
constraint int_lin_eq([1, -10, -17, -23, -28], [the_returns[8], x[16], x[24], x[32], x[40]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4], [choices[1], x[9], x[17], x[25], x[33]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4], [choices[2], x[10], x[18], x[26], x[34]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4], [choices[3], x[11], x[19], x[27], x[35]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4], [choices[4], x[12], x[20], x[28], x[36]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4], [choices[5], x[13], x[21], x[29], x[37]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4], [choices[6], x[14], x[22], x[30], x[38]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4], [choices[7], x[15], x[23], x[31], x[39]], 0);
constraint int_lin_eq([1, -1, -2, -3, -4], [choices[8], x[16], x[24], x[32], x[40]], 0);
constraint int_lin_eq([-1, 5, 41, 18, 15, 22, 13, 42, 22, 10, 58, 30, 25, 38, 24, 59, 35, 17, 65, 39, 33, 48, 32, 66, 42, 23, 68, 45, 38, 55, 39, 68, 46, 28], [INT____00001, not_invested, x[9], x[10], x[11], x[12], x[13], x[14], x[15], x[16], x[17], x[18], x[19], x[20], x[21], x[22], x[23], x[24], x[25], x[26], x[27], x[28], x[29], x[30], x[31], x[32], x[33], x[34], x[35], x[36], x[37], x[38], x[39], x[40]], 0) :: defines_var(INT____00001);
constraint int_lin_le([1, 1, 1, 1, 1], [x[1], x[9], x[17], x[25], x[33]], 1);
constraint int_lin_le([1, 1, 1, 1, 1], [x[2], x[10], x[18], x[26], x[34]], 1);
constraint int_lin_le([1, 1, 1, 1, 1], [x[3], x[11], x[19], x[27], x[35]], 1);
constraint int_lin_le([1, 1, 1, 1, 1], [x[4], x[12], x[20], x[28], x[36]], 1);
constraint int_lin_le([1, 1, 1, 1, 1], [x[5], x[13], x[21], x[29], x[37]], 1);
constraint int_lin_le([1, 1, 1, 1, 1], [x[6], x[14], x[22], x[30], x[38]], 1);
constraint int_lin_le([1, 1, 1, 1, 1], [x[7], x[15], x[23], x[31], x[39]], 1);
constraint int_lin_le([1, 1, 1, 1, 1], [x[8], x[16], x[24], x[32], x[40]], 1);
constraint int_lin_le([1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4], [not_invested, x[9], x[10], x[11], x[12], x[13], x[14], x[15], x[16], x[17], x[18], x[19], x[20], x[21], x[22], x[23], x[24], x[25], x[26], x[27], x[28], x[29], x[30], x[31], x[32], x[33], x[34], x[35], x[36], x[37], x[38], x[39], x[40]], 10);
solve  :: int_search([x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15], x[16], x[17], x[18], x[19], x[20], x[21], x[22], x[23], x[24], x[25], x[26], x[27], x[28], x[29], x[30], x[31], x[32], x[33], x[34], x[35], x[36], x[37], x[38], x[39], x[40]], smallest, indomain_min, complete) maximize INT____00001;