/*
* Copyright 2002, 2003, 2004, 2005 - Koalog
*/
package com.koalog.jcs.examples;
import org.apache.log4j.PropertyConfigurator;
import com.koalog.jcs.variable.BooleanVariable;
import com.koalog.jcs.solver.DefaultSplitSolver;
import com.koalog.jcs.constraint.BaseProblem;
import com.koalog.jcs.constraint.arithmetic.Hyperplan;
import com.koalog.jcs.constraint.arithmetic.Exactly;
/**
* This is a partition problem.
* Given the set S = {1, 2, ..., n},
* it consists in finding two sets A and B such that:
*
* - A U B = S,
* - |A| = |B|,
* - sum(A) = sum(B),
* - sum_squares(A) = sum_squares(B).
*
*
* @author Yan Georget
*/
public class PartitionProblem extends BaseProblem {
//------------------------------------------------------------------------
// CONSTRUCTORS
//------------------------------------------------------------------------
/**
* Sole constructor.
* @param n the size of the problem
*/
public PartitionProblem(int n) {
super();
int[] s = new int[n];
int[] ss = new int[n];
// b[i] <=> i+1 is in set A
BooleanVariable[] b = new BooleanVariable[n];
for (int i=0; i