/* * Copyright 2002, 2003, 2004, 2005 - Koalog */ package com.koalog.jcs.examples; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import org.apache.log4j.Category; import org.apache.log4j.PropertyConfigurator; import com.koalog.jcs.variable.SetVariable; import com.koalog.jcs.constraint.BaseProblem; import com.koalog.jcs.constraint.set.ConstantCard; import com.koalog.jcs.constraint.set.Partition; import com.koalog.jcs.constraint.set.IntersectionMaxSize; import com.koalog.jcs.domain.SetDomain; /** * Social golfer problem: schedule a golf tournament during n weeks. * *
Each week, 8 groups of 4 golfers are formed. * Each golfer should only golf with the same persons only once. * *
Note: the problem has no solution if n is strictly greater than 10.
*
* @author Yan Georget
*/
public class GolfersProblem extends BaseProblem {
//------------------------------------------------------------------------
// STATIC PROPERTIES
//------------------------------------------------------------------------
private static Category cat = Category.getInstance(GolfersProblem.class);
/** Number of groups. */
public static final int GROUP_NB = 8;
/** Number of golfers in a group. */
public static final int GROUP_CARD = 4;
/** Number of golfers. */
public static final int GOLFERS_NB = GROUP_NB*GROUP_CARD;
//------------------------------------------------------------------------
// PROPERTIES
//------------------------------------------------------------------------
SetVariable[][] group;
//------------------------------------------------------------------------
// CONSTRUCTORS
//------------------------------------------------------------------------
/**
* Sole constructor.
* @param n the number of weeks
*/
public GolfersProblem(int n) {
super();
group = new SetVariable[n][GROUP_NB];
Collection vars = new ArrayList(n*GROUP_NB);
Collection golfers = new ArrayList(GOLFERS_NB);
for (int i=1; i<=GOLFERS_NB; i++) {
golfers.add(new Integer(i));
}
for (int i=0; i