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

Last change on this file since 1533 was 1533, checked in by forrest, 10 years ago

make it easier to play with multiple Lp solutions

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