FRAMES NO FRAMES

IloBestInstantiate

public IloGoal IloBestInstantiate(const IloEnv env, const IloNumVar var)
public IloGoal IloBestInstantiate(const IloEnv env, const IloAnyVar var, const IloAnyValueSelector select)
public IloGoal IloBestInstantiate(const IloEnv env, const IloAnyVar var)
public IloGoal IloBestInstantiate(const IloEnv env, const IloNumVar var, const IloIntValueSelector select)
public IloGoal IloBestInstantiate(const IloEnv env, const IloIntSetVar var)
public IloGoal IloBestInstantiate(const IloEnv env, const IloAnySetVar var)
public IloGoal IloBestInstantiate(const IloEnv env, const IloIntSetVar var, const IloIntSetValueSelector select)
public IloGoal IloBestInstantiate(const IloEnv env, const IloAnySetVar var, const IloAnySetValueSelector select)
Definition file: ilsolver/ilosolverint.h
Include file: <ilsolver/ilosolver.h>

This function creates and returns a goal, using the numeric selector indicated by select. If the variable var has already been bound to a value, then this goal does nothing and succeeds. Otherwise, it sets a choice point and alters the domain of var in an attempt to assign a value to var. The way the goal alters the domain of var varies, depending on the class of var and its argument select.

When it takes an instance of the class IloEnv as a parameter, it returns an instance of IloGoal for use with the member functions IloSolver::startNewSearch and IloSolver::solve. An instance of IloSolver extracts the goal that it returns as an instance of IlcGoal for use during a Solver search.

When the Variable Is Integer or an Enumerated Variable

If its argument var has already been bound, IloBestInstantiate 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 IloBestInstantiate succeeds.

When the Variable Is a Set of Variables

If var has already been bound, then IloBestInstantiate 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 IloBestInstantiate succeeds.

Differs from IloInstantiate

This goal differs from the one returned by the function IloInstantiate. This goal tries only one value, chosen according to select, whereas when a failure occurs, IloInstantiate continues to try other values according to select until the domain of var is exhausted.

Note
Though this function works on numerical variables of type Float and type Int, it is preferable to use the function IloDichotomize with floating-point variables.

See Also: