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

Last change on this file since 1287 was 1287, checked in by forrest, 13 years ago

changes for cbc event handler and multiple factorizations

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