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

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

more flexibility in pivoting

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.9 KB
RevLine 
[1370]1/* $Id: ClpEventHandler.hpp 1761 2011-07-06 16:06:24Z forrest $ */
[344]2// Copyright (C) 2004, International Business Machines
3// Corporation and others.  All Rights Reserved.
[1665]4// This code is licensed under the terms of the Eclipse Public License (EPL).
5
[344]6#ifndef ClpEventHandler_H
7#define ClpEventHandler_H
8
9#include "ClpSimplex.hpp"
10/** Base class for Clp event handling
[1502]11
[346]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
[1502]16by deriving a class MyEventHandler which knows about such events.  If one occurs
[346]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.
[635]22
23User can derive and construct from CbcModel  - not pretty
[1502]24
[344]25*/
26
27class ClpEventHandler  {
[1502]28
[344]29public:
[1525]30     /** enums for what sort of event.
[346]31
[1525]32         These will also be returned in ClpModel::secondaryStatus() as int
33     */
34     enum Event {
35          endOfIteration = 100, // used to set secondary status
[1761]36          endOfFactorization, // after gutsOfSolution etc
[1525]37          endOfValuesPass,
38          node, // for Cbc
39          treeStatus, // for Cbc
40          solution, // for Cbc
[1533]41          theta, // hit in parametrics
[1610]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
[1761]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          complicatedPivotOut, // in modifyCoefficients
56          noCandidateInDual, // tentative end
57          looksEndInDual, // About to declare victory (or defeat)
58          endInDual, // Victory (or defeat)
59          noTheta // At end (because no pivot)
[1525]60     };
[1610]61     /**@name Virtual method that the derived classes should provide.
[1525]62      The base class instance does nothing and as event() is only useful method
63      it would not be very useful NOT providing one!
64     */
65     //@{
66     /** This can do whatever it likes.  If return code -1 then carries on
67         if 0 sets ClpModel::status() to 5 (stopped by event) and will return to user.
[1610]68         At present if <-1 carries on and if >0 acts as if 0 - this may change.
69         For ClpSolve 2 -> too big return status of -2 and -> too small 3
[1525]70     */
71     virtual int event(Event whichEvent);
72     //@}
[344]73
74
[1525]75     /**@name Constructors, destructor */
[344]76
[1525]77     //@{
78     /** Default constructor. */
79     ClpEventHandler(ClpSimplex * model = NULL);
80     /** Destructor */
81     virtual ~ClpEventHandler();
82     // Copy
83     ClpEventHandler(const ClpEventHandler&);
84     // Assignment
85     ClpEventHandler& operator=(const ClpEventHandler&);
86     /// Clone
87     virtual ClpEventHandler * clone() const;
[1502]88
[1525]89     //@}
[1502]90
[1525]91     /**@name Sets/gets */
[1502]92
[1525]93     //@{
94     /** set model. */
95     void setSimplex(ClpSimplex * model);
96     /// Get model
97     inline ClpSimplex * simplex() const {
98          return model_;
99     }
100     //@}
[1502]101
102
[344]103protected:
[1525]104     /**@name Data members
105        The data members are protected to allow access for derived classes. */
106     //@{
107     /// Pointer to simplex
108     ClpSimplex * model_;
109     //@}
[344]110};
[1034]111/** Base class for Clp disaster handling
[1502]112
[1034]113This is here to allow for disaster handling.  By disaster I mean that Clp
114would otherwise give up
115
116*/
117
118class ClpDisasterHandler  {
[1502]119
[1034]120public:
[1525]121     /**@name Virtual methods that the derived classe should provide.
122     */
123     //@{
124     /// Into simplex
125     virtual void intoSimplex() = 0;
126     /// Checks if disaster
127     virtual bool check() const = 0;
128     /// saves information for next attempt
129     virtual void saveInfo() = 0;
130     /// Type of disaster 0 can fix, 1 abort
131     virtual int typeOfDisaster();
132     //@}
[1034]133
134
[1525]135     /**@name Constructors, destructor */
[1034]136
[1525]137     //@{
138     /** Default constructor. */
139     ClpDisasterHandler(ClpSimplex * model = NULL);
140     /** Destructor */
141     virtual ~ClpDisasterHandler();
142     // Copy
143     ClpDisasterHandler(const ClpDisasterHandler&);
144     // Assignment
145     ClpDisasterHandler& operator=(const ClpDisasterHandler&);
146     /// Clone
147     virtual ClpDisasterHandler * clone() const = 0;
[1502]148
[1525]149     //@}
[1502]150
[1525]151     /**@name Sets/gets */
[1502]152
[1525]153     //@{
154     /** set model. */
155     void setSimplex(ClpSimplex * model);
156     /// Get model
157     inline ClpSimplex * simplex() const {
158          return model_;
159     }
160     //@}
[1502]161
162
[1034]163protected:
[1525]164     /**@name Data members
165        The data members are protected to allow access for derived classes. */
166     //@{
167     /// Pointer to simplex
168     ClpSimplex * model_;
169     //@}
[1034]170};
[344]171#endif
Note: See TracBrowser for help on using the repository browser.