Overview | Group | Tree | Graph | Index | Concepts |
An instance of this class represents an algorithm for IBM® ILOG® Solver.
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.
Choice Functions and Criteria
An instance of IloSolver
allows you to set parameters to
control the order in which constrained variables are bound to values. You
control these search primitives by means of choice functions and criteria.
In Concert Technology, the classes listed in IloChoose
support
these search primitives in a model.
Enumeration Algorithms
There are enumeration algorithms available in an instance of
IloSolver
. With IBM ILOG Concert Technology, you access those
enumeration algorithms most easily through predefined goals, such as
IloBestGenerate
, IloBestInstantiate
, IloGenerate
, and IloInstantiate
, in a model.
Modifying the Search Globally
These member functions have an overall effect on the search performed by
IloSolver::solve
. They allow you to limit the
number of failures, the number of choice points, or the amount of time spent
in a search.
void setFailLimit (IloInt numberOfFailures) const; void setTimeLimit (IloNum time) const; void setOrLimit (IloInt numberOfChoicePoints) const;
The following member function lets you control the granularity of the optimization:
void setOptimizationStep (IloNum step) const;
Nonlinear Propagation Techniques
When you use the member function IloSolver::useNonLinConstraint
, the invoking solver will use nonlinear
propagation techniques for all the nonlinear constraints in your model.
In addition, when the set of nonlinear constraints is a square system of equations or a square system of inequalities, a global constraint will be posted. This constraint may allow for additional propagation.
Furthermore it may allow you to prove that the solution-interval found for the system of nonlinear constraints surely contains a solution.
The keep
parameter of IloSolver::useNonLinConstraint
specifies whether or not in addition to
the advanced propagation techniques the invoking solver should also use its
default propagation. If keep
is IlcTrue
constraints are propagated only by the nonlinear propagation techniques; if
keep
is IlcFalse
, the invoking solver will use
nonlinear propagation techniques as well as its default propagation
techniques.
By default, when you use nonlinear propagation techniques, the default
precision (indicated by IloSolver::getDefaultPrecision
and changed by IloSolver::setDefaultPrecision
) is
respected. However, you can set your own value to use with nonlinear
constraints and to use in the safety of solutions by means of the member
function IloSolver::setNonLinPrecision
and
IloSolver::getNonLinPrecision
.
Example
Here is an example using nonlinear propagation techniques.
#include <ilconcert/ilomodel.h> #include <ilconcert/ilosolver.h> ILOSTLBEGIN int main () { try { IloEnv env; IloModel model(env); IloNumVar x(env,-10, 10); IloNumVar y(env,-10, 10); IloNumVarArray vars(env, 2, x, y); model.add(IloSquare(x) + IloSquare(y) == 1); model.add(IloSquare(x) == y); IloSolver solver(env); solver.useNonLinConstraint(); solver.extract(model); solver.startNewSearch(IloSplit(env, vars)); IloInt nbSol = 0; while (solver.next()) { nbSol++; solver.out() << ?Sol#? << nbSol << ? ?; if (solver.isNonLinSafe()) solver.out() << ?[SAFE] ?; solver.out() << endl; solver.out() << ?x: ? << solver.getFloatVar(x) << endl; solver.out() << ?y: ? << solver.getFloatVar(y) << endl; solver.out() << endl; } env.end(); } catch (IloException& ex) { cerr << ?Error: ? << ex << endl; } return 0; }
Here is the result of that program:
Sol#1 [SAFE] x: [0.786151..0.786152] y: [0.618033..0.618034] Sol#2 [SAFE] x: [-0.786152..-0.786151] y: [0.618033..0.618034]
Safe Solutions
When it is working with constrained floating-point variables, an instance
of IloSolver
returns an interval or set of intervals possibly
containing a solution. Practical considerations about the representation of
real numbers as floating-point values on any computing platform make it
difficult to predict whether an interval of a given precision contains a
unique solution (that is, an assignment of values to variables that
satisfies the constraints of the problem).
However, in some cases, the algorithms of IloSolver
can
prove the existence of solutions within precisely defined intervals. In its
search for solutions, an instance of IloSolver
regards a
solution as safe if it is certain that a solution exists within the
most recently returned intervals. When it proves a solution safe, it
considers the model most recently synchronized within a call to the member
functions IloSolver::solve
or IloSolver::startNewSearch
.
The member function IloSolver::isNonLinSafe
applies
to the non linear constraints of a problem; it tells you whether Solver has
proved the existence of a solution with respect to the non linear
constraints of a problem within the most recently returned set of intervals.
The return value of this member function applies only to the non linear
constraints of a problem; that is, it can prove that the set of non linear
constraints has a solution, but it says nothing about any other constraints
in the problem. In some cases, there may be other constraints that are
not non linear (constraints such as IloAllDiff
, for
example; in other words, constraints that are not non linear equalities or
inequalities) in the problem that make it impossible to find a solution to
the problem in its entirety.
Exceptions
Early versions of Solver raised errors in case of anomalous
situations. Those errors were associated with an error code enumerated in
IlcErrorType
. As of version 5.0, an instance
of IloSolver
now silently transforms an error into an
exception, that is, an instance of
IloSolver::SolverErrorException
. The member function
IloSolver::SolverErrorException::getErrorType
will return the
IlcErrorType
.
See Also:
IloAddConstraint, IloSynchronizeMode, IloSolver::FailureStatus
Constructor Summary | |
---|---|
public | IloSolver(const IloEnv & env) |
public | IloSolver(const IloModel & model) |
Inherited Methods from IloAlgorithm |
---|
clear, end, error, extract, getEnv, getIntValue, getIntValues, getModel, getObjValue, getStatus, getTime, getValue, getValue, getValue, getValue, getValues, getValues, isExtracted, out, printTime, resetTime, setError, setOut, setWarning, solve, warning |
Inner Enumeration |
---|
IloSolver::FailureStatus |
Constructor Detail |
---|
This constructor creates an algorithm for IBM® ILOG® Solver.
This constructor creates an algorithm for IBM ILOG Solver. Actual propagation of all
constraints added to the model model
will take place either at the next
solve()
or at the next solver.next()
.
Examples:
When you create an algorithm (an instance of IloSolver
, for example)
and extract a model for it, you can write either this line:
IloSolver solver(model);
or these two lines:
IloSolver solver(env); solver.extract(model);
Those two lines may be useful when you want to attach your own specialized extractor to the algorithm you are creating before you extract a particular model.
Method Detail |
---|
This member function adds all the constraints in the array constraints
to the
invoking solver so that the invoking solver takes them into account during its search. You can
use this member function only during search.
This member function adds constraint
to the invoking solver so that the invoking
solver takes constraint
into account during its search. You can use this member
function only during search.
This member function adds the memory manager indicated by mm
to the list of memory managers
known to the invoking solver.
When you call the member function IloSolver::end
or when the solver re-extracts the model
during synchronization, it will call the virtual member function IlcMemoryManagerI::end
for
all the memory managers known to the invoking solver.
The purpose of a memory manager is to delete automatically any memory not allocated through the Solver heap. Consequently, this member function is conventionally used at run time, like this:
solver.addMemoryManager(new(solver.getHeap()) MyMemoryManager());
where solver
is the invoking solver and MyMemoryManager
is a class where you
have defined MyMemoryManager::end
to delete memory appropriately.
This member function adds the goal
to the invoking solver. The invoking solver will then
treat goal
as a reversible object with respect to memory management, backtracking, choice points,
and so forth.
It is possible to “undo” actions that are not simple assignments—such actions as drawing in a graphic interface or dealing with files.
For managing reversible changes that are not assignments, Solver provides reversible actions. Such
actions are executed when Solver restores the state of the invoking solver. A reversible action is created by
the member function addReversibleAction
.
However, it is much more efficient to use the reversible classes—IlcRevInt
,
IlcRevAny
, IlcRevBool
,
IlcRevFloat
—to manage reversible assignments than to use reversible actions.
In the member function addReversibleAction
, the argument goal
must be a goal
that does not change the state of the invoking solver. That is, it must not execute any reversible assignments,
nor call other goals, nor call the member function fail
. The member function addReversibleAction
saves its argument, goal
, as a reversible action. If Solver backtracks to a choice point that was set
before this call to addReversibleAction
, then goal
will be executed.
Since reversible actions do not have subgoals, demons are usually used for implementing them.
The execution of reversible actions is interleaved with the restoration of reversible states. Thus when a
reversible goal is called, the state of the invoking solver is the same as the state of the invoking solver
when addReversibleAction
was called.
Reversible actions can be used to display the search for a solution through a graphic user interface. See the Solver User's Manual for an example (about animating graphic interfaces) showing how to do this.
This member function adds a hook to set the trace to the start of the search search
.
This member function indicates whether the arithmetic division operator
/
is restricted to numeric division only. If the return value
is IloTrue
, operator /
is restricted, and integer
division is accessible only through the IloDiv function.
If the return value is IloFalse
, operator /
* performs division resulting in, in general, a non-integral result.
For compatibility with previous versions of
Solver, the default value is IloFalse
, meaning the
division of two integer expressions using operator
is
another integer expression.
This member function specifies whether the arithmetic division operator
/
is restricted to numeric division only. If snd
is IloTrue
, operator /
is restricted, and integer
division is accessible only through the IloDiv function.
If snd
is IloFalse
, operator /
performs division resulting in, in general, a non-integral result.
For compatibility with previous versions of
Solver, the default value is IloFalse
, meaning the
division of two integer expressions using operator
is
another integer expression.
This member function commits the current search to be confined to the part
of the search tree below the closest choice point with label
label
. In case no such choice point exists, this method then
commits the search to the current state and removes all remaining open choice
points or open search nodes.
This member function "cleans house" by freeing all memory allocated by Solver on the
Solver heap for the invoking solver. Since it destroys the invoking solver and all objects
associated with the invoking solver, you must not use the solver nor any object
created with this solver after you call this member function. This member function is called
automatically by IloEnv::end
.
If you also want this member function to delete automatically memory that you allocate
that is not on the Solver heap, then you should add a memory manager, an instance of
IlcMemoryManagerI
, to the list of memory managers associated with the invoking
solver. See the class IlcMemoryManagerI
for details.
See Also:
This member function terminates a search and deletes the internal objects created by Solver to carry out the search (such internal objects as the search tree, choice points, goal stack, etc.)
This member function completely exits the search.
This member function extracts all the extractable objects added to
model for the invoking algorithm. This member function discards any previously
extracted model. Actual propagation of all constraints added to the model
model
will take place either at the next
solve()
or at the next solver.next()
.
The failure of a goal is triggered by this member function. In fact, this member function triggers the failure of the current goal. The execution of the current goal then stops, and execution returns to the last choice point satisfying the following conditions:
label
is not 0 (zero), the choice point has the same label as
label
.If no such choice point exists, then the current call to IloSolver::solve or
IloSolver::next terminates and returns IloFalse
.
If fail
is called outside a call to IloSolver::solve or a call to
IloSolver::next, then an error is raised.
In other words, when the member function fail
is called, goal execution resumes at
the last choice point with untried subgoals. It is possible to resume goal execution at an earlier
choice point by associating labels with choice points. Then the member function fail
can be called with a label, and in that case, goal execution resumes at the last choice point with that label.
This member function returns the demon currently executing in the invoking solver. It returns an empty handle if there is no such demon.
This member function returns the search goal currently executing in the invoking solver. It returns an empty handle if there is no such goal.
This member function returns the Ilc
class (that is, the extracted search class)
corresponding to the Ilo
class (that is, the model class) of arg
.
This member function returns the Ilc
class (that is, the extracted search class)
corresponding to the Ilo
class (that is, the model class) of arg
.
This member function returns the value that var
assumes in a solution.
This member function returns the algorithmically constrained enumerated set variable corresponding
to the modeling variable indicated by var
.
This member function returns the array of algorithmically constrained enumerated set variables
corresponding to the array of modeling variables indicated by vars
.
This member function returns the modeling value that var
assumes in a solution.
This member function returns the algorithmically constrained enumerated variable corresponding to
the modeling variable indicated by var
.
This member function returns the array of algorithmically constrained enumerated variables corresponding
to the array of modeling variables indicated by vars
.
This member function returns the box associated with the IloBox
object in the invoking solver.
This member function returns a floating point number between 0 and 1,
which represents the proportion of removed intervals from the intervals of
x
during the last constraint propagation.
This member function returns a floating point number between 0 and 1,
which represents the proportion of removed intervals from the intervals of
x
during the last constraint propagation.
This member function returns a floating point number between 0 and 1,
which represents the proportion of removed values from the domain of
x
during the last constraint propagation.
This member function returns a floating point number between 0 and 1,
which represents the proportion of removed values from the domain of
x
during the last constraint propagation.
This member function returns the constraint corresponding to the modeling constraint
indicated by ct
.
This member function returns the number of active nodes currently open in the search carried on by the invoking solver.
This member function returns the default precision of the invoking solver. That value is used in managing
constrained floating-point expressions (instances of IlcFloatExp
and its subclasses)
if you associate no other relative precision with a given expression. That value in a solver is always greater
than or equal to 2.10-11. It is initially 1.10-10
This member function returns the degree of the variable x
.
The degree is the number of uninstantiated variables appearing in a constraint
where x
also appears. This value changes throughout search.
This function can be called only when the aggregator obtained by the function
IlcDegreeInformation
is used. Moreover, it can be called only on variables corresponding to
IloIntVar
appearing in the extracted model.
This member function returns the degree of the variable x
.
The degree is the number of uninstantiated variables appearing in a constraint
where x
also appears. This value changes throughout search. This
function can be called only when the aggregator obtained by the function
IlcDegreeInformation
is used. Moreover, it can be called only
on variables corresponding to IloIntVar
appearing in the
extracted model.
This member function displays part of the statistics about the current state of the invoking solver
available from IloSolver::printInformation
. In particular, it returns the
the elapsed time (sometimes known as wall clock time) of the solver, in seconds, since the most recent
extraction of a model or the most recent synchronization of a model.
This member function returns an identifier (one of the choices of the nested enumeration
IloSolver::FailureStatus
) that indicates the failure status of an instance of
IloSolver
after an unsuccessful IloSolver::solve or
IloSolver::next. Possible values of FailureStatus
are:
enum FailureStatus { searchHasNotFailed, searchFailedNormally, searchStoppedByLimit, searchStoppedByLabel, searchStoppedByExit, unknownFailureStatus };
This member function returns the Ilc
class (that is, the extracted search class)
corresponding to the Ilo
class (that is, the model class) of arg
.
This member function returns a value (one of the choices of the enumeration IlcFloatDisplay
)
that indicates how the invoking solver will display the values of constrained floating-point variables as output.
This member function returns the floatting point expression corresponding
to the modeling numerical expression indicated by expr
.
This member function returns the algorithmically constrained floating-point variable corresponding
to the modeling variable indicated by var
.
This member function returns the array of algorithmically constrained floating-point variables
corresponding to the modeling variables indicated by vars
.
This member function returns a pointer to the heap associated with the invoking solver. Use this member
function with the overloaded new
operator, like this new (solver.getHeap())
.
This member function returns the impact of a variable. This impact is the sum of the impact of each value in its current domain.
This member function returns the average of observed impacts on the assignment
x = v
so far. The impact of an assignment x = v
is the
proportion of the search space that this assignment eliminates by constraint
propagation. When countFails
is set to IloTrue
,
failures of the assignment are also counted as having an impact of 1.0.
Otherwise they are not taken into account in the average.
This member function returns the undocumented class IloSolverI*
.
This member function returns the Ilc
class (that is, the extracted search class)
corresponding to the Ilo
class (that is, the model class) of arg
.
This member function returns the integer expression corresponding to the modeling integer
expression indicated by expr
.
This member function returns the Ilc
class (that is, the extracted search class)
corresponding to the Ilo
class (that is, the model class) of arg
.
This member function returns the modeling value that var
assumes in a solution.
This member function returns the algorithmically constrained set variable
corresponding to the modeling variable indicated by var
.
This member function returns the array of algorithmically constrained
integer set variables corresponding to the array of modeling variables
indicated by vars
.
This member function returns the algorithmically constrained integer variable corresponding to
the modeling variable indicated by var
.
This member function returns the array of algorithmically constrained integer variables corresponding
to the modeling variables indicated by vars
.
This member function computes and returns the impact on the assignment
x = v
. The impact is the proportion of the search space that
this assignment eliminates by constraint propagation at the place where this
function is called.
This member function computes the impact of the assignment
x = v
for each value v
in the current domain
of x
and returns the sum of these impacts.
This member function returns the maximum value of the numeric variable v
.
This member function returns the maximum amount of memory used to store nodes during the search by the invoking solver.
This member function displays part of the statistics about the current state of the invoking solver
available from IloSolver::printInformation
. In particular, it returns the
total memory, in bytes, used by the invoking solver.
This member function returns the minimum value of the numeric variable v
.
When you are using non-linear constraint propagation (by means of the member function
IloSolver::useNonLinConstraint
), this member function returns the precision of
non-linear constraint propagation with respect to floating-point values and with respect to the safety of solutions.
This member function displays part of the statistics about the current state of the invoking solver
available from IloSolver::printInformation
. In particular, it returns the
number of choice points since the most recent extraction or synchronization of a model by the invoking solver.
This member function displays part of the statistics about the current state of the invoking solver available
from IloSolver::printInformation
. In particular, it returns the number of constraints
extracted for the invoking solver.
This member function returns the number of nodes discarded during the search by the invoking solver.
This member function returns the number of times the assignment
x = v
has failed at this point in the search.
This member function displays part of the statistics about the current state of the invoking solver available
from IloSolver::printInformation
. In particular, it returns the number of failures
since the most recent extraction or synchronization of a model by the invoking solver.
A reset of a model in the invoking solver will occur under any of these conditions:
startNewSearch(IlcSynchronizeAndRestart)
.This member function returns the number of node files used during the search by the invoking solver.
This member function returns the number of times the assignment
x = v
has been made at this point in the search.
This member function returns the number of moves performed during the search in the search tree by the invoking solver since the most recent extraction or synchronization of a model by the invoking solver.
This member function returns the number of choice points recomputed by the invoking solver since the most recent extraction or synchronization of a model by the invoking solver.
This member function displays part of the statistics about the current state of the invoking solver available
from IloSolver::printInformation
. In particular, it returns the number of
constrained variables extracted for the invoking solver.
This member function returns the current optimization step. The
optimization step indicates how much improvement there must be between solutions during the
search launched by IloSolver::solve
.
This member function returns a pointer to the heap where persistent objects of the search are stored. When the invoking solver is deleted, this heap will be deleted, too.
This member function returns a random number generator. This can be convenient as it can be reduce the number of places that a random number generator needs to be explicitly passed in user code.
This member function returns the difference between the domain size of
x
before and after the the last constraint propagation.
This member function returns the difference between the domain size of
x
before and after the last constraint propagation.
This member function returns the number of removed values from the domain
of x
during the last constraint propagation.
This member function returns the number of removed values from the domain
of x
during the last constraint propagation.
This member function returns the relative optimization step. For example, if the optimization step is 90%, Solver searches for a solution where the objective value is less than 90% of the objective value of the best solution found so far.
This member function returns the amount of memory currently used to store nodes by the invoking solver.
This member function returns the current open node being explored by the invoking solver.
This member function returns the rate of instantiations
x = v
that fails by considering only values
v
that are in the current domain of x
.
This member function returns the success rate of assignment
x = v
at this point in the search. The success rate is the proportion
of assignments of this kind that does not fail.
This member function displays part of the statistics about the current state of the invoking solver
available from IloSolver::printInformation
. In particular, it returns the
total running time of the solver, in seconds, since the most recent extraction of a model or the most recent
synchronization of a model.
This member function returns the total number of nodes created during the search by the invoking solver since the most recent extraction or synchronization of a model by the invoking solver.
This member function returns the value of the numeric variable v
.
This member function returns a positive integer identifying the current worker (an instance of
IloSolver
). These identifying numbers start from 0
(zero) and are contiguous.
In a sequential search, this member function always returns 0
.
This member function checks whether an extractable ext
has been
extracted by Solver.
This member function returns IloTrue
if the invoking solver is jumping from one open node
to another using recomputation. It returns IloFalse
otherwise.
This member function returns IloTrue
if the invoking solver is conducting a search; otherwise,
it returns IloFalse
.
This member function returns IloTrue
if var represents an integer variable in the
invoking solver; it returns IloFalse
otherwise.
This member function applies only to the non linear equalities and inequalities in a model; it says
nothing about constraints that are not non linear equalities or inequalities. It returns
IloTrue
if the solution returned by the invoking solver has been proved safe in the sense
explained in Safe Solutions. In short, there is a solution (an assignment of values to variables
satisfying all non linear constraints in the model) in the interval returned by the solver. It returns
IloFalse
otherwise.
This member function searches for the next solution in the search tree of the invoking
IloSolver
object.
The first time next
is called, it iteratively pops one goal from the goal
stack and executes it. The execution of the goal can add other goals to the stack and can
set choice points.
The execution of next
terminates in two cases. First, when the goal stack
becomes empty, this member function returns IloTrue
. Second, if a failure occurs
and no choice point with untried subgoals and correct labels exists, the member function
restores the state of the invoking search and returns IloFalse
.
The second execution and subsequent executions of next
start from where the
preceding execution left off. If a solution was found, then Solver backtracks and searches
for the next solution. If no solution was found, this member function immediately returns
IloFalse
.
This member function returns IloTrue
when it has found a solution.
This member function is part of the special purpose debugging features of Solver. It displays
statistics about the current state of the solver since the most recent extraction of a model or the
most recent synchronization of a model and prints to stream stream
. For more information,
see IloSolver::printInformation
.
This member function is part of the special purpose debugging features of Solver. It displays statistics about the current state of the solver since the most recent extraction of a model or the most recent synchronization of a model.
Specifically, in the output stream indicated by its argument, this member function displays the following information about memory use by Solver:
Each of those numbers can be accessed individually by one of the following member functions.
Typical output from the member function printInformation looks like this:
Number of fails : 3306 Number of choice points : 3310 Number of variables : 26 Number of constraints : 21 Reversible stack (bytes) : 8060 Solver heap (bytes) : 16100 And stack (bytes) : 4040 Or stack (bytes) : 4040 Constraint queue (bytes) : 4068 Total memory used (bytes) : 36308 Total CPU time : 12.29
This member function propagates the constraint constraint
and synchronizes with
the model (or not) according to the parameter mode
. This member functions returns
IloTrue
if the propagation succeeds; otherwise, it returns IloFalse
.
The parameter restore
indicates whether or not at the end of the propagation the
invoking solver should restore the state that it was in prior to the search. This restoration
of a state influences only the propagation, not the synchronization with a model. The invoking
solver will remain synchronized (or not, consistent with the mode
parameter) after
the search regardless of the restore
parameter. This member function must be used
at the top level of the search.
This member function removes a hook to set the trace from the search search
.
This member function restarts the search at the top of the search tree (that is, before
the first call of the member function next
).
It also stores the best value of any objective function that has been defined by
IloSolver::setObjMin
.
If you have stored an intermediate solution, then you should call restart
before you call IloSolver::next
so that next
will immediately produce
that stored solution.
This member function controls how Solver manages the propagation of
tuple set table constraints. It must be called before extraction. It
allows you to modify the default behavior (set using
IloSolver::setSimpleTupleSet
)
to accelerate the propagation of table constraints defined by the set
of their allowed tuples when propagation is slow. Typically, this can
occur when the tuples are of an arity greater than three and when they
contain numerous tuples. IloSolver::setBigTupleSet
uses a
data structure that is very quick, but that consumes a lot of memory.
This member function defines the default filter level for a type of constraint, such as the
types IlcAllDiff
, IlcDistribute
, IlcSequence
, and so forth. For
each type of constraint (as defined in the enumeration IlcFilterLevelConstraint
)
Solver respects a default filter level in propagation. With this member function, you can reset that default for
all constraints of that type.
If you want to reset the default filter level of a given constraint (rather than for all constraints of a
given type), then consider the member function IloSolver::setFilterLevel
.
This member function sets the default precision of the invoking solver. That value is used in managing
constrained floating-point expressions (instances of IlcFloatExp
and its subclasses)
if you associate no other relative precision with a given expression. In any case, the default precision must be
greater than or equal to 2.10-11. When it is less than 2.10-11, the default precision is automatically changed to
2.10-11. This member function is not reversible. This member function does not change the
precision of any constrained floating-point expressions that have already been created.
This member function sets a limit on the number of failures during a search performed by
IloSolver::solve
or by IloSolver::startNewSearch
.
The limit is set to the current number of fails plus numberOfFailures
.
The limit is recomputed each time this member function is called. When the limit is reached,
the search stops and the current call to the member function IloSolver::solve
returns IloFalse
.
The effect of this member function is immediate. This change will influence any subsequent calls of the
member functions IloSolver::startNewSearch
and IloSolver::solve
.
This member function controls initial constraint propagation during a search performed by
IloSolver::startNewSearch
. The initial constraint propagation will not be
redone if the following conditions are met:
IloSynchronizeAndRestart
mode
is
IloTrue
This mode is not the default.
Node files make it possible for you to limit the amount of memory Solver uses to store open search nodes. (Open search nodes in the search are the ones which have not yet been completely explored.) You activate node files by invoking this member function. This member function sets the options for node files and must be used before starting a search.
When the memory used to store nodes is greater than maxSize
bytes, Solver
creates a buffer of one megabyte. Solver then fills that buffer with open nodes. The parameter
maxSize
cannot be less than 5 000 000. If the given parameter is less than 5 000 000,
Solver will silently change it to 5 000 000.
If the parameter useCompression
is set to IlcTrue
, the buffer is
compressed. If the parameter useDisk
is set to IlcTrue
, this temporary
buffer is then flushed from memory and written to disk as a file. The name of the file is prefixed
by prefixName
.
If one buffer is not enough to reduce the memory consumption below maxSize
, then
Solver creates node files until the memory consumption fits that limit.
This member function defines the filter level for a given constraint.
For each type of constraint (as defined in the enumeration
IlcFilterLevelConstraint
) Solver respects a default filter
level in propagation. With this member function, you can reset the
filter level of a given constraint to override the default filter level of its type.
If you want to reset the default filter level of all constraints of a given type,
then consider the member function setDefaultFilterLevel
.
This member function defines the filter level for a given constraint.
For each type of constraint (as defined in the enumeration
IlcFilterLevelConstraint
) Solver respects a default filter
level in propagation. With this member function, you can reset the
filter level of a given constraint to override the default filter level of its type.
If you want to reset the default filter level of all constraints of a given type,
then consider the member function setDefaultFilterLevel
.
This member function changes the format of the display of floating-point constrained variables. Possible
values of display
are:
enum IlcFloatDisplay { IlcStandardDisplay = 0, IlcIntScientific = 1, IlcIntFixed = 2, IlcBasScientific = 3, IlcBasFixed = 4 };
The default value is IlcIntFixed
. See the enumeration IlcFloatDisplay
for an explanation of those values.
This member function controls how Solver manages the propagation of
tuple set table constraints. It must be called before extraction. It
allows you to modify the default behavior (set using
IloSolver::setSimpleTupleSet
)
to accelerate the propagation of table constraints defined by the set
of their allowed tuples when propagation is slow. Typically, this can
occur when the tuples are of an arity greater than three and when they
contain numerous tuples. IloSolver::setHoloTupleSet
uses a data structure that is almost as quick as that used by
IloSolver::setBigTupleSet
,
but that only consumes slightly more memory than the default
IloSolver::setSimpleTupleSet
data structure.
This member function assigns n
as the maximum value of the numeric variable v
.
This member function assigns n
as the minimum value of the numeric variable v
.
This member function assigns mon
as the search monitor for the invoking search.
A monitor watches and reports events in a search. If the IloBool
is IlcTrue
this monitor is set to monitor all searches including nested searches. If the IloBool
is
IlcFalse
the monitor is set only for the top level search. This member function must be
used before starting a search.
This member function sets p
as the degree of precision to use with nonlinear propagation
techniques (see the member function IloSolver::useNonLinConstraint
) and in determining
the safety of nonlinear solutions (see the member function IloSolver::isNonLinSafe
). By
default, the nonlinear precision is equal to the default precision of the invoking solver.
This member functions sets an optimization objective to minimize in the invoking
search. There is only one objective at a time for a given search. In other words,
each time you call this member function, it replaces the previous objective
(if there was one). Specifically, this member function sets obj
as the minimum objective of the invoking search object and sets step
as the step size. That is, it constrains the search to produce solutions
that are at least a step better than the previous solution.
If you want to maximize an objective, then use
solver.setObjMin(-obj, step);
.
This member function sets an optimization objective to minimize in the invoking
search. There is only one objective at a time for a given search. In other words,
each time you call this member function, it replaces the previous objective
(if there was one). Specifically, this member function sets obj
as the minimum objective of the invoking search object and sets step
as the step size. That is, it constrains the search to produce solutions
that are at least a step better than the previous solution.
If you want to maximize an objective, then use
solver.setObjMin(-obj, step);
.
This member function sets the step size used to measure improvement between solutions during a
search by IloSolver::solve
.
You can also set the step size for a given variable by means of a parameter in the
function IloMinimizeVar
.
This member functions sets a limit on the number of choice points (corresponding to execution of the
goal IlcOr
) during a search by IloSolver::solve
or by IloSolver::startNewSearch.
The limit is set to the current number of choice points plus numberOfChoicePoints
. The limit
is recomputed each time this member function is called. When the limit is reached, the search stops and the
current call to the member function IloSolver::solve
returns IloFalse
.
The effect of this member function is immediate. This change will influence any subsequent calls of the member
functions IloSolver::startNewSearch
and IloSolver::solve
.
This member function allows you to control propagation for variables that you suspect have become stuck in a propagation cycle, resulting sometimes in very slow constraint propagation. For example, the domain of variable x is reduced. This reduction causes the reduction of the domain of variable y, which causes the reduction of the domain of variable z, and so on, until this cycle of reductions returns to reduce the domain of variable x. This function must be called before extraction.
This member function allows you to control propagation for variables that you suspect have become stuck in a propagation cycle, resulting sometimes in very slow constraint propagation. For example, the domain of variable x is reduced. This reduction causes the reduction of the domain of variable y, which causes the reduction of the domain of variable z, and so on, until this cycle of reductions returns to reduce the domain of variable x. This function must be called before extraction.
This member function sets the relative step size used to measure
improvement between solutions during a search by IloSolver::solve
. It
is used to update the cutoff each time a mixed integer solution is
found. The value is multiplied by the absolute value of the integer
objective and subtracted from (added to) the newly found integer
objective when minimizing
(maximizing). This forces the mixed integer optimization to ignore
integer
solutions that are not at least this amount better than the one found so
far. This value must be strictly between 0 and 1.
This member function controls how Solver manages the propagation of
tuple set table constraints. It must be called before extraction. This is
the default setting for tuple set constraint propagation. The
member functions
IloSolver::setBigTupleSet
and
IloSolver::setHoloTupleSet
allow you to
modify this default behavior to accelerate the propagation of table
constraints defined by the set of their allowed tuples when propagation
is slow. Typically, this can occur when the tuples are of arity greater
than three and when they contain numerous tuples.
This member function sets a limit on the amount of time spent during a search by
IloSolver::solve
or by IloSolver::startNewSearch.
The limit is set to the current time plus time
. The limit is recomputed whenever this member
function is called. When the limit is reached, the search stops and the current call to the member function
IloSolver::solve
returns IlcFalse
.
The time is measured in elapsed CPU seconds for the search process.
This change will influence any subsequent calls of the member functions IloSolver::startNewSearch
and IloSolver::solve
.
This member function assigns trace
as the trace associated with the invoking solver.
This member function turns the trace mechanism on or off for the invoking solver. If the value of trace
is IlcTrue
, the trace mechanism turns on. If the value of trace is IlcFalse
,
the trace mechanism turns off.
This member function assigns n
as the value of the numeric variable v
.
This member function solves a problem by using a default goal to launch the search. It is used only at the top level of the search.
This member function first checks to see whether a model has already been extracted. If a model has already been extracted, it then checks whether the model has changed since it was extracted previously. If the model has changed, then the model is extracted again. If the model has not changed, then it is not extracted again. In other words, this member function synchronizes with the current model before it starts its search.
When Concert Technology determines at extraction time that the model is infeasible, it skips
the remainder of the extraction, and the first call to the member function solve
will
report without any search that there is no solution. If an instance of the class
IloObjective
has been added to the model, then the solver will search for an optimal solution.
This member function solves a problem by using the goal goal
passed as a parameter. The parameter restore
indicates whether
or not at the end of the search the invoking solver should restore the
state that it was in prior to the search. This member function can only
be used within a search (for example, inside a goal) not at the top level.
This member function solves a problem by using the goal
passed
as a parameter. By means of the mode
parameter, you control
how solver synchronizes with the current model. When using the default
parameter, IloSynchronizeAndRestart
, the instance of
IloSolver
will end in a state equivalent to a deletion
of the instance of IloSolver
and a reload of the current model.
Use the parameter IloSynchronizeAndContinue
only if all changes
since the last synchronization are monotonic. In this case, the instance of
IloSolver
will apply all the changes from the current state and
continue from there. The parameter restore
indicates whether or
not at the end of the search the invoking solver should restore the state that
it was in prior to the search. This restoration of a state influences only the
search, not the synchronization with a model. This member function is used only
at the top level of the search.
This member function behaves exactly like IloSolver::solve,
except in the case where the model contains an objective
(an instance of IloObjective). In this case,
solveFeasible
finds the first solution respecting all the
problem constraints, whereas IloSolver::solve finds a solution
respecting all constraints that also optimizes the objective.
This member function behaves exactly like IloSolver::solve,
except in the case where the model contains an objective
(an instance of IloObjective). In this case,
solveFeasible
finds the first solution respecting all the
problem constraints, whereas IloSolver::solve finds a solution
respecting all constraints that also optimizes the objective.
This member function starts a new search with goal.
This function is
only used inside a search.
This member function starts a new search with goal
and synchronizes with
the model (or not) according to the parameter mode
. This member function is
used only at the top level of the search.
This member function removes any limits, such as a time limit, a limit on the number of choice points, or a
limit on the number of failures, for the invoking solver. This change will influence any subsequent calls of the
member functions IloSolver::startNewSearch
and IloSolver::solve
.
This member function removes the constraint aggregator agg
from the current list of aggregators in the invoking object.
This member function adds the constraint aggregator agg
to the current list of aggregators in the invoking object. This function
must be called before model extraction.
If the value of useIt
is IlcTrue
, then this
member function makes the invoking solver use the overloaded new
operator to create objects associated with the invoking
solver. Those objects are then allocated on the heap associated with that
solver; they will be de-allocated when you call the member function
end
for that solver.
If the value of use
is IlcFalse
, then Concert
Technology uses the conventional C++ new
operator.
This member function changes how Solver handles the propagation of linear constraints. After this member function is called, all linear constraints added to Solver are no longer handled by the default propagation mechanism of Solver. Instead they are collected by a global propagation mechanism. This global propagation can improve performance in cases where the linear constraints reduce the variable domains only by small increments.
int main () { IloEnv env; IloModel model(env); IloSolver solver(model); IloIntVar var1(env, 0, 20000000); IloIntVar var2(env, 0, 20000000); model.add(var1 < var2); model.add(var1 > var2); solver.useLinPropagation(); if(solver.propagate()) { cout << "Propagation succeeded" << endl; solver.printInformation(); } else { cout << "Propagation failed" << endl; solver.printInformation(); } env.end(); return 0; }
On this example, the use of useLinPropagation
significantly improves the running time. Note, however, that the
aforementioned global propagation mechanism is more costly and hence
not always beneficial with regard to the default propagation mechanism
of Solver.
This member function tells the invoking solver to use nonlinear propagation techniques. In order to use these techniques, you must call this member function before you extract your model for the invoking solver. For example,
solve.useNonLinConstraint();
Then for all the nonlinear constraints in your model, the invoking solver will use nonlinear propagation techniques.
In addition, when the set of nonlinear constraints is a square system of equations or a square system of inequalities, a global constraint will be posted. This constraint may allow for additional propagation.
Furthermore it may allow you to prove that the solution-interval found for the system of nonlinear constraints surely contains a solution.
The keep
parameter specifies whether or not in addition to the advanced propagation techniques
the invoking solver should also use its default propagation. If keep
is IlcTrue
constraints
are propagated only by the nonlinear propagation techniques; if keep
is IlcFalse
, the invoking
solver will use nonlinear propagation techniques as well as its default propagation techniques.
The default value of keep
is IlcTrue
.
Inner Enumeration Detail |
---|
The values in this enumeration indicate the failure status of an instance
of IloSolver
after an unsuccessful IloSolver::solve or IloSolver::next. The member
function IloSolver::getFailureStatus is used to query the
failure status of an instance of IloSolver
.
See Also:
Fields |
---|
searchHasNotFailed | |
searchFailedNormally | |
searchStoppedByLimit | |
searchStoppedByLabel | |
searchStoppedByExit | |
unknownFailureStatus |