source: trunk/Clp/src/ClpEventHandler.hpp @ 1790

Last change on this file since 1790 was 1790, checked in by forrest, 8 years ago

improve robustness of parametrics

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.1 KB
Line 
1/* $Id: ClpEventHandler.hpp 1790 2011-09-08 16:46:09Z forrest $ */
2// Copyright (C) 2004, International Business Machines
3// Corporation and others.  All Rights Reserved.
4// This code is licensed under the terms of the Eclipse Public License (EPL).
5
6#ifndef ClpEventHandler_H
7#define ClpEventHandler_H
8
9#include "ClpSimplex.hpp"
10/** Base class for Clp event handling
11
12This is just here to allow for event handling.  By event I mean a Clp event
13e.g. end of values pass.
14
15One use would be to let a user handle a system event e.g. Control-C.  This could be done
16by deriving a class MyEventHandler which knows about such events.  If one occurs
17MyEventHandler::event() could clear event status and return 3 (stopped).
18
19Clp would then return to user code.
20
21As it is called every iteration this should be fine grained enough.
22
23User can derive and construct from CbcModel  - not pretty
24
25*/
26
27class ClpEventHandler  {
28
29public:
30     /** enums for what sort of event.
31
32         These will also be returned in ClpModel::secondaryStatus() as int
33     */
34     enum Event {
35          endOfIteration = 100, // used to set secondary status
36          endOfFactorization, // after gutsOfSolution etc
37          endOfValuesPass,
38          node, // for Cbc
39          treeStatus, // for Cbc
40          solution, // for Cbc
41          theta, // hit in parametrics
42          pivotRow, // used to choose pivot row
43          presolveStart, // ClpSolve presolve start
44          presolveSize, // sees if ClpSolve presolve too big or too small
45          presolveInfeasible, // ClpSolve presolve infeasible
46          presolveBeforeSolve, // ClpSolve presolve before solve
47          presolveAfterFirstSolve, // ClpSolve presolve after solve
48          presolveAfterSolve, // ClpSolve presolve after solve
49          presolveEnd, // ClpSolve presolve end
50          goodFactorization, // before gutsOfSolution
51          complicatedPivotIn, // in modifyCoefficients
52          noCandidateInPrimal, // tentative end
53          looksEndInPrimal, // About to declare victory (or defeat)
54          endInPrimal, // Victory (or defeat)
55          beforeStatusOfProblemInPrimal,
56          startOfStatusOfProblemInPrimal,
57          complicatedPivotOut, // in modifyCoefficients
58          noCandidateInDual, // tentative end
59          looksEndInDual, // About to declare victory (or defeat)
60          endInDual, // Victory (or defeat)
61          beforeStatusOfProblemInDual,
62          startOfStatusOfProblemInDual,
63          startOfIterationInDual,
64          updateDualsInDual,
65          endOfCreateRim,
66          slightlyInfeasible,
67          noTheta // At end (because no pivot)
68     };
69     /**@name Virtual method that the derived classes should provide.
70      The base class instance does nothing and as event() is only useful method
71      it would not be very useful NOT providing one!
72     */
73     //@{
74     /** This can do whatever it likes.  If return code -1 then carries on
75         if 0 sets ClpModel::status() to 5 (stopped by event) and will return to user.
76         At present if <-1 carries on and if >0 acts as if 0 - this may change.
77         For ClpSolve 2 -> too big return status of -2 and -> too small 3
78     */
79     virtual int event(Event whichEvent);
80     //@}
81
82
83     /**@name Constructors, destructor */
84
85     //@{
86     /** Default constructor. */
87     ClpEventHandler(ClpSimplex * model = NULL);
88     /** Destructor */
89     virtual ~ClpEventHandler();
90     // Copy
91     ClpEventHandler(const ClpEventHandler&);
92     // Assignment
93     ClpEventHandler& operator=(const ClpEventHandler&);
94     /// Clone
95     virtual ClpEventHandler * clone() const;
96
97     //@}
98
99     /**@name Sets/gets */
100
101     //@{
102     /** set model. */
103     void setSimplex(ClpSimplex * model);
104     /// Get model
105     inline ClpSimplex * simplex() const {
106          return model_;
107     }
108     //@}
109
110
111protected:
112     /**@name Data members
113        The data members are protected to allow access for derived classes. */
114     //@{
115     /// Pointer to simplex
116     ClpSimplex * model_;
117     //@}
118};
119/** Base class for Clp disaster handling
120
121This is here to allow for disaster handling.  By disaster I mean that Clp
122would otherwise give up
123
124*/
125
126class ClpDisasterHandler  {
127
128public:
129     /**@name Virtual methods that the derived classe should provide.
130     */
131     //@{
132     /// Into simplex
133     virtual void intoSimplex() = 0;
134     /// Checks if disaster
135     virtual bool check() const = 0;
136     /// saves information for next attempt
137     virtual void saveInfo() = 0;
138     /// Type of disaster 0 can fix, 1 abort
139     virtual int typeOfDisaster();
140     //@}
141
142
143     /**@name Constructors, destructor */
144
145     //@{
146     /** Default constructor. */
147     ClpDisasterHandler(ClpSimplex * model = NULL);
148     /** Destructor */
149     virtual ~ClpDisasterHandler();
150     // Copy
151     ClpDisasterHandler(const ClpDisasterHandler&);
152     // Assignment
153     ClpDisasterHandler& operator=(const ClpDisasterHandler&);
154     /// Clone
155     virtual ClpDisasterHandler * clone() const = 0;
156
157     //@}
158
159     /**@name Sets/gets */
160
161     //@{
162     /** set model. */
163     void setSimplex(ClpSimplex * model);
164     /// Get model
165     inline ClpSimplex * simplex() const {
166          return model_;
167     }
168     //@}
169
170
171protected:
172     /**@name Data members
173        The data members are protected to allow access for derived classes. */
174     //@{
175     /// Pointer to simplex
176     ClpSimplex * model_;
177     //@}
178};
179#endif
Note: See TracBrowser for help on using the repository browser.