Overview | Group | Tree | Graph | Index | Concepts |
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:
IloEnv, IloModel, IloAlgorithm::Status, IloAlgorithm::Exception, IloCplex (ILOG CPLEX Reference Manual) , IloSolver (ILOG Solver Reference Manual)
Constructor Summary | |
---|---|
public | IloAlgorithm(IloAlgorithmI *) |
Method Summary | |
---|---|
public void | clear() |
public void | end() |
public ostream & | error() |
public void | extract(const IloModel) |
public IloEnv | getEnv() |
public IloInt | getIntValue(const IloIntVar) |
public void | getIntValues(const IloIntVarArray, IloIntArray) |
public IloNum | getObjValue() |
public IloAlgorithm::Status | getStatus() |
public IloNum | getTime() |
public IloNum | getValue(const IloNumExprArg) |
public IloNum | getValue(const IloObjective) |
public IloNum | getValue(const IloIntVar) |
public IloNum | getValue(const IloNumVar) |
public void | getValues(const IloIntVarArray, IloNumArray) |
public void | getValues(const IloNumVarArray, IloNumArray) |
public IloBool | isExtracted(const IloExtractable) |
public ostream & | out() |
public void | printTime() |
public void | resetTime() |
public void | setError(ostream &) |
public void | setOut(ostream &) |
public void | setWarning(ostream &) |
public IloBool | solve() |
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 |
---|
This constructor creates an algorithm in Concert Technology from its implementation object. This is the default constructor.
Method Detail |
---|
This member function clears the current model from the algorithm.
This member function deletes the invoking algorithm. That is, it frees memory associated with the invoking algorithm.
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
.
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).
This member function returns the environment of the invoking algorithm.
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).
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.
This member function returns the numeric value of the objective function associated with the invoking algorithm.
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
.
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.
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).
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).
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).
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).
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.
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.
This member function returns IloTrue
if extr
has been
extracted for the invoking algorithm; otherwise, it returns IloFalse
.
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
.
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.)
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.
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.
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.
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
.
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 |
---|
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:
IloAlgorithm, operator<<, IloCplex::Status documented in the ILOG CPLEX Reference Manual
Fields |
---|
Unknown | |
Feasible | |
Optimal | |
Infeasible | |
Unbounded | |
InfeasibleOrUnbounded | |
Error |