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 fad1b07018 Squashed 'software/minizinc/' content from commit 4f10c8205
git-subtree-dir: software/minizinc
git-subtree-split: 4f10c82056ffcb1041d7ffef29d77a7eef92cf76
2021-06-16 14:06:46 +10:00

164 lines
4.3 KiB
MiniZinc

/***
!Test
solvers: [gecode, chuffed]
expected:
- !Result
solution: !Solution
end: 53
objective: 53
s: [0, 0, 0, 4, 7, 7, 6, 8, 12, 8, 6, 4, 14, 19, 12, 12, 13, 18, 8, 11, 14, 18, 19, 4, 16, 10, 20, 9, 14, 6, 24, 26, 21, 16, 9, 21, 24, 28, 31, 22, 24, 11, 25, 16, 30, 26, 38, 25, 25, 30, 33, 36, 39, 34, 33, 47, 25, 44, 50, 38]
***/
% The following is a regression test for a flattening bug with predicate
% parameter expansion. See the log message for r7550.
% It is derived from g12/zinc/benchmarks/minizinc/rcpsp/rcpsp.mzn with 02.dzn
%-----------------------------------------------------------------------------%
include "globals.mzn";
%-----------------------------------------------------------------------------%
% Model parameters.
%
% Resource parameters
%
int: n_res; % The number of resources
array [ 1..n_res ] of int: rc; % The resource capacities
% Task parameters
%
int: n_tasks; % The number of tasks
array [ 1..n_tasks ] of int: d; % The task durations
int: sum_d = sum( i in 1..n_tasks ) (d[i]); % The total duration
array [ 1..n_res, 1..n_tasks ] of int: rr; % The resource requirements
array [ 1..n_tasks ] of set of int: suc; % The task successors
n_res = 4;
rc = [ 18, 22, 20, 14 ];
n_tasks = 60;
d = [ 4, 7, 9, 2, 6, 5, 2, 7, 4, 3, 4, 10, 4, 5, 8, 2, 7, 10, 8, 8, 8, 1, 5, 5, 7, 2, 1, 8, 10, 1, 1, 4, 10, 9, 3, 3, 7, 10, 6, 6, 9, 9, 1, 10, 2, 10, 6, 8, 9, 2, 6, 2, 8, 3, 4, 3, 9, 3, 3, 7 ];
rr = [| 1, 0, 0, 5, 0, 4, 9, 0, 0, 0, 0, 0, 0, 9, 0, 0,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39 },
{ 47 },
{ 47 },
{ 53 },
{ 51 },
{ 56 },
{ 51, 58 },
{ 46 },
{ 55 },
{ 52 },
{ 58 },
{ 55 },
{ 54 },
{ 56 },
{ 53 },
{ 60 },
{ 56 },
{ 59 },
{ 60 },
{ 59 },
{ 59 },
{ },
{ },
{ } ];
%-----------------------------------------------------------------------------%
% Model variables.
%
% s: start times
% end: total end time (makespan)
%
array [ 1..n_tasks ] of var 0..sum_d: s;
var 0..sum_d: end;
%-----------------------------------------------------------------------------%
% Constraints.
%
% successor constraints
constraint
forall ( i in 1..n_tasks, j in suc[i] )
(
s[i] + d[i] <= s[j]
);
% cumulative resource constraints
constraint
forall ( i in 1..n_res )
(
cumulative(
s,
d,
[ rr[i,j] | j in 1..n_tasks ],
rc[i]
)
);
% makespan constraints
constraint
forall ( i in 1..n_tasks )
(
s[i] + d[i] <= end
);
%-----------------------------------------------------------------------------%
% Objective.
%
solve
:: int_search( s, smallest, indomain_min, complete )
minimize end;
output [
"s = ",
show( s ),
";\n",
"end = ",
show( end ),
";\n"
];
%-----------------------------------------------------------------------------%
%%% EOF %%%