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

Last change on this file since 754 was 754, checked in by andreasw, 14 years ago

first version

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 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#endif
Note: See TracBrowser for help on using the repository browser.