lemon/glpk.h
changeset 783 ef88c0a30f85
parent 650 a8dfe89b7719
child 833 d2bc45e8f6f2
     1.1 --- a/lemon/glpk.h	Mon Jan 12 23:11:39 2009 +0100
     1.2 +++ b/lemon/glpk.h	Thu Nov 05 15:48:01 2009 +0100
     1.3 @@ -26,9 +26,10 @@
     1.4  #include <lemon/lp_base.h>
     1.5  
     1.6  // forward declaration
     1.7 -#ifndef _GLP_PROB
     1.8 +#if !defined _GLP_PROB && !defined GLP_PROB
     1.9  #define _GLP_PROB
    1.10 -typedef struct { double _prob; } glp_prob;
    1.11 +#define GLP_PROB
    1.12 +typedef struct { double _opaque_prob; } glp_prob;
    1.13  /* LP/MIP problem object */
    1.14  #endif
    1.15  
    1.16 @@ -53,6 +54,7 @@
    1.17  
    1.18      virtual int _addCol();
    1.19      virtual int _addRow();
    1.20 +    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
    1.21  
    1.22      virtual void _eraseCol(int i);
    1.23      virtual void _eraseRow(int i);
    1.24 @@ -100,6 +102,24 @@
    1.25  
    1.26      virtual void _clear();
    1.27  
    1.28 +    virtual void _messageLevel(MessageLevel level);
    1.29 +
    1.30 +  private:
    1.31 +
    1.32 +    static void freeEnv();
    1.33 +
    1.34 +    struct FreeEnvHelper {
    1.35 +      ~FreeEnvHelper() {
    1.36 +        freeEnv();
    1.37 +      }
    1.38 +    };
    1.39 +    
    1.40 +    static FreeEnvHelper freeEnvHelper;
    1.41 +
    1.42 +  protected:
    1.43 +    
    1.44 +    int _message_level;
    1.45 +    
    1.46    public:
    1.47  
    1.48      ///Pointer to the underlying GLPK data structure.
    1.49 @@ -119,7 +139,7 @@
    1.50    ///
    1.51    /// This class implements an interface for the GLPK LP solver.
    1.52    ///\ingroup lp_group
    1.53 -  class GlpkLp : public GlpkBase, public LpSolver {
    1.54 +  class GlpkLp : public LpSolver, public GlpkBase {
    1.55    public:
    1.56  
    1.57      ///\e
    1.58 @@ -127,6 +147,11 @@
    1.59      ///\e
    1.60      GlpkLp(const GlpkLp&);
    1.61  
    1.62 +    ///\e
    1.63 +    virtual GlpkLp* cloneSolver() const;
    1.64 +    ///\e
    1.65 +    virtual GlpkLp* newSolver() const;
    1.66 +
    1.67    private:
    1.68  
    1.69      mutable std::vector<double> _primal_ray;
    1.70 @@ -136,9 +161,6 @@
    1.71  
    1.72    protected:
    1.73  
    1.74 -    virtual GlpkLp* _cloneSolver() const;
    1.75 -    virtual GlpkLp* _newSolver() const;
    1.76 -
    1.77      virtual const char* _solverName() const;
    1.78  
    1.79      virtual SolveExitStatus _solve();
    1.80 @@ -153,8 +175,6 @@
    1.81      virtual Value _getPrimalRay(int i) const;
    1.82      virtual Value _getDualRay(int i) const;
    1.83  
    1.84 -    ///\todo It should be clarified
    1.85 -    ///
    1.86      virtual ProblemType _getPrimalType() const;
    1.87      virtual ProblemType _getDualType() const;
    1.88  
    1.89 @@ -166,44 +186,26 @@
    1.90      ///Solve with dual simplex
    1.91      SolveExitStatus solveDual();
    1.92  
    1.93 +  private:
    1.94 +
    1.95 +    bool _presolve;
    1.96 +
    1.97 +  public:
    1.98 +
    1.99      ///Turns on or off the presolver
   1.100  
   1.101      ///Turns on (\c b is \c true) or off (\c b is \c false) the presolver
   1.102      ///
   1.103      ///The presolver is off by default.
   1.104 -    void presolver(bool b);
   1.105 +    void presolver(bool presolve);
   1.106  
   1.107 -    ///Enum for \c messageLevel() parameter
   1.108 -    enum MessageLevel {
   1.109 -      /// no output (default value)
   1.110 -      MESSAGE_NO_OUTPUT = 0,
   1.111 -      /// error messages only
   1.112 -      MESSAGE_ERROR_MESSAGE = 1,
   1.113 -      /// normal output
   1.114 -      MESSAGE_NORMAL_OUTPUT = 2,
   1.115 -      /// full output (includes informational messages)
   1.116 -      MESSAGE_FULL_OUTPUT = 3
   1.117 -    };
   1.118 -
   1.119 -  private:
   1.120 -
   1.121 -    MessageLevel _message_level;
   1.122 -
   1.123 -  public:
   1.124 -
   1.125 -    ///Set the verbosity of the messages
   1.126 -
   1.127 -    ///Set the verbosity of the messages
   1.128 -    ///
   1.129 -    ///\param m is the level of the messages output by the solver routines.
   1.130 -    void messageLevel(MessageLevel m);
   1.131    };
   1.132  
   1.133    /// \brief Interface for the GLPK MIP solver
   1.134    ///
   1.135    /// This class implements an interface for the GLPK MIP solver.
   1.136    ///\ingroup lp_group
   1.137 -  class GlpkMip : public GlpkBase, public MipSolver {
   1.138 +  class GlpkMip : public MipSolver, public GlpkBase {
   1.139    public:
   1.140  
   1.141      ///\e
   1.142 @@ -211,11 +213,11 @@
   1.143      ///\e
   1.144      GlpkMip(const GlpkMip&);
   1.145  
   1.146 +    virtual GlpkMip* cloneSolver() const;
   1.147 +    virtual GlpkMip* newSolver() const;
   1.148 +
   1.149    protected:
   1.150  
   1.151 -    virtual GlpkMip* _cloneSolver() const;
   1.152 -    virtual GlpkMip* _newSolver() const;
   1.153 -
   1.154      virtual const char* _solverName() const;
   1.155  
   1.156      virtual ColTypes _getColType(int col) const;
   1.157 @@ -226,30 +228,6 @@
   1.158      virtual Value _getSol(int i) const;
   1.159      virtual Value _getSolValue() const;
   1.160  
   1.161 -    ///Enum for \c messageLevel() parameter
   1.162 -    enum MessageLevel {
   1.163 -      /// no output (default value)
   1.164 -      MESSAGE_NO_OUTPUT = 0,
   1.165 -      /// error messages only
   1.166 -      MESSAGE_ERROR_MESSAGE = 1,
   1.167 -      /// normal output
   1.168 -      MESSAGE_NORMAL_OUTPUT = 2,
   1.169 -      /// full output (includes informational messages)
   1.170 -      MESSAGE_FULL_OUTPUT = 3
   1.171 -    };
   1.172 -
   1.173 -  private:
   1.174 -
   1.175 -    MessageLevel _message_level;
   1.176 -
   1.177 -  public:
   1.178 -
   1.179 -    ///Set the verbosity of the messages
   1.180 -
   1.181 -    ///Set the verbosity of the messages
   1.182 -    ///
   1.183 -    ///\param m is the level of the messages output by the solver routines.
   1.184 -    void messageLevel(MessageLevel m);
   1.185    };
   1.186  
   1.187