Program: 76615
Project: 76615
Buggy source:
/** 
 * Solves the set of inequalities and updates the variables. If the set of inequalities is satisfiable, this method returns <code>true</code> and the variables are set to the least or greatest solution depending on the <code>least</code> parameter; if the set of inequalities is definite (see class document), and the set of inequalities is not satisfiable, this method returns <code>false</code>; if the set of inequalities is not definite, a <code>false</code> return value doesn't guarantee the set of inequalities is not satisfiable.  In the case this method returns <code>false</code>, the variable values are random.
 * @param least if <code>true</code>, this method will try tofind the least solution; otherwise, this method will try to find the greatest solution.
 * @return <code>true</code> if the set of inequalities issatisfiable; <code>false</code> if not satisfiable, or the set of inequalities is not definite.
 * @exception InvalidStateException the CPO over which theinequalities are defined is not a lattice.
 */
public boolean solve(boolean least){
  Object init=least ? _cpo.bottom() : _cpo.top();
  if (init == null) {
    throw new InvalidStateException("String_Node_Str" + "String_Node_Str");
  }
  for (Enumeration e=_Clist.keys(); e.hasMoreElements(); ) {
    InequalityTerm variable=(InequalityTerm)e.nextElement();
    try {
      variable.set(init);
    }
 catch (    IllegalActionException ex) {
      throw new RuntimeException("String_Node_Str" + "String_Node_Str" + ex.getMessage());
    }
  }
  LinkedList _NS=new LinkedList();
  for (int i=0; i < _Ilist.size(); i++) {
    Info info=(Info)_Ilist.elementAt(i);
    info._inCvar=least ? info._ineq.greaterTerm().settable() : info._ineq.lesserTerm().settable();
    if (info._inCvar) {
      if (info._ineq.satisfied(_cpo)) {
        info._inserted=false;
      }
 else {
        _NS.insertLast(new Integer(i));
        info._inserted=true;
      }
    }
  }
  while (_NS.size() > 0) {
    int index=((Integer)(_NS.first())).intValue();
    _NS.removeFirst();
    Info info=(Info)(_Ilist.elementAt(index));
    info._inserted=false;
    Object value=null;
    InequalityTerm updateTerm=null;
    if (least) {
      updateTerm=info._ineq.greaterTerm();
      value=_cpo.lub(info._ineq.lesserTerm().value(),updateTerm.value());
    }
 else {
      updateTerm=info._ineq.lesserTerm();
      value=_cpo.glb(updateTerm.value(),info._ineq.greaterTerm().value());
    }
    if (value == null) {
      throw new InvalidStateException("String_Node_Str" + "String_Node_Str");
    }
    try {
      updateTerm.set(value);
    }
 catch (    IllegalActionException ex) {
      throw new RuntimeException("String_Node_Str" + "String_Node_Str" + ex.getMessage());
    }
    Vector affected=(Vector)_Clist.get(updateTerm);
    for (int i=0; i < affected.size(); i++) {
      Integer index1Wrap=(Integer)(affected.elementAt(i));
      int index1=index1Wrap.intValue();
      Info affectedInfo=(Info)_Ilist.elementAt(index1);
      if (index1 != index && affectedInfo._inCvar) {
        if (info._ineq.satisfied(_cpo)) {
          if (info._inserted) {
            _NS.removeOneOf(index1Wrap);
          }
        }
 else {
          if (!info._inserted) {
            _NS.insertFirst(index1Wrap);
          }
        }
      }
    }
  }
  for (int i=0; i < _Ilist.size(); i++) {
    Info info=(Info)_Ilist.elementAt(i);
    if (!info._inCvar) {
      if (!info._ineq.satisfied(_cpo)) {
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Solves the set of inequalities and updates the variables. If the set of inequalities is satisfiable, this method returns <code>true</code> and the variables are set to the least or greatest solution depending on the <code>least</code> parameter; if the set of inequalities is definite (see class document), and the set of inequalities is not satisfiable, this method returns <code>false</code>; if the set of inequalities is not definite, a <code>false</code> return value doesn't guarantee the set of inequalities is not satisfiable.  In the case this method returns <code>false</code>, the variable values are random.
 * @param least if <code>true</code>, this method will try tofind the least solution; otherwise, this method will try to find the greatest solution.
 * @return <code>true</code> if the set of inequalities issatisfiable; <code>false</code> if not satisfiable, or the set of inequalities is not definite.
 * @exception InvalidStateException the CPO over which theinequalities are defined is not a lattice.
 */
public boolean solve(boolean least){
  Object init=least ? _cpo.bottom() : _cpo.top();
  if (init == null) {
    throw new InvalidStateException("String_Node_Str" + "String_Node_Str");
  }
  for (Enumeration e=_Clist.keys(); e.hasMoreElements(); ) {
    InequalityTerm variable=(InequalityTerm)e.nextElement();
    try {
      variable.set(init);
    }
 catch (    IllegalActionException ex) {
      throw new RuntimeException("String_Node_Str" + "String_Node_Str" + ex.getMessage());
    }
  }
  LinkedList _NS=new LinkedList();
  for (int i=0; i < _Ilist.size(); i++) {
    Info info=(Info)_Ilist.elementAt(i);
    info._inCvar=least ? info._ineq.greaterTerm().settable() : info._ineq.lesserTerm().settable();
    if (info._inCvar) {
      if (info._ineq.satisfied(_cpo)) {
        info._inserted=false;
      }
 else {
        _NS.insertLast(new Integer(i));
        info._inserted=true;
      }
    }
  }
  while (_NS.size() > 0) {
    int index=((Integer)(_NS.first())).intValue();
    _NS.removeFirst();
    Info info=(Info)(_Ilist.elementAt(index));
    info._inserted=false;
    Object value=null;
    InequalityTerm updateTerm=null;
    if (least) {
      updateTerm=info._ineq.greaterTerm();
      value=_cpo.lub(info._ineq.lesserTerm().value(),updateTerm.value());
    }
 else {
      updateTerm=info._ineq.lesserTerm();
      value=_cpo.glb(updateTerm.value(),info._ineq.greaterTerm().value());
    }
    if (value == null) {
      throw new InvalidStateException("String_Node_Str" + "String_Node_Str");
    }
    try {
      updateTerm.set(value);
    }
 catch (    IllegalActionException ex) {
      throw new RuntimeException("String_Node_Str" + "String_Node_Str" + ex.getMessage());
    }
    Vector affected=(Vector)_Clist.get(updateTerm);
    for (int i=0; i < affected.size(); i++) {
      Integer index1Wrap=(Integer)(affected.elementAt(i));
      int index1=index1Wrap.intValue();
      Info affectedInfo=(Info)_Ilist.elementAt(index1);
      if (index1 != index && affectedInfo._inCvar) {
        if (affectedInfo._ineq.satisfied(_cpo)) {
          if (affectedInfo._inserted) {
            _NS.removeOneOf(index1Wrap);
          }
        }
 else {
          if (!affectedInfo._inserted) {
            _NS.insertFirst(index1Wrap);
          }
        }
      }
    }
  }
  for (int i=0; i < _Ilist.size(); i++) {
    Info info=(Info)_Ilist.elementAt(i);
    if (!info._inCvar) {
      if (!info._ineq.satisfied(_cpo)) {
        return false;
      }
    }
  }
  return true;
}