NO FRAMES

Class IloAlgorithm

Definition file: ilconcert/iloalg.h
The base class of algorithms in Concert Technology.

IloAlgorithm is the base class of algorithms in Concert Technology. An instance of this class represents an algorithm in Concert Technology.

In general terms, you define a model, and Concert Technology extracts objects from it for your target algorithm and then solves for solutions.

Most member functions in this class contain assert statements. For an explanation of the macro NDEBUG (a way to turn on or turn off these assert statements), see the concept Assert and NDEBUG.

Status

The member function getStatus returns a status showing information about the currently extracted model and the solution (if there is one). For explanations of the status, see the nested enumeration IloAlgorithm::Status.

Exceptions

The class IloAlgorithm::Exception, derived from the class IloException, is the base class of exceptions thrown by classes derived from IloAlgorithm. For an explanation of exceptions thrown by instances of IloAlgorithm, see IloAlgorithm::Exception.

Streams and Output

The class IloAlgorithm supports these communication streams:

Child classes:

See Also:

Constructor Summary
public IloAlgorithm(IloAlgorithmI * impl=0)
Method Summary
public voidclear() const
public voidend()
public ostream &error() const
public voidextract(const IloModel) const
public IloEnvgetEnv() const
public IloIntgetIntValue(const IloIntVar) const
public voidgetIntValues(const IloIntVarArray, IloIntArray) const
public IloModelgetModel() const
public IloNumgetObjValue() const
public IloAlgorithm::StatusgetStatus() const
public IloNumgetTime() const
public IloNumgetValue(const IloNumExprArg) const
public IloNumgetValue(const IloObjective) const
public IloNumgetValue(const IloIntVar) const
public IloNumgetValue(const IloNumVar) const
public voidgetValues(const IloIntVarArray, IloNumArray) const
public voidgetValues(const IloNumVarArray, IloNumArray) const
public IloBoolisExtracted(const IloExtractable) const
public ostream &out() const
public voidprintTime() const
public voidresetTime() const
public voidsetError(ostream &)
public voidsetOut(ostream &)
public voidsetWarning(ostream &)
public IloBoolsolve() const
public ostream &warning() const
Inner Enumeration
IloAlgorithm::Status An enumeration for the class IloAlgorithm.
Inner Class
IloAlgorithm::CannotRemoveException The class of exceptions thrown if an object cannot be removed from a model.
IloAlgorithm::CannotExtractException The class of exceptions thrown if an object cannot be extracted from a model.
IloAlgorithm::Exception The base class of exceptions thrown by classes derived from IloAlgorithm.
IloAlgorithm::NotExtractedException The class of exceptions thrown if an extractable object has no value in the current solution of an algorithm.
Constructor Detail

IloAlgorithm

public IloAlgorithm(IloAlgorithmI * impl=0)

This constructor creates an algorithm in Concert Technology from its implementation object. This is the default constructor.


Method Detail

clear

public void clear() const

This member function clears the current model from the algorithm.


end

public void end()

This member function deletes the invoking algorithm. That is, it frees memory associated with the invoking algorithm.


error

public ostream & error() const

This member function returns a reference to the stream currently used for error messages from the invoking algorithm. IloAlgorithm::error is initialized with the value of IloEnv::error.


extract

public void extract(const IloModel) const

This member function extracts the extractable objects from a model into the invoking algorithm if a member function exists to extract the objects from the model for the invoking algorithm. Not all extractable objects can be extracted by all algorithms; see the documentation of the algorithm class you are using for a list of extractable classes it supports.

When you use this member function to extract extractable objects from a model, it extracts all the elements of that model for which Concert Technology creates the representation of the extractable object suitable for the invoking algorithm.

The attempt to extract may fail. In case such a failure occurs, Concert Technology throws the exception CannotExtractException on platforms that support C++ exceptions when exceptions are enabled.

For example, a failure will occur if you attempt to extract more than one objective for an invoking algorithm that accepts only one objective, and Concert Technology will throw the exception MultipleObjException.


getEnv

public IloEnv getEnv() const

This member function returns the environment of the invoking algorithm.


getIntValue

public IloInt getIntValue(const IloIntVar) const

This member function returns the integer value of an integer variable in the current solution of the invoking algorithm. For example, to access the variable, use the member function getIntValue(var) where var is an instance of the class IloIntVar.

If there is no value to return for var, this member function raises an error. This member function throws the exception NotExtractedException if there is no value to return (for example, if var was not extracted by the invoking algorithm).


getIntValues

public void getIntValues(const IloIntVarArray, IloIntArray) const

This member function accepts an array of variables vars and puts the corresponding values into the array vals; the corresponding values come from the current solution of the invoking algorithm. The array vals must be a clean, empty array when you pass it to this member function.

If there are no values to return for vars, this member function raises an error. On platforms that support C++ exceptions, when exceptions are enabled, this member function throws the exception NotExtractedException in such a case.


getModel

public IloModel getModel() const

This member function returns the model of the invoking algorithm.


getObjValue

public IloNum getObjValue() const

This member function returns the numeric value of the objective function associated with the invoking algorithm.


getStatus

public IloAlgorithm::Status getStatus() const

This member function returns a status showing information about the current model and the solution. For explanations of the status, see the nested enumeration IloAlgorithm::Status.


getTime

public IloNum getTime() const

This member function returns the amount of time elapsed in seconds since the most recent reset of the invoking algorithm. (The member function IloAlgorithm::printTime directs the output of getTime to the output channel of the invoking algorithm.)

See Also:


getValue

public IloNum getValue(const IloNumExprArg) const

This member function returns the value of an expression in the current solution of the invoking algorithm. For example, to access the expression, use the member function getValue(expr) where expr is an instance of the class IloNumExprArg.

If there is no value to return for expr, this member function raises an error. This member function throws the exception NotExtractedException if there is no value to return (for example, if expr was not extracted by the invoking algorithm).


getValue

public IloNum getValue(const IloObjective) const

This member function returns the value of an objective in the current solution of the invoking algorithm. For example, to access the objective, use the member function getValue(obj) where obj is an instance of the class IloObjective.

If there is no value to return for obj, this member function raises an error. This member function throws the exception NotExtractedException if there is no value to return (for example, if obj was not extracted by the invoking algorithm).


getValue

public IloNum getValue(const IloIntVar) const

This member function returns the numeric value of an integer variable in the current solution of the invoking algorithm. For example, to access the variable, use the member function getValue(var) where var is an instance of the class IloIntVar.

If there is no value to return for var, this member function raises an error. This member function throws the exception NotExtractedException if there is no value to return (for example, if var was not extracted by the invoking algorithm).


getValue

public IloNum getValue(const IloNumVar) const

This member function returns the numeric value of a numeric variable in the current solution of the invoking algorithm. For example, to access the value of the variable, use the member function getValue(var) where var is an instance of the class IloNumVar.

If there is no value to return for var, this member function raises an error. This member function throws the exception NotExtractedException if there is no value to return (for example, if var was not extracted by the invoking algorithm).


getValues

public void getValues(const IloIntVarArray, IloNumArray) const

This member function accepts an array of variables vars and puts the corresponding values into the array vals; the corresponding values come from the current solution of the invoking algorithm. The array vals must be a clean, empty array when you pass it to this member function.

If there are no values to return for vars, this member function raises an error. On platforms that support C++ exceptions, when exceptions are enabled, this member function throws the exception NotExtractedException in such a case.


getValues

public void getValues(const IloNumVarArray, IloNumArray) const

This member function accepts an array of variables vars and puts the corresponding values into the array vals; the corresponding values come from the current solution of the invoking algorithm. The array vals must be a clean, empty array when you pass it to this member function.

If there are no values to return for vars, this member function raises an error. On platforms that support C++ exceptions, when exceptions are enabled, this member function throws the exception NotExtractedException in such a case.


isExtracted

public IloBool isExtracted(const IloExtractable) const

This member function returns IloTrue if extr has been extracted for the invoking algorithm; otherwise, it returns IloFalse.


out

public ostream & out() const

This member function returns a reference to the stream currently used for logging. General output from the invoking algorithm is accessible through this member function. IloAlgorithm::out is initialized with the value of IloEnv::out.


printTime

public void printTime() const

This member function directs the output of the member function IloAlgorithm::getTime to an output channel of the invoking algorithm. (The member function IloAlgorithm::getTime accesses the elapsed time in seconds since the most recent reset of the invoking algorithm.)


resetTime

public void resetTime() const

This member function resets the timer on the invoking algorithm. The type of timer is platform dependent. On Windows systems, the time is elapsed wall clock time. On UNIX systems, the time is CPU time.


setError

public void setError(ostream &)

This member function sets the stream for errors generated by the invoking algorithm. By default, the stream is defined by an instance of IloEnv as cerr.


setOut

public void setOut(ostream &)

This member function redirects the out() stream with the stream given as an argument.

This member function can be used with IloEnv::getNullStream to suppress screen output by redirecting it to the null stream.


setWarning

public void setWarning(ostream &)

This member function sets the stream for warnings from the invoking algorithm. By default, the stream is defined by an instance of IloEnv as cout.


solve

public IloBool solve() const

This member function solves the current model in the invoking algorithm. In other words, solve works with all extractable objects extracted from the model for the algorithm. The member function returns IloTrue if it finds a solution (not necessarily an optimal one). Here is an example of its use:


 if (algo.solve()) {
   algo.out() << "Status is " << algo.getStatus() << endl;
 };

If an objective of the model has been extracted into the invoking algorithm, this member function solves the model to optimality. If there is currently no objective, this member function searches for the first feasible solution. A feasible solution is not necessarily optimal, though it satisfies all constraints.


warning

public ostream & warning() const

This member function returns a reference to the stream currently used for warnings from the invoking algorithm. IloAlgorithm::warning is initialized with the value of IloEnv::warning.


Inner Enumeration Detail

Enumeration Status

Definition file: ilconcert/iloalg.h
An enumeration for the class IloAlgorithm.

IloAlgorithm is the base class of algorithms in Concert Technology, and IloAlgorithm::Status is an enumeration limited in scope to the class IloAlgorithm. The member function IloAlgorithm::getStatus returns a status showing information about the current model and the solution.

Unknown specifies that the algorithm has no information about the solution of the model.

Feasible specifies that the algorithm found a feasible solution (that is, an assignment of values to variables that satisfies the constraints of the model, though it may not necessarily be optimal). The member functions IloAlgorithm::getValue access this feasible solution.

Optimal specifies that the algorithm found an optimal solution (that is, an assignment of values to variables that satisfies all the constraints of the model and that is proved optimal with respect to the objective of the model). The member functions IloAlgorithm::getValue access this optimal solution.

Infeasible specifies that the algorithm proved the model infeasible; that is, it is not possible to find an assignment of values to variables satisfying all the constraints in the model.

Unbounded specifies that the algorithm proved the model unbounded.

InfeasibleOrUnbounded specifies that the model is infeasible or unbounded.

Error specifies that an error occurred and, on platforms that support exceptions, that an exception has been thrown.

See Also the enumeration IloCplex::Status in the ILOG CPLEX Reference Manual for status specific to the CPLEX algorithms.

See Also:

Fields
Unknown
Feasible
Optimal
Infeasible
Unbounded
InfeasibleOrUnbounded
Error