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 indicating 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:

ostream& IloAlgorithm::out() const; for general output.

ostream& IloAlgorithm::warning() const; for warning messages about non-fatal conditions.

See Also:

Constructor Summary
public IloAlgorithm(IloAlgorithmI *)
Method Summary
public voidclear()
public voidend()
public ostream &error()
public voidextract(const IloModel)
public IloEnvgetEnv()
public IloIntgetIntValue(const IloIntVar)
public voidgetIntValues(const IloIntVarArray, IloIntArray)
public IloNumgetObjValue()
public IloAlgorithm::StatusgetStatus()
public IloNumgetTime()
public IloNumgetValue(const IloNumExprArg)
public IloNumgetValue(const IloObjective)
public IloNumgetValue(const IloIntVar)
public IloNumgetValue(const IloNumVar)
public voidgetValues(const IloIntVarArray, IloNumArray)
public voidgetValues(const IloNumVarArray, IloNumArray)
public IloBoolisExtracted(const IloExtractable)
public ostream &out()
public voidprintTime()
public voidresetTime()
public voidsetError(ostream &)
public voidsetOut(ostream &)
public voidsetWarning(ostream &)
public IloBoolsolve()
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)

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


Method Detail

clear

public void clear()

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()

This member function returns a reference to the stream currently used for warnings from the invoking algorithm. By default, the stream is defined by an instance of IloEnv as cout.


extract

public void extract(const IloModel )

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 (documented in the ILOG CPLEX Reference Manual).


getEnv

public IloEnv getEnv()

This member function returns the environment of the invoking algorithm.


getIntValue

public IloInt getIntValue(const IloIntVar )

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 )

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.


getObjValue

public IloNum getObjValue()

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


getStatus

public IloAlgorithm::Status getStatus()

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


getTime

public IloNum getTime()

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.)

The type of time returned is platform dependent. On Windows systems, the time returned is elapsed wall clock time. On UNIX systems, the time returned is CPU time.


getValue

public IloNum getValue(const IloNumExprArg )

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 )

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 )

This member function returns the numerical 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 )

This member function returns the numeric 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 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 )

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 )

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 )

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


out

public ostream & out()

This member function returns a reference to the stream currently used for warnings from the invoking algorithm. By default, the stream is defined by an instance of IloEnv as cout.


printTime

public void printTime()

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()

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 cout.


setOut

public void setOut(ostream & )

This member function redirects the out() stream with the stream given as a parameter.

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()

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.


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 indicating information about the current model and the solution.

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

Feasible indicates 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 indicates 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 indicates 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 indicates that the algorithm proved the model unbounded.

InfeasibleOrUnbounded indicates that the model is infeasible or unbounded.

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

See Also:

Fields
Unknown
Feasible
Optimal
Infeasible
Unbounded
InfeasibleOrUnbounded
Error