Commons Math
  1. Commons Math
  2. MATH-970

Provide a way to retrieve the best solution found so far when reaching the maxIteration limit in SimplexSolver

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.2
    • Fix Version/s: 3.3
    • Labels:
      None

      Issue Links

        Activity

        Hide
        Thomas Neidhart added a comment -

        Right now, when the maxIteration count is reached, an exception is thrown by the optimizer, and there is no way to retrieve the best solution that has been found so far.

        This is not acceptable in some use-cases, e.g. when limiting the optimization process by time. In these cases, the best solution that has been found so far shall be accessible, either as part of the Exception, or via a separate getter.

        Show
        Thomas Neidhart added a comment - Right now, when the maxIteration count is reached, an exception is thrown by the optimizer, and there is no way to retrieve the best solution that has been found so far. This is not acceptable in some use-cases, e.g. when limiting the optimization process by time. In these cases, the best solution that has been found so far shall be accessible, either as part of the Exception, or via a separate getter.
        Hide
        Gilles added a comment -

        > [...] either as part of the Exception, or via a separate getter.

        Neither is particularly attractive.
        This behaviour should rather be customized via the new API proposed by Luc:

        LinearOptimizer withMaxIteration(int max, boolean returnBestSoFar) {
          // ...
        }
        
        Show
        Gilles added a comment - > [...] either as part of the Exception, or via a separate getter. Neither is particularly attractive. This behaviour should rather be customized via the new API proposed by Luc: LinearOptimizer withMaxIteration(int max, boolean returnBestSoFar) { // ... }
        Hide
        Thomas Neidhart added a comment -

        The disadvantage of this approach is that the user has no means to know if the solution is optimal (within the given epsilon bounds), or the optimizer has just returned the last valid solution before exceeding the max iteration count.

        I would prefer a SolutionCallback which contains the last valid solution. For some optimizers this is very straight-forward, e.g. for the SimplexSolver you just need a reference to the SimplexTableau and can derive from it the solution. For other optimizers this may not be so simple.

        Show
        Thomas Neidhart added a comment - The disadvantage of this approach is that the user has no means to know if the solution is optimal (within the given epsilon bounds), or the optimizer has just returned the last valid solution before exceeding the max iteration count. I would prefer a SolutionCallback which contains the last valid solution. For some optimizers this is very straight-forward, e.g. for the SimplexSolver you just need a reference to the SimplexTableau and can derive from it the solution. For other optimizers this may not be so simple.
        Hide
        Thomas Neidhart added a comment -

        If there are no objections with the SolutionCallback approach, I will go forward and make the change.

        Show
        Thomas Neidhart added a comment - If there are no objections with the SolutionCallback approach, I will go forward and make the change.
        Hide
        Thomas Neidhart added a comment -

        Added in r1543169.

        Show
        Thomas Neidhart added a comment - Added in r1543169.
        Hide
        Luc Maisonobe added a comment -

        Closing all resolved issue now available in released 3.3 version.

        Show
        Luc Maisonobe added a comment - Closing all resolved issue now available in released 3.3 version.

          People

          • Assignee:
            Thomas Neidhart
            Reporter:
            Thomas Neidhart
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development