LSPhase Class¶
- class localsolver.LSPhase¶
Optimization phase. Since LocalSolver allows lexicographic multiobjective optimization, we allow you to parameterize the time or the number of iterations to spend in optimizing each objective. When multiple objectives are declared, these objectives are optimized in lexicographic order (in the order of their declaration in the model). Thus, if
k
objectives0, ..., k-1
are declared, each objectivei
can be optimized while maintaining the values of objectives0, ..., i-1
previously obtained and ignoring the values of objectivesi+1, ..., k-1
. During such an optimization phase, objectivei
is called the optimized objective.
Summary¶
Sets the time limit of this phase in seconds. |
|
Gets the time limit of this phase in seconds. |
|
Sets the number of iterations of this phase. |
|
Gets the number of iterations of this phase. |
|
Sets the optimized objective of this phase. |
|
Gets the index of the optimized objective. |
|
Sets the enabled status of this phase. |
|
Returns true if the phase is enabled, False otherwise. |
|
Returns a string representation of this phase. |
Instance methods¶
- void SetTimeLimit(int timeLimit)¶
Sets the time limit of this phase in seconds. Note that the “real” time (that is, total time) spent to resolve the model is considered here and not only the CPU time). The default time limit is set to the largest positive integer on 32 bits, that is
2^31-1 = 2,147,483,647 > 10^9
. Only allowed in statesModeling
orStopped
.Note that if the optimal value of an objective is found before the end of the corresponding phase, the remaining time will be transferred to the next phase.
- Arguments
timeLimit (int) – Time limit in seconds.
- int GetTimeLimit()¶
Gets the time limit of this phase in seconds.
- Returns
Time limit in seconds.
- See
- void SetIterationLimit(long iterationLimit)¶
Sets the number of iterations of this phase. Fixing the seed and the number of iterations of all phases ensures the reproducibility of results over several runs. The default number of iterations is set to the largest positive integer on 64 bits, that is
2^63-1 = 9,223,372,036,854,775,807 > 10^18
. Only allowed in statesModeling
orStopped
.Note that if the optimal value of an objective is found before the end of the corresponding phase, the remaining iterations will be transferred to the next phase.
- Arguments
iterationLimit (long) – Iteration limit.
- long GetIterationLimit()¶
Gets the number of iterations of this phase.
- Returns
Iteration limit.
- See
- void SetOptimizedObjective(int objectiveIndex)¶
Sets the optimized objective of this phase. When multiple objectives are declared, these objectives are optimized in lexicographic order (in the order of their declaration in the model). Thus, if
k
objectives0, ..., k-1
are declared, each objectivei
can be optimized while maintaining the values of objectives0, ..., i-1
previously obtained and ignoring the values of objectivesi+1, ..., k-1
. By default, the optimized objective corresponds to the last objective declared in the model. Only allowed in statesPaused
orStopped
.- Arguments
objectiveIndex (int) – Index of the optimized objective.
- int GetOptimizedObjective()¶
Gets the index of the optimized objective.
- Returns
Index of the optimized objective.
- See
- void SetEnabled(bool enabled)¶
Sets the enabled status of this phase. The solver only optimize enabled phases. Disabling a phase can be useful when an objective has been removed from the model by
LSModel.RemoveObjective(int)
. By default, a phase is enabled. Only allowed in statesPaused
orStopped
.- Since
5.0
- Arguments
enabled (bool) – True to enable the phase, False to disable it.
- bool IsEnabled()¶
Returns true if the phase is enabled, False otherwise.
- Since
5.0
- Returns
True if phase is enabled
- string ToString()¶
Returns a string representation of this phase. Useful for debugging or logging purposes.
- Returns
String representation.