package examples;

import static org.gecode.Gecode.post;
import static org.gecode.Gecode.rel;
import static org.gecode.GecodeEnumConstants.IRT_EQ;
import static org.gecode.GecodeEnumConstants.IRT_NQ;

import org.gecode.BExpr;
import org.gecode.Expr;
import org.gecode.IntConLevel;
import org.gecode.IntVar;
import org.gecode.Space;
import org.gecode.VarArray;

/**
 * @author stampie
 *
 */
public class ExprTest extends Space{

	IntVar variable1, variable2;
	
	public ExprTest(){
		super("Expr Test");
		variable1 = new IntVar(this, 0, 5);
		variable2 = new IntVar(this, 0, 5);
		VarArray<IntVar> vars = new VarArray<IntVar>(2);
		vars.add(variable1);
		vars.add(variable2);
	}
	
	public ExprTest (Boolean share, ExprTest sdk){
		super(share, sdk);
		this.variable1 = sdk.variable1;
		this.variable2 = sdk.variable2;
	}
	
	/* (non-Javadoc)
	 * @see org.gecode.Space#toString()
	 */
	@Override
	public String toString() {
		return "Variable #1: " + variable1.toString()
		+ "\nVariable #2: " + variable2.toString();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	    Options opt = new Options("Expression test");
	    opt.size = 9;
	    opt.gui = false;
	    opt.print = true;
	    opt.parse(args);

	    ExprTest space = new ExprTest();
	    BExpr expression = new BExpr(new Expr(new Expr(space.variable2).minus(space.variable1)), IRT_EQ, 0,IntConLevel.ICL_DOM);
	    post(space, expression);
	    //rel(space, space.variable1, IRT_EQ, space.variable2, IntConLevel.ICL_DOM);
	    post(space, new BExpr(space.variable1, IRT_NQ, 2));
	    post(space, new BExpr(space.variable1, IRT_NQ, 4));
	    opt.doSearch(space);
	    System.out.println(space.status().toString());
	    System.exit(0);
	}

}
