FRAMES NO FRAMES

IlcBestInstantiate

public IlcGoal IlcBestInstantiate(const IlcIntVar var)
public IlcGoal IlcBestInstantiate(const IlcAnyVar var)
public IlcGoal IlcBestInstantiate(const IlcAnyVar var, IlcAnySelect select)
public IlcGoal IlcBestInstantiate(const IlcIntVar var, IlcIntSelect select)
Definition file: ilsolver/ilcint.h
Include file: <ilsolver/ilosolver.h>

This function returns a goal, a primitive in the algorithms that search for solutions. That goal is used to assign a value to a constrained variable.

If its argument var has already been bound, IlcBestInstantiate does nothing and succeeds. Otherwise, it sets a choice point and binds the invoking constrained variable to a value from its domain. If the optional argument select is provided, then that value is chosen by select; otherwise, the values are tried in ascending order when the values are integers. If a failure occurs, the tried-and-failed value is removed from the domain, and IlcBestInstantiate succeeds.

This function differs from the function IlcInstantiate in that respect. IlcBestInstantiate tries only one value, whereas when a failure occurs with IlcInstantiate, Solver continues trying other values until all the values in the domain of that variable have been tried before it goes on to another variable.

Implementation

This goal can be defined like this for IlcIntVar:

 static
 ILCGOAL2(IlcIntBestInstantiate,
          IlcIntVar, var,
          IlcIntSelectI*, select) {
     if (var.isBound()) return 0;
     IlcInt val = (select)? select->select(var) : var.getMin();
     return IlcOr(var == val,
                  var != val);
 }
 IlcGoal IlcBestInstantiate(IlcIntVar var){
     return IlcIntBestInstantiate(var, 0);
 }
 IlcGoal IlcBestInstantiate(IlcIntVar var, IlcIntSelect sel){
     return IlcIntBestInstantiate(var, sel.getImpl());
 }

The code is similar for IlcAnyVar.

For more information, see the concept Choice Point.

See Also:


IlcBestInstantiate

public IlcGoal IlcBestInstantiate(const IlcIntSetVar var)
public IlcGoal IlcBestInstantiate(const IlcAnySetVar var)
public IlcGoal IlcBestInstantiate(const IlcAnySetVar var, IlcAnySetSelect select)
public IlcGoal IlcBestInstantiate(const IlcIntSetVar var, IlcIntSetSelect select)
Definition file: ilsolver/intset.h
Include file: <ilsolver/ilosolver.h>

This function returns a goal, a primitive in the algorithms that search for solutions. That goal is used to assign a value to a constrained variable. This function differs from the function IlcInstantiate (which tries all values in a domain); IlcBestInstantiate tries only one possible value. It behaves slightly differently, depending on the class of its arguments.

If var has already been bound, then IlcBestInstantiate does nothing and succeeds. Otherwise, it sets a choice point, then adds an element of the possible set to the required set of var. The added element is chosen by select, if that optional argument is provided; otherwise, the values are tried in ascending order when the values are integers. If failure occurs, the element is removed from the possible set of var, and IlcBestInstantiate succeeds.

For more information, see the concept Choice Point.

See Also:


IlcBestInstantiate

public IlcGoal IlcBestInstantiate(const IlcFloatVar var, IlcBool increaseMinFirst=IlcTrue, IlcFloat prec=0)
Definition file: ilsolver/nlinflt.h
Include file: <ilsolver/ilosolver.h>

This function returns a goal, a primitive in the algorithms that search for solutions. That goal is used to assign a value to a constrained variable. This function differs from the function IlcInstantiate (which tries all values in a domain); IlcBestInstantiate tries only one possible value. It behaves slightly differently, depending on the class of its arguments.

If var has already been bound, then IlcBestInstantiate does nothing and succeeds. Otherwise, it sets a choice point, then replaces the domain of var by one of its halves. If a failure occurs then, the domain is replaced by the other half.

The optional argument increaseMinFirst must be a Boolean value, either IlcTrue or IlcFalse. If it is IlcTrue, then the upper half of the domain is tried first; otherwise, the lower half is tried first.

For more information, see the concept Choice Point.

See Also: