/* * Copyright 2002, 2003, 2004, 2005 - Koalog */ package com.koalog.jcs.examples; import java.util.Collection; import java.util.ArrayList; import java.util.Arrays; import org.apache.log4j.PropertyConfigurator; import com.koalog.util.matrix.SquareMatrix; import com.koalog.jcs.domain.SparseDomain; import com.koalog.jcs.variable.IntegerVariable; import com.koalog.jcs.solver.DefaultFFSolver; import com.koalog.jcs.constraint.BaseProblem; import com.koalog.jcs.constraint.arithmetic.Element_3; import com.koalog.jcs.constraint.arithmetic.LatinSquare_SPARSE; /** * The quasigroup problem. * * @author Yan Georget */ public class QGProblem extends BaseProblem { /** The numbers, with sparse domains, by row then by column. */ IntegerVariable[][] num; /** The rows, with sparse domains, by number then by column. */ IntegerVariable[][] row; /** The columns, with sparse domains, by number then by row. */ IntegerVariable[][] col; SquareMatrix mNum; SquareMatrix mRow; SquareMatrix mCol; int n; //------------------------------------------------------------------------ // CONSTRUCTORS //------------------------------------------------------------------------ /** * Sole constructor. * @param n the size of the quasigroup */ public QGProblem(int n) { super(); this.n = n; num = new IntegerVariable[n][n]; row = new IntegerVariable[n][n]; col = new IntegerVariable[n][n]; for (int i=0; i1) { // symmetry breaking num[i][j] = new IntegerVariable(i+"_"+j, new SparseDomain(i-1, n-1)); } else { num[i][j] = new IntegerVariable(i+"_"+j, new SparseDomain(0, n-1)); } } } } for (int k=0; k