/* * Copyright 2002, 2003, 2004, 2005 - Koalog */ package com.koalog.jcs.examples; import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.Category; import java.util.Arrays; import java.util.Comparator; import java.util.Map; import java.util.HashMap; import com.koalog.jcs.variable.BooleanVariable; import com.koalog.jcs.variable.IntegerVariable; import com.koalog.jcs.constraint.BaseProblem; import com.koalog.jcs.constraint.arithmetic.Atmost; import com.koalog.jcs.constraint.arithmetic.Atleast; import com.koalog.jcs.constraint.arithmetic.Exactly_SPARSE; import com.koalog.jcs.constraint.arithmetic.Element; import com.koalog.jcs.domain.SparseDomain; /** * The cars sequencing problem (problem prob001 in CSPLIB). * *

Cars have to be scheduled on a production line. * The cars differ by their options * (the set of options of a car defines its type/class). * Options are installed by stations: * for each block of b consecutive cars, * each station can handle at most s cars * (s and b depend on the option/station). * *

The problem has been shown to be NP-complete (Gent 1999). * * @author Yan Georget */ public class CarsSequencingProblem extends BaseProblem { //------------------------------------------------------------------------ // PROPERTIES //------------------------------------------------------------------------ /** * The problem data: *

*/ int[][] data; /** A map mapping a variable to an array of costs. */ Map costs; //------------------------------------------------------------------------ // CONSTRUCTOR //------------------------------------------------------------------------ /** * Sole constructor. * @param data the problem data */ public CarsSequencingProblem(int[][] data) { super(); this.data = data; int carsNb = data[0][0]; int optionsNb = data[0][1]; int typesNb = data[0][2]; IntegerVariable[] type = new IntegerVariable[carsNb]; for (int i=0; i