Overview | Group | Tree | Graph | Index | Concepts |
An instance of IloAlgorithm
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:
ostream& IloAlgorithm::error() const;
for error
messages.ostream& IloAlgorithm::out() const;
for general
output.ostream& IloAlgorithm::warning() const;
for warning
messages about nonfatal conditions.Child classes:
IloCplex
in the IBM ILOG CPLEX Reference
ManualIloCP
in the IBM ILOG CP Optimizer Reference
Manual.IloSolver
in the IBM ILOG Solver Reference Manual
.See Also:
IloEnv, IloModel, IloAlgorithm::Status, IloAlgorithm::Exception
Constructor Summary | |
---|---|
public | IloAlgorithm(IloAlgorithmI * impl=0) |
Method Summary | |
---|---|
public void | clear() const |
public void | end() |
public ostream & | error() const |
public void | extract(const IloModel) const |
public IloEnv | getEnv() const |
public IloInt | getIntValue(const IloIntVar) const |
public void | getIntValues(const IloIntVarArray, IloIntArray) const |
public IloModel | getModel() const |
public IloNum | getObjValue() const |
public IloAlgorithm::Status | getStatus() const |
public IloNum | getTime() const |
public IloNum | getValue(const IloNumExprArg) const |
public IloNum | getValue(const IloObjective) const |
public IloNum | getValue(const IloIntVar) const |
public IloNum | getValue(const IloNumVar) const |
public void | getValues(const IloIntVarArray, IloNumArray) const |
public void | getValues(const IloNumVarArray, IloNumArray) const |
public IloBool | isExtracted(const IloExtractable) const |
public ostream & | out() const |
public void | printTime() const |
public void | resetTime() const |
public void | setError(ostream &) |
public void | setOut(ostream &) |
public void | setWarning(ostream &) |
public IloBool | solve() const |
public ostream & | warning() const |
Inner Enumeration | |
---|---|
IloAlgorithm::Status |
An enumeration for the class IloAlgorithm .
|
Inner Class | |
---|---|
IloAlgorithm::CannotExtractException | The class of exceptions thrown if an object cannot be extracted from a model. |
IloAlgorithm::CannotRemoveException | The class of exceptions thrown if an object cannot be removed 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
error messages from the invoking algorithm. IloAlgorithm::error
is
initialized with the value of IloEnv::error
.
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
.
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 model of the invoking algorithm.
This member function returns the numeric value of the objective function associated with the invoking algorithm.
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
.
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:
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 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).
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).
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
logging. General output from the invoking algorithm is accessible through
this member function. IloAlgorithm::out
is initialized with the
value of IloEnv::out
.
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 cerr
.
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.
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.
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 |
---|
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:
Fields |
---|
Unknown | |
Feasible | |
Optimal | |
Infeasible | |
Unbounded | |
InfeasibleOrUnbounded | |
Error |