Package com.exigen.ie.constrainer

Examples of com.exigen.ie.constrainer.IntExp


    int possible_instances = 0;
    int required_instances = 0;
    for(int i=0; i<size; i++)
    {
      IntExp exp = (IntExp)vars.elementAt(i);
      if (exp.contains(card_value))
      {
        possible_instances++;
        if (exp.bound())
          required_instances++;
      }
    }
    try
    {
View Full Code Here


      if (_possible_required.min() == max())
      {
        // remove _card_value from all unbounds
        for(int i=0; i<_vars.size(); i++)
        {
          IntExp vari = (IntVar)_vars.elementAt(i);
          if (!vari.bound())
            vari.removeValue(_card_value);
        }
      }

    }
View Full Code Here

      int cardinality = e.max();
      if (_possible_required.min() == cardinality)
      { // remove _value from all unbounds
        for(int i=0; i<_vars.size(); i++)
        {
          IntExp vari = (IntVar)_vars.elementAt(i);
          if (!vari.bound())
            vari.removeValue(_card_value);
        }
      }
    }
View Full Code Here

    IntExp[] vars = _vars.data();

    for(int i=0; i < vars.length; i++)
    {
      IntExp vari = vars[i];
      int maxi = max - (min_sum - vari.min());
      if (maxi < vari.max())
      {
        vari.setMax(maxi);
      }
    }
//    System.out.println("---- set max:" + max + " in " + this);
  }
View Full Code Here

    IntExp[] vars = _vars.data();

    for(int i=0; i < vars.length; i++)
    {
      IntExp vari = vars[i];
      int mini = min - (max_sum - vari.max());
      if (mini > vari.min())
      {
        vari.setMin(mini);
      }
    }
//    System.out.println("---- set min:" + min + " in " + this);
  }
View Full Code Here

    IntExp[] vars = _vars.data();

    for(int i=0; i < vars.length; i++)
    {
      IntExp vari = (IntExp)vars[i];
      int mini = vari.min();
      int maxi = vari.max();

      int new_min = value - (sum_max - maxi);
      if (new_min > mini)
      {
        vari.setMin(new_min);
      }

      int new_max = value - (sum_min - mini);
      if (new_max < maxi)
      {
        vari.setMax(new_max);
      }
    }

//    System.out.println("---- set value: " + value + " in " + this);
  }
View Full Code Here

    IntExp[] vars = _vars.data();

    for(int i=0; i < vars.length; i++)
    {
      IntExp vari = vars[i];
      int mini = vari.min();
      int maxi = vari.max();

      int new_min = minC - (maxE - maxi);
      if (new_min > mini)
      {
        vari.setMin(new_min);
      }

      int new_max = maxC - (minE - mini);
      if (new_max < maxi)
      {
        vari.setMax(new_max);
      }
    }
  }
View Full Code Here

  {
    // initial propagation
    int size = _intvars.size();
    for(int i=0; i<size; i++)
    {
      IntExp vari = (IntExp)_intvars.elementAt(i);
      if (vari.bound())
      {
        int value = vari.value();
        boolean bit = _bits.bit(value);
        // check for failure
        if (bit)
        {
          constrainer().fail("Diff");
        }
        _bits.bit(value,true);
        constrainer().addUndo(UndoBits.getUndo(_bits,value));
      }
    }

    // attach observers
    Observer value_observer = new AllDiffObserver();
    Observer minmax_observer = new AllDiffMinMaxObserver();
    for(int i=0; i<size; i++)
    {
      IntExp vari = (IntExp)_intvars.elementAt(i);
      vari.attachObserver(value_observer);
    }

    return null;
  } // end of execute
View Full Code Here

  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 size = _intvars.size();
      int value = event_var.value();
      boolean bit = _bits.bit(value);
      // check for failure
      if (bit)
      {
        //Debug.on();Debug.print("diff fail: "+interest+_intvars+_bits);Debug.off();
        var.constrainer().fail("AllDiff"); //+_bits +" "+_intvars);
      }

      // set the bit
      _bits.bit(value,true)//Debug.on();Debug.print(" "+this+":  "+_bits);Debug.off();
      var.constrainer().addUndo(UndoBits.getUndo(_bits,value));

      // additional propagation

      IntExp[] data = _intvars.data();

      for(int i=0; i < size; i++)
      {
        IntExp vari = data[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

      int min = _bits.min();
      int max = _bits.max();
      //Debug.on();Debug.print("alldiff minmax "+interest+":  "+_bits);Debug.off();
      for(int i=0; i<_intvars.size(); i++)
      {
        IntExp vari = (IntExp)_intvars.elementAt(i);
        if (!vari.bound())
        {
          for(int v=min; v <=max; v++)
          {
            if (_bits.bit(v) && vari.contains(v))//(v==vari.min() || v==vari.max()))
            {
              //Debug.on();Debug.print("alldiff minmax remove "+v+" from "+vari);Debug.off();
              vari.removeValue(v); // may fail
              if (vari.bound())
                break;
            }
          }
        }
      }
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.