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 | language ESSENCE 1.2.0 $ prob039.essence: Rehearsal Problem $ Problem details available at http://www.csplib.org/Problems/prob039/ $ 07 September 2007 $ given n_pieces, n_players : int (1..) letting Piece be domain int (1..n_pieces), Index be domain int (1..n_pieces), Player be domain int (1..n_players) given duration : function ( total ) Piece --> int (1..), plays_in : relation of (Player*Piece) find order : function ( total , bijective ) Index --> Piece, arrive, leave : function ( total ) Player --> Index maximising sum p : Player . sum ([duration(order(i)) | i : Index, i <= arrive(p) ]) + sum ([duration(order(i)) | i : Index, i >= leave(p) , i <= n_pieces ]) such that forAll p : Player . plays_in(p,arrive(p)), forAll p : Player . plays_in(p,leave(p)), forAll p : Player . forAll i : Index , plays_in(p,order(i)) . arrive(p) <= i /\ leave(p) >= i |