Package localsolver

Class LSPhase


  • public class LSPhase
    extends java.lang.Object
    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 objectives 0, ..., k-1 are declared, each objective i can be optimized while maintaining the values of objectives 0, ..., i-1 previously obtained and ignoring the values of objectives i+1, ..., k-1. During such an optimization phase, objective i is called the optimized objective. At least one phase must be created to launch the solver. If you have only one objective to optimize, then create a phase, set the time or the number of iterations, and run the solver. By default, the optimized objective of a phase corresponds to the last objective declared in the model (in this case, all objectives of the model are optimized together).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      long getIterationLimit()
      Gets the number of iterations of this phase.
      LocalSolver getLocalSolver()
      Returns the LocalSolver object associated to this phase.
      int getOptimizedObjective()
      Gets the index of the optimized objective.
      int getTimeLimit()
      Gets the time limit of this phase in seconds.
      int hashCode()  
      boolean isEnabled()
      Returns true if the phase is enabled, False otherwise.
      void setEnabled​(boolean enabled)
      Sets the enabled status of this phase.
      void setIterationLimit​(long iterationLimit)
      Sets the number of iterations of this phase.
      void setOptimizedObjective​(int objectiveIndex)
      Sets the optimized objective of this phase.
      void setTimeLimit​(int timeLimit)
      Sets the time limit of this phase in seconds.
      java.lang.String toString()
      Returns a String representation of this phase.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getLocalSolver

        public LocalSolver getLocalSolver()
        Returns the LocalSolver object associated to this phase.
        Returns:
        LocalSolver object.
      • setTimeLimit

        public 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 states LSState.Modeling or LSState.Stopped. 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.
        Parameters:
        timeLimit - Time limit in seconds.
      • getTimeLimit

        public int getTimeLimit()
        Gets the time limit of this phase in seconds.
        Returns:
        Time limit in seconds.
        See Also:
        setTimeLimit(int)
      • setIterationLimit

        public 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 states LSState.Modeling or LSState.Stopped. 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.
        Parameters:
        iterationLimit - Iteration limit.
      • getIterationLimit

        public long getIterationLimit()
        Gets the number of iterations of this phase.
        Returns:
        Iteration limit.
        See Also:
        setIterationLimit(long)
      • setOptimizedObjective

        public 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 objectives 0, ..., k-1 are declared, each objective i can be optimized while maintaining the values of objectives 0, ..., i-1 previously obtained and ignoring the values of objectives i+1, ..., k-1. By default, the optimized objective corresponds to the last objective declared in the model. Only allowed in states LSState.Modeling or LSState.Stopped.
        Parameters:
        objectiveIndex - Index of the optimized objective.
      • getOptimizedObjective

        public int getOptimizedObjective()
        Gets the index of the optimized objective.
        Returns:
        Index of the optimized objective.
        See Also:
        setOptimizedObjective(int)
      • setEnabled

        public void setEnabled​(boolean 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 states LSState.Modeling or LSState.Stopped.
        Parameters:
        enabled - True to enable the phase, False to disable it
        Since:
        5.0
      • isEnabled

        public boolean isEnabled()
        Returns true if the phase is enabled, False otherwise.
        Returns:
        True if phase is enabled
        Since:
        5.0
      • toString

        public java.lang.String toString()
        Returns a String representation of this phase. Useful for debugging or logging purposes.
        Overrides:
        toString in class java.lang.Object
        Returns:
        String representation.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object