/* * Copyright 2002, 2003, 2004, 2005 - Koalog */ package com.koalog.jcs.examples; import java.util.Collection; import java.util.ArrayList; import org.apache.log4j.PropertyConfigurator; import com.koalog.jcs.variable.IntegerVariable; import com.koalog.jcs.constraint.BaseProblem; import com.koalog.jcs.constraint.arithmetic.AllDifferent_SPARSE; import com.koalog.jcs.constraint.arithmetic.GCC_SPARSE; import com.koalog.jcs.constraint.arithmetic.Relation_SPARSE; import com.koalog.jcs.domain.SparseDomain; /** *

The problem consists of scheduling games between n teams over n-1 weeks * (here n for the sake of uniformity). Each week is divided into n/2 periods. * The goal is to schedule a game for each period of every week so that: *

* * @author Yan Georget */ public class RoundRobinProblem extends BaseProblem { //------------------------------------------------------------------------ // PROPERTIES //------------------------------------------------------------------------ /** The number of teams. */ int n; //------------------------------------------------------------------------ // CONSTRUCTORS //------------------------------------------------------------------------ /** * Sole constructor. * @param n the number of teams. */ public RoundRobinProblem(int n) { super(); this.n = n; // The problem constraints. Collection vars = new ArrayList((n/2) * (n-1)); // The games per periods and weeks. IntegerVariable[][] g = new IntegerVariable[n/2][n-1]; for (int p=0; p