lemon/cbc.h
changeset 579 d11bf7998905
child 576 745e182d0139
equal deleted inserted replaced
-1:000000000000 0:3f9c09dc4f7e
       
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
       
     2  *
       
     3  * This file is a part of LEMON, a generic C++ optimization library.
       
     4  *
       
     5  * Copyright (C) 2003-2009
       
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
       
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
       
     8  *
       
     9  * Permission to use, modify and distribute this software is granted
       
    10  * provided that this copyright notice appears in all copies. For
       
    11  * precise terms see the accompanying LICENSE file.
       
    12  *
       
    13  * This software is provided "AS IS" with no warranty of any kind,
       
    14  * express or implied, and with no claim as to its suitability for any
       
    15  * purpose.
       
    16  *
       
    17  */
       
    18 
       
    19 // -*- C++ -*-
       
    20 #ifndef LEMON_CBC_H
       
    21 #define LEMON_CBC_H
       
    22 
       
    23 ///\file
       
    24 ///\brief Header of the LEMON-CBC mip solver interface.
       
    25 ///\ingroup lp_group
       
    26 
       
    27 #include <lemon/lp_base.h>
       
    28 
       
    29 class CoinModel;
       
    30 class OsiSolverInterface;
       
    31 class CbcModel;
       
    32 
       
    33 namespace lemon {
       
    34 
       
    35   /// \brief Interface for the CBC MIP solver
       
    36   ///
       
    37   /// This class implements an interface for the CBC MIP solver.
       
    38   ///\ingroup lp_group
       
    39   class CbcMip : public MipSolver {
       
    40   protected:
       
    41 
       
    42     CoinModel *_prob;
       
    43     OsiSolverInterface *_osi_solver;
       
    44     CbcModel *_cbc_model;
       
    45 
       
    46   public:
       
    47 
       
    48     /// \e
       
    49     CbcMip();
       
    50     /// \e
       
    51     CbcMip(const CbcMip&);
       
    52     /// \e
       
    53     ~CbcMip();
       
    54     /// \e
       
    55     virtual CbcMip* newSolver() const;
       
    56     /// \e
       
    57     virtual CbcMip* cloneSolver() const;
       
    58 
       
    59   protected:
       
    60 
       
    61     virtual const char* _solverName() const;
       
    62 
       
    63     virtual int _addCol();
       
    64     virtual int _addRow();
       
    65 
       
    66     virtual void _eraseCol(int i);
       
    67     virtual void _eraseRow(int i);
       
    68 
       
    69     virtual void _eraseColId(int i);
       
    70     virtual void _eraseRowId(int i);
       
    71 
       
    72     virtual void _getColName(int col, std::string& name) const;
       
    73     virtual void _setColName(int col, const std::string& name);
       
    74     virtual int _colByName(const std::string& name) const;
       
    75 
       
    76     virtual void _getRowName(int row, std::string& name) const;
       
    77     virtual void _setRowName(int row, const std::string& name);
       
    78     virtual int _rowByName(const std::string& name) const;
       
    79 
       
    80     virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
       
    81     virtual void _getRowCoeffs(int i, InsertIterator b) const;
       
    82 
       
    83     virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
       
    84     virtual void _getColCoeffs(int i, InsertIterator b) const;
       
    85 
       
    86     virtual void _setCoeff(int row, int col, Value value);
       
    87     virtual Value _getCoeff(int row, int col) const;
       
    88 
       
    89     virtual void _setColLowerBound(int i, Value value);
       
    90     virtual Value _getColLowerBound(int i) const;
       
    91     virtual void _setColUpperBound(int i, Value value);
       
    92     virtual Value _getColUpperBound(int i) const;
       
    93 
       
    94     virtual void _setRowLowerBound(int i, Value value);
       
    95     virtual Value _getRowLowerBound(int i) const;
       
    96     virtual void _setRowUpperBound(int i, Value value);
       
    97     virtual Value _getRowUpperBound(int i) const;
       
    98 
       
    99     virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
       
   100     virtual void _getObjCoeffs(InsertIterator b) const;
       
   101 
       
   102     virtual void _setObjCoeff(int i, Value obj_coef);
       
   103     virtual Value _getObjCoeff(int i) const;
       
   104 
       
   105     virtual void _setSense(Sense sense);
       
   106     virtual Sense _getSense() const;
       
   107 
       
   108     virtual ColTypes _getColType(int col) const;
       
   109     virtual void _setColType(int col, ColTypes col_type);
       
   110 
       
   111     virtual SolveExitStatus _solve();
       
   112     virtual ProblemType _getType() const;
       
   113     virtual Value _getSol(int i) const;
       
   114     virtual Value _getSolValue() const;
       
   115 
       
   116     virtual void _clear();
       
   117 
       
   118   public:
       
   119 
       
   120     ///Enum for \c messageLevel() parameter
       
   121     enum MessageLevel {
       
   122       /// no output (default value)
       
   123       MESSAGE_NO_OUTPUT = 0,
       
   124       /// error messages only
       
   125       MESSAGE_ERROR_MESSAGE = 1,
       
   126       /// normal output
       
   127       MESSAGE_NORMAL_OUTPUT = 2,
       
   128       /// full output (includes informational messages)
       
   129       MESSAGE_FULL_OUTPUT = 3
       
   130     };
       
   131 
       
   132   private:
       
   133 
       
   134     MessageLevel _message_level;
       
   135 
       
   136   public:
       
   137 
       
   138     ///Set the verbosity of the messages
       
   139 
       
   140     ///Set the verbosity of the messages
       
   141     ///
       
   142     ///\param m is the level of the messages output by the solver routines.
       
   143     void messageLevel(MessageLevel m);
       
   144 
       
   145 
       
   146   };
       
   147 
       
   148 }
       
   149 
       
   150 #endif