source: coopr.opt/trunk/coopr/opt/results/solver.py @ 2259

Last change on this file since 2259 was 2259, checked in by wehart, 10 years ago

Adding new termination conditions.

Fixing problem setting up testing utilities when YAML is not installed.

File size: 3.6 KB
RevLine 
[1899]1#  _________________________________________________________________________
2#
3#  Coopr: A COmmon Optimization Python Repository
4#  Copyright (c) 2008 Sandia Corporation.
5#  This software is distributed under the BSD License.
6#  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
7#  the U.S. Government retains certain rights in this software.
8#  For more information, see the Coopr README.txt file.
9#  _________________________________________________________________________
10
[2095]11__all__ = ['SolverInformation', 'SolverStatus', 'TerminationCondition']
[1899]12
13from container import *
14from pyutilib.enum import Enum
15
16
[2250]17SolverStatus = Enum(
18    'ok',                   # Normal termination
19    'warning',              # Termination with unusual condtion
20    'error',                # Terminated internally with error
21    'aborted',              # Terminated due to external conditions (e.g. interrupts)
22    'unknown'               # An unitialized value
23    )
[1899]24
[2250]25TerminationCondition = Enum(
26    # OK
27    'maxIterations',        # Exceeded maximum number of iterations allowed by user
28    'minFunctionValue',     # Found solution smaller than specified function value
29    'minStepLength',        # Step length is smaller than specified limit
30    'globallyOptimal',      # Found a globally optimal solution
31    'locallyOptimal',       # Found a locally optimal solution
[2251]32    'optimal',              # Found an optimal solution
[2259]33    'maxEvaluations',       # Exceeded maximum number of problem evaluations
[2250]34    # WARNING
35    'unbounded',            # Demonstrated that problem is unbounded
36    'infeasible',           # Demonstrated that the problem is infeasible
[2259]37    'invalidProlem',        # The problem setup or characteristics are not valide for the solver
[2250]38    'other'                 # Other, uncategorized normal termination
39    # ERROR
40    'solverFailure',        # Solver failed to terminate correctly
41    'internalSolverError',  # Internal solver error
42    'error',                # Other errors
43    # ABORTED
44    'userInterrupt',        # Interrupt signal generated by user
45    'resourceInterrupt',    # Interrupt signal in resources used by optimizer
46    'licensingProblems',    # Problem accessing solver license
47    # UNKNOWN
48    'unknown'               # An unitialized value
49    )
[1899]50
51
[2250]52
[1899]53class BranchAndBoundStats(MapContainer):
54
55    def __init__(self):
56        MapContainer.__init__(self)
57        self.declare('number of bounded subproblems')
58        self.declare('number of created subproblems')
59
60
61class BlackBoxStats(MapContainer):
62
63    def __init__(self):
64        MapContainer.__init__(self)
65        self.declare('number of function evaluations')
66        self.declare('number of gradient evaluations')
67        self.declare('number of iterations')
68
69
70class SolverStatistics(MapContainer):
71
72    def __init__(self):
73        MapContainer.__init__(self)
74        self.declare("branch_and_bound", value=BranchAndBoundStats(), active=False)
75        self.declare("black_box", value=BlackBoxStats(), active=False)
76
77
[1902]78class SolverInformation(MapContainer):
[1899]79
80    def __init__(self):
81        MapContainer.__init__(self)
[2257]82        self.declare('name')
[1915]83        self.declare('status', value=SolverStatus.ok)
[1899]84        self.declare('return_code')
85        self.declare('message')
[1918]86        self.declare('user_time', type=ScalarType.time)
87        self.declare('system_time', type=ScalarType.time)
[2257]88        self.declare('wallclock_time', type=ScalarType.time)
[2251]89        self.declare('termination_condition', value=TerminationCondition.unknown)
[1905]90        self.declare('termination_message')
[1915]91        self.declare('statistics', value=SolverStatistics(), active=False)
[1899]92
Note: See TracBrowser for help on using the repository browser.