Ignore:
Timestamp:
Jan 29, 2010 9:25:07 AM (10 years ago)
Author:
forrest
Message:

moving sandbox stuff to trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/ClpEventHandler.hpp

    r1370 r1502  
    77#include "ClpSimplex.hpp"
    88/** Base class for Clp event handling
    9    
     9
    1010This is just here to allow for event handling.  By event I mean a Clp event
    1111e.g. end of values pass.
    1212
    1313One use would be to let a user handle a system event e.g. Control-C.  This could be done
    14 by deriving a class MyEventHandler which knows about such events.  If one occurs 
     14by deriving a class MyEventHandler which knows about such events.  If one occurs
    1515MyEventHandler::event() could clear event status and return 3 (stopped).
    1616
     
    2020
    2121User can derive and construct from CbcModel  - not pretty
    22    
     22
    2323*/
    2424
    2525class ClpEventHandler  {
    26  
     26
    2727public:
    28   /** enums for what sort of event.
     28    /** enums for what sort of event.
    2929
    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   };
    41   /**@name Virtual method that the derived classe should provide.
    42    The base class instance does nothing and as event() is only useful method
    43    it would not be very useful NOT providing one!
    44   */
    45   //@{
    46   /** This can do whatever it likes.  If return code -1 then carries on
    47       if 0 sets ClpModel::status() to 5 (stopped by event) and will return to user.
    48       At present if <-1 carries on and if >0 acts as if 0 - this may change
    49   */
    50   virtual int event(Event whichEvent);
    51   //@}
    52  
    53  
    54   /**@name Constructors, destructor */
     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    };
     41    /**@name Virtual method that the derived classe should provide.
     42     The base class instance does nothing and as event() is only useful method
     43     it would not be very useful NOT providing one!
     44    */
     45    //@{
     46    /** This can do whatever it likes.  If return code -1 then carries on
     47        if 0 sets ClpModel::status() to 5 (stopped by event) and will return to user.
     48        At present if <-1 carries on and if >0 acts as if 0 - this may change
     49    */
     50    virtual int event(Event whichEvent);
     51    //@}
    5552
    56   //@{
    57   /** Default constructor. */
    58   ClpEventHandler(ClpSimplex * model = NULL);
    59   /** Destructor */
    60   virtual ~ClpEventHandler();
    61   // Copy
    62   ClpEventHandler(const ClpEventHandler&);
    63   // Assignment
    64   ClpEventHandler& operator=(const ClpEventHandler&);
    65   /// Clone
    66   virtual ClpEventHandler * clone() const;
    6753
    68   //@}
    69  
    70   /**@name Sets/gets */
     54    /**@name Constructors, destructor */
    7155
    72   //@{
    73   /** set model. */
    74   void setSimplex(ClpSimplex * model);
    75   /// Get model
    76   inline ClpSimplex * simplex() const
    77   { return model_;}
    78   //@}
    79  
    80  
     56    //@{
     57    /** Default constructor. */
     58    ClpEventHandler(ClpSimplex * model = NULL);
     59    /** Destructor */
     60    virtual ~ClpEventHandler();
     61    // Copy
     62    ClpEventHandler(const ClpEventHandler&);
     63    // Assignment
     64    ClpEventHandler& operator=(const ClpEventHandler&);
     65    /// Clone
     66    virtual ClpEventHandler * clone() const;
     67
     68    //@}
     69
     70    /**@name Sets/gets */
     71
     72    //@{
     73    /** set model. */
     74    void setSimplex(ClpSimplex * model);
     75    /// Get model
     76    inline ClpSimplex * simplex() const {
     77        return model_;
     78    }
     79    //@}
     80
     81
    8182protected:
    82   /**@name Data members
    83      The data members are protected to allow access for derived classes. */
    84   //@{
    85   /// Pointer to simplex
    86   ClpSimplex * model_;
    87   //@}
     83    /**@name Data members
     84       The data members are protected to allow access for derived classes. */
     85    //@{
     86    /// Pointer to simplex
     87    ClpSimplex * model_;
     88    //@}
    8889};
    8990/** Base class for Clp disaster handling
    90    
     91
    9192This is here to allow for disaster handling.  By disaster I mean that Clp
    9293would otherwise give up
     
    9596
    9697class ClpDisasterHandler  {
    97  
     98
    9899public:
    99   /**@name Virtual methods that the derived classe should provide.
    100   */
    101   //@{
    102   /// Into simplex
    103   virtual void intoSimplex()=0;
    104   /// Checks if disaster
    105   virtual bool check() const = 0;
    106   /// saves information for next attempt
    107   virtual void saveInfo() =0;
    108   /// Type of disaster 0 can fix, 1 abort
    109   virtual int typeOfDisaster();
    110   //@}
    111  
    112  
    113   /**@name Constructors, destructor */
     100    /**@name Virtual methods that the derived classe should provide.
     101    */
     102    //@{
     103    /// Into simplex
     104    virtual void intoSimplex() = 0;
     105    /// Checks if disaster
     106    virtual bool check() const = 0;
     107    /// saves information for next attempt
     108    virtual void saveInfo() = 0;
     109    /// Type of disaster 0 can fix, 1 abort
     110    virtual int typeOfDisaster();
     111    //@}
    114112
    115   //@{
    116   /** Default constructor. */
    117   ClpDisasterHandler(ClpSimplex * model = NULL);
    118   /** Destructor */
    119   virtual ~ClpDisasterHandler();
    120   // Copy
    121   ClpDisasterHandler(const ClpDisasterHandler&);
    122   // Assignment
    123   ClpDisasterHandler& operator=(const ClpDisasterHandler&);
    124   /// Clone
    125   virtual ClpDisasterHandler * clone() const =0;
    126113
    127   //@}
    128  
    129   /**@name Sets/gets */
     114    /**@name Constructors, destructor */
    130115
    131   //@{
    132   /** set model. */
    133   void setSimplex(ClpSimplex * model);
    134   /// Get model
    135   inline ClpSimplex * simplex() const
    136   { return model_;}
    137   //@}
    138  
    139  
     116    //@{
     117    /** Default constructor. */
     118    ClpDisasterHandler(ClpSimplex * model = NULL);
     119    /** Destructor */
     120    virtual ~ClpDisasterHandler();
     121    // Copy
     122    ClpDisasterHandler(const ClpDisasterHandler&);
     123    // Assignment
     124    ClpDisasterHandler& operator=(const ClpDisasterHandler&);
     125    /// Clone
     126    virtual ClpDisasterHandler * clone() const = 0;
     127
     128    //@}
     129
     130    /**@name Sets/gets */
     131
     132    //@{
     133    /** set model. */
     134    void setSimplex(ClpSimplex * model);
     135    /// Get model
     136    inline ClpSimplex * simplex() const {
     137        return model_;
     138    }
     139    //@}
     140
     141
    140142protected:
    141   /**@name Data members
    142      The data members are protected to allow access for derived classes. */
    143   //@{
    144   /// Pointer to simplex
    145   ClpSimplex * model_;
    146   //@}
     143    /**@name Data members
     144       The data members are protected to allow access for derived classes. */
     145    //@{
     146    /// Pointer to simplex
     147    ClpSimplex * model_;
     148    //@}
    147149};
    148150#endif
Note: See TracChangeset for help on using the changeset viewer.