import static choco.Choco.*; import choco.cp.model.CPModel; import choco.cp.solver.CPSolver; import choco.kernel.model.Model; import choco.kernel.solver.Solver; import choco.kernel.model.variables.integer.IntegerVariable; import choco.kernel.model.constraints.Constraint; import choco.cp.solver.search.integer.varselector.*; import java.util.*; public class Skipper { Model model; int id; // identification number int n; // number of skippers, controls domains size for a time slot int m; // size of a round int matches; // number of matches int rounds; // number of rounds int timeSlots; IntegerVariable[] timeSlot; // array of timeslots for a skipper IntegerVariable[] isMinusTwo; // IntegerVariable[] isMinusOne; // IntegerVariable[] isGeqZero; // IntegerVariable[] state; // there is a state for each round for the skipper IntegerVariable[] decVar; // decision variables Skipper(Model model,int id,int n,int m){ this.model = model; this.id = id; this.n = n; this.m = m; matches = n*(n-1)/2; rounds = (int)Math.ceil((double)matches/(double)m); timeSlots = rounds * m; timeSlot = makeIntVarArray("timeSlot_"+ id,timeSlots,-2,n-1); isMinusTwo = makeIntVarArray("isMinusTwo",timeSlots,0,1); isMinusOne = makeIntVarArray("isMinusOne",timeSlots,0,1); isGeqZero = makeIntVarArray("isGeqZero",timeSlots,0,1); state = makeIntVarArray("state_"+ id,rounds,1,5); decVar = new IntegerVariable[timeSlots + rounds]; for (int i=0;i= 0) // public static void main(String[] args) { int n = Integer.parseInt(args[0]); // number of rounds int boats = Math.min(n,Integer.parseInt(args[1])); // number of boats int m = boats/2; // size of a round int matches = n*(n-1)/2; int rounds = (int)Math.ceil((double)matches/(double)m); int timeSlots = rounds * m; Model model = new CPModel(); Skipper skip = new Skipper(model,0,n,m); Solver solver = new CPSolver(); solver.read(skip.model); solver.setVarIntSelector(new MinDomain(solver,solver.getVar(skip.decVar))); System.out.println("blip"); if (solver.solve().booleanValue()){ for (int round=0;round= 0) System.out.print(x); } System.out.print(" "); } System.out.println(); while (solver.nextSolution().booleanValue()){ for (int round=0;round= 0) System.out.print(x); } System.out.print(" "); } System.out.println(); } } } }