Package com.exigen.ie.constrainer

Examples of com.exigen.ie.constrainer.IntExp


  class AllDiffObserver extends Observer
  {
    public void update(Subject var, EventOfInterest interest)
        throws Failure
    {
      IntExp event_var = (IntExp)var;
      //Debug.on(); Debug.print("AllDiffObserver("+var+") "+interest+" "+_bits); Debug.off();
      int value = event_var.value();
      // check for failure
      if (!_bit_var.contains(value))
      {
        //Debug.on();Debug.print("diff fail: "+interest+_intvars+_bits);Debug.off();
        var.constrainer().fail("AllDiff"); //+_bits +" "+_intvars);
      }

      // set the bit
      int size = _intvars.size();
      _bit_var.removeValue(value)//Debug.on();Debug.print(" "+this+":  "+_bits);Debug.off();

      // additional propagation
      for(int i=0; i<size; i++)
      {
        IntExp vari = (IntExp)_intvars.elementAt(i);
        if (vari != event_var)
        {
          //Debug.on();Debug.print("alldiff remove "+value+" from "+vari);Debug.off();
          vari.removeValue(value); // may fail
        }
      }
    }
View Full Code Here


    super(vars[0].getProblem(), name);
    Problem problem = (Problem) vars[0].getProblem();
    Constrainer constrainer = problem.getConstrainer();
    IntExpArray intvars = new IntExpArray(constrainer, vars.length);
    for (int i = 0; i < vars.length; i++) {
      IntExp cvar = (IntExp) vars[i].getImpl();
      intvars.set(cvar, i);
    }
    IntExp sum = constrainer.sum(intvars);
    problem.defineConstraintImpl(this, sum, oper, var);
  }
View Full Code Here

   *
   * @param min
   *            int
   */
  public final  void setMin(int min) throws Exception {
    IntExp myVar = (IntExp) getImpl();
    myVar.setMin(min);
  }
View Full Code Here

  /**
   * @return current minimum for the domain of this variable
   */
  public final int getMin() {
    IntExp myVar = (IntExp) getImpl();
    return myVar.min();
  }
View Full Code Here

   *
   * @param value
   *            int
   */
  public final void removeValue(int value) throws Exception {
    IntExp myVar = (IntExp) getImpl();
    myVar.removeValue(value);
  }
View Full Code Here

   * This method is better to be redefined to take into consideration an actual
   * domain implementation.
   * @return the current number of values inside the domain of this variable
   */
  public final int getDomainSize() {
    IntExp myVar = (IntExp) getImpl();
    return myVar.size();
  }
View Full Code Here

   *
   * @param max
   *            int
   */
  public final void setMax(int max) throws Exception {
    IntExp myVar = (IntExp) getImpl();
    myVar.setMax(max);
  }
View Full Code Here

  /**
   * @return current maximum for the domain of this variable
   */
  public final int getMax() {
    IntExp myVar = (IntExp) getImpl();
    return myVar.max();
  }
View Full Code Here

  /**
   * @return true if the domain of the variable contains only one value
   */
  public final boolean isBound() {
    IntExp myVar = (IntExp) getImpl();
    return myVar.bound();
  }
View Full Code Here

  /**
   * Returns true if the domain of this variable contains the value.
   * @return true if the value is in the domain of this variable
   */
  public boolean contains(int value) {
    IntExp myVar = (IntExp) getImpl();
    return myVar.contains(value);
  }
View Full Code Here

TOP

Related Classes of com.exigen.ie.constrainer.IntExp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.