/* * Main authors: * Christian Schulte * * Copyright: * Christian Schulte, 2004 * * Last modified: * $Date: 2006-08-31 17:36:38 +0200 (Thu, 31 Aug 2006) $ by $Author: schulte $ * $Revision: 3579 $ * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * See the file "LICENSE" for information on usage and * redistribution of this file, and for a * DISCLAIMER OF ALL WARRANTIES. * */ #include "examples/support.hh" /** * \brief %Example: Orthogonal latin squares * * \ingroup Examples */ class OrthoLatinSquare : public Example { protected: /// Size of squares const int n; /// Fields of first square IntVarArray x1; /// Fields of second square IntVarArray x2; public: /// Access field at position \a i and \a j in first square IntVar& y1(int i, int j) { return x1[i*n+j]; } /// Access field at position \a i and \a j in second square IntVar& y2(int i, int j) { return x2[i*n+j]; } /// Actual model OrthoLatinSquare(const Options& opt) : n(opt.size), x1(this,n*n,1,n), x2(this,n*n,1,n) { const int nn = n*n; IntVarArray z(this,nn,0,n*n-1); distinct(this, z, opt.icl); // Connect { IntArgs mod(n*n); IntArgs div(n*n); for (int i=0; i(opt); return 0; } // STATISTICS: example-any