Ignore:
Timestamp:
Nov 9, 2009 6:33:07 PM (10 years ago)
Author:
EdwinStraver
Message:

Changed formatting using AStyle -A4 -p

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/Cbc/src/CbcSolver_ban.hpp

    r1276 r1286  
    3232class CbcSolver  {
    3333
    34     public:
    35         ///@name Solve method
    36         //@{
    37         /** This takes a list of commands, does "stuff" and returns
    38             returnMode -
    39             0 model and solver untouched - babModel updated
    40             1 model updated - just with solution basis etc
    41             2 model updated i.e. as babModel (babModel NULL) (only use without preprocessing)
    42         */
    43         int solve(int argc, const char * argv[], int returnMode);
    44         /** This takes a list of commands, does "stuff" and returns
    45             returnMode -
    46             0 model and solver untouched - babModel updated
    47             1 model updated - just with solution basis etc
    48             2 model updated i.e. as babModel (babModel NULL) (only use without preprocessing)
    49         */
    50         int solve(const char * input, int returnMode);
    51         //@}
    52         ///@name Constructors and destructors etc
    53         //@{
    54         /// Default Constructor
    55         CbcSolver();
    56 
    57         /// Constructor from solver
    58         CbcSolver(const OsiClpSolverInterface &);
    59 
    60         /// Constructor from model
    61         CbcSolver(const CbcModel &);
    62 
    63         /** Copy constructor .
    64          */
    65         CbcSolver(const CbcSolver & rhs);
    66 
    67         /// Assignment operator
    68         CbcSolver & operator=(const CbcSolver& rhs);
    69 
    70         /// Destructor
    71         ~CbcSolver ();
    72         /// Fill with standard parameters
    73         void fillParameters();
    74         /// Set default values in solvers from parameters
    75         void fillValuesInSolver();
    76         /// Add user function
    77         void addUserFunction(CbcUser * function);
    78         /// Set user call back
    79         void setUserCallBack(CbcStopNow * function);
    80         /// Add cut generator
    81         void addCutGenerator(CglCutGenerator * generator);
    82         //@}
    83         ///@name miscellaneous methods to line up with old
    84         //@{
    85         // analyze model
    86         int * analyze(OsiClpSolverInterface * solverMod, int & numberChanged, double & increment,
    87                       bool changeInt,  CoinMessageHandler * generalMessageHandler);
    88         /** 1 - add heuristics to model
    89             2 - do heuristics (and set cutoff and best solution)
    90             3 - for miplib test so skip some
    91             (out model later)
    92         */
    93         int doHeuristics(CbcModel * model, int type);
    94         /** Updates model_ from babModel_ according to returnMode
    95             returnMode -
    96             0 model and solver untouched - babModel updated
    97             1 model updated - just with solution basis etc
    98             2 model updated i.e. as babModel (babModel NULL) (only use without preprocessing)
    99         */
    100         void updateModel(ClpSimplex * model2, int returnMode);
    101         //@}
    102         ///@name useful stuff
    103         //@{
    104         /// Get int value
    105         int intValue(CbcOrClpParameterType type) const;
    106         /// Set int value
    107         void setIntValue(CbcOrClpParameterType type,int value);
    108         /// Get double value
    109         double doubleValue(CbcOrClpParameterType type) const;
    110         /// Set double value
    111         void setDoubleValue(CbcOrClpParameterType type,double value);
    112         /// User function (NULL if no match)
    113         CbcUser * userFunction(const char * name) const;
    114         /// Return original Cbc model
    115         inline CbcModel * model() {
    116             return &model_;
    117             }
    118         /// Return updated Cbc model
    119         inline CbcModel * babModel() {
    120             return babModel_;
    121             }
    122         /// Number of userFunctions
    123         inline int numberUserFunctions() const {
    124             return numberUserFunctions_;
    125             }
    126         /// User function array
    127         inline CbcUser ** userFunctionArray() const {
    128             return userFunction_;
    129             }
    130         /// Copy of model on initial load (will contain output solutions)
    131         inline OsiClpSolverInterface * originalSolver() const {
    132             return originalSolver_;
    133             }
    134         /// Copy of model on initial load
    135         inline CoinModel * originalCoinModel() const {
    136             return originalCoinModel_;
    137             }
    138         /// Copy of model on initial load (will contain output solutions)
    139         void setOriginalSolver(OsiClpSolverInterface * originalSolver);
    140         /// Copy of model on initial load
    141         void setOriginalCoinModel(CoinModel * originalCoinModel);
    142         /// Number of cutgenerators
    143         inline int numberCutGenerators() const {
    144             return numberCutGenerators_;
    145             }
    146         /// Cut generator array
    147         inline CglCutGenerator ** cutGeneratorArray() const {
    148             return cutGenerator_;
    149             }
    150         /// Start time
    151         inline double startTime() const {
    152             return startTime_;
    153             }
    154         /// Whether to print to std::cout
    155         inline void setPrinting(bool onOff) {
    156             noPrinting_= !onOff;
    157             }
    158         /// Where to start reading commands
    159         inline void setReadMode(int value) {
    160             readMode_ = value;
    161             }
    162         //@}
    163     private:
    164         ///@name Private member data
    165         //@{
    166 
    167         /// Reference model
    168         CbcModel model_;
    169 
    170         /// Updated model
    171         CbcModel * babModel_;
    172 
    173         /// User functions
    174         CbcUser ** userFunction_;
    175         /** Status of user functions
    176             0 - not used
    177             1 - needs cbc_load
    178             2 - available - data in coinModel
    179             3 - data loaded - can do cbc_save
    180         */
    181         int * statusUserFunction_;
    182         /// Copy of model on initial load (will contain output solutions)
    183         OsiClpSolverInterface * originalSolver_;
    184         /// Copy of model on initial load
    185         CoinModel * originalCoinModel_;
    186         /// Cut generators
    187         CglCutGenerator ** cutGenerator_;
    188         /// Number of user functions
    189         int numberUserFunctions_;
    190         /// Number of cut generators
    191         int numberCutGenerators_;
    192         /// Stop now stuff
    193         CbcStopNow * callBack_;
    194         /// Cpu time at instantiation
    195         double startTime_;
    196         /// Parameters and values
    197         CbcOrClpParam * parameters_;
    198         /// Number of parameters
    199         int numberParameters_ ;
    200         /// Whether to do miplib test
    201         bool doMiplib_;
    202         /// Whether to print to std::cout
    203         bool noPrinting_;
    204         /// Where to start reading commands
    205         int readMode_;
    206         //@}
    207     };
     34public:
     35    ///@name Solve method
     36    //@{
     37    /** This takes a list of commands, does "stuff" and returns
     38        returnMode -
     39        0 model and solver untouched - babModel updated
     40        1 model updated - just with solution basis etc
     41        2 model updated i.e. as babModel (babModel NULL) (only use without preprocessing)
     42    */
     43    int solve(int argc, const char * argv[], int returnMode);
     44    /** This takes a list of commands, does "stuff" and returns
     45        returnMode -
     46        0 model and solver untouched - babModel updated
     47        1 model updated - just with solution basis etc
     48        2 model updated i.e. as babModel (babModel NULL) (only use without preprocessing)
     49    */
     50    int solve(const char * input, int returnMode);
     51    //@}
     52    ///@name Constructors and destructors etc
     53    //@{
     54    /// Default Constructor
     55    CbcSolver();
     56
     57    /// Constructor from solver
     58    CbcSolver(const OsiClpSolverInterface &);
     59
     60    /// Constructor from model
     61    CbcSolver(const CbcModel &);
     62
     63    /** Copy constructor .
     64     */
     65    CbcSolver(const CbcSolver & rhs);
     66
     67    /// Assignment operator
     68    CbcSolver & operator=(const CbcSolver& rhs);
     69
     70    /// Destructor
     71    ~CbcSolver ();
     72    /// Fill with standard parameters
     73    void fillParameters();
     74    /// Set default values in solvers from parameters
     75    void fillValuesInSolver();
     76    /// Add user function
     77    void addUserFunction(CbcUser * function);
     78    /// Set user call back
     79    void setUserCallBack(CbcStopNow * function);
     80    /// Add cut generator
     81    void addCutGenerator(CglCutGenerator * generator);
     82    //@}
     83    ///@name miscellaneous methods to line up with old
     84    //@{
     85    // analyze model
     86    int * analyze(OsiClpSolverInterface * solverMod, int & numberChanged, double & increment,
     87                  bool changeInt,  CoinMessageHandler * generalMessageHandler);
     88    /** 1 - add heuristics to model
     89        2 - do heuristics (and set cutoff and best solution)
     90        3 - for miplib test so skip some
     91        (out model later)
     92    */
     93    int doHeuristics(CbcModel * model, int type);
     94    /** Updates model_ from babModel_ according to returnMode
     95        returnMode -
     96        0 model and solver untouched - babModel updated
     97        1 model updated - just with solution basis etc
     98        2 model updated i.e. as babModel (babModel NULL) (only use without preprocessing)
     99    */
     100    void updateModel(ClpSimplex * model2, int returnMode);
     101    //@}
     102    ///@name useful stuff
     103    //@{
     104    /// Get int value
     105    int intValue(CbcOrClpParameterType type) const;
     106    /// Set int value
     107    void setIntValue(CbcOrClpParameterType type, int value);
     108    /// Get double value
     109    double doubleValue(CbcOrClpParameterType type) const;
     110    /// Set double value
     111    void setDoubleValue(CbcOrClpParameterType type, double value);
     112    /// User function (NULL if no match)
     113    CbcUser * userFunction(const char * name) const;
     114    /// Return original Cbc model
     115    inline CbcModel * model() {
     116        return &model_;
     117    }
     118    /// Return updated Cbc model
     119    inline CbcModel * babModel() {
     120        return babModel_;
     121    }
     122    /// Number of userFunctions
     123    inline int numberUserFunctions() const {
     124        return numberUserFunctions_;
     125    }
     126    /// User function array
     127    inline CbcUser ** userFunctionArray() const {
     128        return userFunction_;
     129    }
     130    /// Copy of model on initial load (will contain output solutions)
     131    inline OsiClpSolverInterface * originalSolver() const {
     132        return originalSolver_;
     133    }
     134    /// Copy of model on initial load
     135    inline CoinModel * originalCoinModel() const {
     136        return originalCoinModel_;
     137    }
     138    /// Copy of model on initial load (will contain output solutions)
     139    void setOriginalSolver(OsiClpSolverInterface * originalSolver);
     140    /// Copy of model on initial load
     141    void setOriginalCoinModel(CoinModel * originalCoinModel);
     142    /// Number of cutgenerators
     143    inline int numberCutGenerators() const {
     144        return numberCutGenerators_;
     145    }
     146    /// Cut generator array
     147    inline CglCutGenerator ** cutGeneratorArray() const {
     148        return cutGenerator_;
     149    }
     150    /// Start time
     151    inline double startTime() const {
     152        return startTime_;
     153    }
     154    /// Whether to print to std::cout
     155    inline void setPrinting(bool onOff) {
     156        noPrinting_ = !onOff;
     157    }
     158    /// Where to start reading commands
     159    inline void setReadMode(int value) {
     160        readMode_ = value;
     161    }
     162    //@}
     163private:
     164    ///@name Private member data
     165    //@{
     166
     167    /// Reference model
     168    CbcModel model_;
     169
     170    /// Updated model
     171    CbcModel * babModel_;
     172
     173    /// User functions
     174    CbcUser ** userFunction_;
     175    /** Status of user functions
     176        0 - not used
     177        1 - needs cbc_load
     178        2 - available - data in coinModel
     179        3 - data loaded - can do cbc_save
     180    */
     181    int * statusUserFunction_;
     182    /// Copy of model on initial load (will contain output solutions)
     183    OsiClpSolverInterface * originalSolver_;
     184    /// Copy of model on initial load
     185    CoinModel * originalCoinModel_;
     186    /// Cut generators
     187    CglCutGenerator ** cutGenerator_;
     188    /// Number of user functions
     189    int numberUserFunctions_;
     190    /// Number of cut generators
     191    int numberCutGenerators_;
     192    /// Stop now stuff
     193    CbcStopNow * callBack_;
     194    /// Cpu time at instantiation
     195    double startTime_;
     196    /// Parameters and values
     197    CbcOrClpParam * parameters_;
     198    /// Number of parameters
     199    int numberParameters_ ;
     200    /// Whether to do miplib test
     201    bool doMiplib_;
     202    /// Whether to print to std::cout
     203    bool noPrinting_;
     204    /// Where to start reading commands
     205    int readMode_;
     206    //@}
     207};
    208208//#############################################################################
    209209/// Structure to hold useful arrays
     
    221221    // Up pseudo costs
    222222    double * pseudoUp_;
    223     } CbcSolverUsefulData;
     223} CbcSolverUsefulData;
    224224/** This allows the use of an unknown user stuff including modeling languages
    225225 */
     
    227227class CbcUser  {
    228228
    229     public:
    230         ///@name import/export methods
    231         //@{
    232         /** Import - gets full command arguments
    233             Returns -1 - no action
    234                      0 - data read in without error
    235                  1 - errors
    236         */
    237         virtual int importData(CbcSolver * /*model*/, int & /*argc*/, char ** /*argv[]*/) {
    238             return -1;
    239             }
    240         /// Export 1 OsiClpSolver, 2 CbcModel - add 10 if infeasible from odd situation
    241         virtual void exportSolution(CbcSolver * /*model*/,
    242                                     int /*mode*/,const char * /*message*/=NULL) {}
    243         /// Export Data (i.e. at very end)
    244         virtual void exportData(CbcSolver * /*model*/) {}
    245         /// Get useful stuff
    246         virtual void fillInformation(CbcSolver * /*model*/,
    247                                      CbcSolverUsefulData & /*info*/) {}
    248 
    249         //@}
    250         ///@name usage methods
    251         //@{
    252         /// CoinModel if valid
    253         inline CoinModel * coinModel() const {
    254             return coinModel_;
    255             }
    256         /// Other info - needs expanding
    257         virtual void * stuff() {
    258             return NULL;
    259             }
    260         /// Name
    261         inline std::string name() const {
    262             return userName_;
    263             }
    264         /// Solve (whatever that means)
    265         virtual void solve(CbcSolver * model, const char * options) = 0;
    266         /// Returns true if function knows about option
    267         virtual bool canDo(const char * options) = 0;
    268         //@}
    269         ///@name Constructors and destructors etc
    270         //@{
    271         /// Default Constructor
    272         CbcUser();
    273 
    274         /** Copy constructor .
    275          */
    276         CbcUser(const CbcUser & rhs);
    277 
    278         /// Assignment operator
    279         CbcUser & operator=(const CbcUser& rhs);
    280 
    281         /// Clone
    282         virtual CbcUser * clone() const = 0;
    283 
    284         /// Destructor
    285         virtual ~CbcUser ();
    286         //@}
    287 
    288     protected:
    289         ///@name Private member data
    290         //@{
    291 
    292         /// CoinModel
    293         CoinModel * coinModel_;
    294 
    295         /// Name of user function
    296         std::string userName_;
     229public:
     230    ///@name import/export methods
     231    //@{
     232    /** Import - gets full command arguments
     233        Returns -1 - no action
     234                 0 - data read in without error
     235             1 - errors
     236    */
     237    virtual int importData(CbcSolver * /*model*/, int & /*argc*/, char ** /*argv[]*/) {
     238        return -1;
     239    }
     240    /// Export 1 OsiClpSolver, 2 CbcModel - add 10 if infeasible from odd situation
     241    virtual void exportSolution(CbcSolver * /*model*/,
     242                                int /*mode*/, const char * /*message*/ = NULL) {}
     243    /// Export Data (i.e. at very end)
     244    virtual void exportData(CbcSolver * /*model*/) {}
     245    /// Get useful stuff
     246    virtual void fillInformation(CbcSolver * /*model*/,
     247                                 CbcSolverUsefulData & /*info*/) {}
     248
     249    //@}
     250    ///@name usage methods
     251    //@{
     252    /// CoinModel if valid
     253    inline CoinModel * coinModel() const {
     254        return coinModel_;
     255    }
     256    /// Other info - needs expanding
     257    virtual void * stuff() {
     258        return NULL;
     259    }
     260    /// Name
     261    inline std::string name() const {
     262        return userName_;
     263    }
     264    /// Solve (whatever that means)
     265    virtual void solve(CbcSolver * model, const char * options) = 0;
     266    /// Returns true if function knows about option
     267    virtual bool canDo(const char * options) = 0;
     268    //@}
     269    ///@name Constructors and destructors etc
     270    //@{
     271    /// Default Constructor
     272    CbcUser();
     273
     274    /** Copy constructor .
     275     */
     276    CbcUser(const CbcUser & rhs);
     277
     278    /// Assignment operator
     279    CbcUser & operator=(const CbcUser& rhs);
     280
     281    /// Clone
     282    virtual CbcUser * clone() const = 0;
     283
     284    /// Destructor
     285    virtual ~CbcUser ();
     286    //@}
     287
     288protected:
     289    ///@name Private member data
     290    //@{
     291
     292    /// CoinModel
     293    CoinModel * coinModel_;
     294
     295    /// Name of user function
     296    std::string userName_;
    297297
    298298//@}
    299     };
     299};
    300300//#############################################################################
    301301
     
    305305class CbcStopNow  {
    306306
    307     public:
    308         ///@name Decision methods
    309         //@{
    310         /// Import - 0 if good
    311         /** Meaning of whereFrom:
    312            1 after initial solve by dualsimplex etc
    313            2 after preprocessing
    314            3 just before branchAndBound (so user can override)
    315            4 just after branchAndBound (before postprocessing)
    316            5 after postprocessing
    317            6 after a user called heuristic phase
    318            nonzero return code to stop
    319         */
    320         virtual int callBack(CbcModel * /*currentSolver*/,
    321                              int /*whereFrom*/) {
    322             return 0;
    323             }
    324         //@}
    325         ///@name Constructors and destructors etc
    326         //@{
    327         /// Default Constructor
    328         CbcStopNow();
    329 
    330         /** Copy constructor .
    331          */
    332         CbcStopNow(const CbcStopNow & rhs);
    333 
    334         /// Assignment operator
    335         CbcStopNow & operator=(const CbcStopNow& rhs);
    336 
    337         /// Clone
    338         virtual CbcStopNow * clone() const;
    339 
    340         /// Destructor
    341         virtual ~CbcStopNow ();
    342         //@}
    343 
    344     private:
    345         ///@name Private member data
    346         //@{
     307public:
     308    ///@name Decision methods
     309    //@{
     310    /// Import - 0 if good
     311    /** Meaning of whereFrom:
     312       1 after initial solve by dualsimplex etc
     313       2 after preprocessing
     314       3 just before branchAndBound (so user can override)
     315       4 just after branchAndBound (before postprocessing)
     316       5 after postprocessing
     317       6 after a user called heuristic phase
     318       nonzero return code to stop
     319    */
     320    virtual int callBack(CbcModel * /*currentSolver*/,
     321                         int /*whereFrom*/) {
     322        return 0;
     323    }
     324    //@}
     325    ///@name Constructors and destructors etc
     326    //@{
     327    /// Default Constructor
     328    CbcStopNow();
     329
     330    /** Copy constructor .
     331     */
     332    CbcStopNow(const CbcStopNow & rhs);
     333
     334    /// Assignment operator
     335    CbcStopNow & operator=(const CbcStopNow& rhs);
     336
     337    /// Clone
     338    virtual CbcStopNow * clone() const;
     339
     340    /// Destructor
     341    virtual ~CbcStopNow ();
     342    //@}
     343
     344private:
     345    ///@name Private member data
     346    //@{
    347347//@}
    348     };
     348};
    349349#endif
Note: See TracChangeset for help on using the changeset viewer.