lemon/lp_cplex.h
changeset 461 08d495d48089
parent 460 76ec7bd57026
child 462 9b082b3fb33f
     1.1 --- a/lemon/lp_cplex.h	Mon Jan 12 12:25:55 2009 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,256 +0,0 @@
     1.4 -/* -*- mode: C++; indent-tabs-mode: nil; -*-
     1.5 - *
     1.6 - * This file is a part of LEMON, a generic C++ optimization library.
     1.7 - *
     1.8 - * Copyright (C) 2003-2008
     1.9 - * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10 - * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11 - *
    1.12 - * Permission to use, modify and distribute this software is granted
    1.13 - * provided that this copyright notice appears in all copies. For
    1.14 - * precise terms see the accompanying LICENSE file.
    1.15 - *
    1.16 - * This software is provided "AS IS" with no warranty of any kind,
    1.17 - * express or implied, and with no claim as to its suitability for any
    1.18 - * purpose.
    1.19 - *
    1.20 - */
    1.21 -
    1.22 -#ifndef LEMON_LP_CPLEX_H
    1.23 -#define LEMON_LP_CPLEX_H
    1.24 -
    1.25 -///\file
    1.26 -///\brief Header of the LEMON-CPLEX lp solver interface.
    1.27 -
    1.28 -#include <lemon/lp_base.h>
    1.29 -
    1.30 -struct cpxenv;
    1.31 -struct cpxlp;
    1.32 -
    1.33 -namespace lemon {
    1.34 -
    1.35 -  /// \brief Reference counted wrapper around cpxenv pointer
    1.36 -  ///
    1.37 -  /// The cplex uses environment object which is responsible for
    1.38 -  /// checking the proper license usage. This class provides a simple
    1.39 -  /// interface for share the environment object between different
    1.40 -  /// problems.
    1.41 -  class CplexEnv {
    1.42 -    friend class CplexBase;
    1.43 -  private:
    1.44 -    cpxenv* _env;
    1.45 -    mutable int* _cnt;
    1.46 -
    1.47 -  public:
    1.48 -
    1.49 -    /// \brief This exception is thrown when the license check is not
    1.50 -    /// sufficient
    1.51 -    class LicenseError : public Exception {
    1.52 -      friend class CplexEnv;
    1.53 -    private:
    1.54 -
    1.55 -      LicenseError(int status);
    1.56 -      char _message[510];
    1.57 -
    1.58 -    public:
    1.59 -
    1.60 -      /// The short error message
    1.61 -      virtual const char* what() const throw() {
    1.62 -        return _message;
    1.63 -      }
    1.64 -    };
    1.65 -
    1.66 -    /// Constructor
    1.67 -    CplexEnv();
    1.68 -    /// Shallow copy constructor
    1.69 -    CplexEnv(const CplexEnv&);
    1.70 -    /// Shallow assignement
    1.71 -    CplexEnv& operator=(const CplexEnv&);
    1.72 -    /// Destructor
    1.73 -    virtual ~CplexEnv();
    1.74 -
    1.75 -  protected:
    1.76 -
    1.77 -    cpxenv* cplexEnv() { return _env; }
    1.78 -    const cpxenv* cplexEnv() const { return _env; }
    1.79 -  };
    1.80 -
    1.81 -  /// \brief Base interface for the CPLEX LP and MIP solver
    1.82 -  ///
    1.83 -  /// This class implements the common interface of the CPLEX LP and
    1.84 -  /// MIP solvers.  
    1.85 -  /// \ingroup lp_group
    1.86 -  class CplexBase : virtual public LpBase {
    1.87 -  protected:
    1.88 -
    1.89 -    CplexEnv _env;
    1.90 -    cpxlp* _prob;
    1.91 -
    1.92 -    CplexBase();
    1.93 -    CplexBase(const CplexEnv&);
    1.94 -    CplexBase(const CplexBase &);
    1.95 -    virtual ~CplexBase();
    1.96 -
    1.97 -    virtual int _addCol();
    1.98 -    virtual int _addRow();
    1.99 -
   1.100 -    virtual void _eraseCol(int i);
   1.101 -    virtual void _eraseRow(int i);
   1.102 -
   1.103 -    virtual void _eraseColId(int i);
   1.104 -    virtual void _eraseRowId(int i);
   1.105 -
   1.106 -    virtual void _getColName(int col, std::string& name) const;
   1.107 -    virtual void _setColName(int col, const std::string& name);
   1.108 -    virtual int _colByName(const std::string& name) const;
   1.109 -
   1.110 -    virtual void _getRowName(int row, std::string& name) const;
   1.111 -    virtual void _setRowName(int row, const std::string& name);
   1.112 -    virtual int _rowByName(const std::string& name) const;
   1.113 -
   1.114 -    virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
   1.115 -    virtual void _getRowCoeffs(int i, InsertIterator b) const;
   1.116 -
   1.117 -    virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
   1.118 -    virtual void _getColCoeffs(int i, InsertIterator b) const;
   1.119 -
   1.120 -    virtual void _setCoeff(int row, int col, Value value);
   1.121 -    virtual Value _getCoeff(int row, int col) const;
   1.122 -
   1.123 -    virtual void _setColLowerBound(int i, Value value);
   1.124 -    virtual Value _getColLowerBound(int i) const;
   1.125 -
   1.126 -    virtual void _setColUpperBound(int i, Value value);
   1.127 -    virtual Value _getColUpperBound(int i) const;
   1.128 -
   1.129 -  private:
   1.130 -    void _set_row_bounds(int i, Value lb, Value ub);
   1.131 -  protected:
   1.132 -
   1.133 -    virtual void _setRowLowerBound(int i, Value value);
   1.134 -    virtual Value _getRowLowerBound(int i) const;
   1.135 -
   1.136 -    virtual void _setRowUpperBound(int i, Value value);
   1.137 -    virtual Value _getRowUpperBound(int i) const;
   1.138 -
   1.139 -    virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
   1.140 -    virtual void _getObjCoeffs(InsertIterator b) const;
   1.141 -
   1.142 -    virtual void _setObjCoeff(int i, Value obj_coef);
   1.143 -    virtual Value _getObjCoeff(int i) const;
   1.144 -
   1.145 -    virtual void _setSense(Sense sense);
   1.146 -    virtual Sense _getSense() const;
   1.147 -
   1.148 -    virtual void _clear();
   1.149 -
   1.150 -  public:
   1.151 -
   1.152 -    /// Returns the used \c CplexEnv instance
   1.153 -    const CplexEnv& env() const { return _env; }
   1.154 -    ///
   1.155 -    const cpxenv* cplexEnv() const { return _env.cplexEnv(); }
   1.156 -
   1.157 -    cpxlp* cplexLp() { return _prob; }
   1.158 -    const cpxlp* cplexLp() const { return _prob; }
   1.159 -
   1.160 -  };
   1.161 -
   1.162 -  /// \brief Interface for the CPLEX LP solver
   1.163 -  ///
   1.164 -  /// This class implements an interface for the CPLEX LP solver.
   1.165 -  ///\ingroup lp_group
   1.166 -  class LpCplex : public CplexBase, public LpSolver {
   1.167 -  public:
   1.168 -    /// \e
   1.169 -    LpCplex();
   1.170 -    /// \e
   1.171 -    LpCplex(const CplexEnv&);
   1.172 -    /// \e
   1.173 -    LpCplex(const LpCplex&);
   1.174 -    /// \e
   1.175 -    virtual ~LpCplex();
   1.176 -
   1.177 -  private:
   1.178 -
   1.179 -    // these values cannot retrieved element by element
   1.180 -    mutable std::vector<int> _col_status;
   1.181 -    mutable std::vector<int> _row_status;
   1.182 -
   1.183 -    mutable std::vector<Value> _primal_ray;
   1.184 -    mutable std::vector<Value> _dual_ray;
   1.185 -
   1.186 -    void _clear_temporals();
   1.187 -
   1.188 -    SolveExitStatus convertStatus(int status);
   1.189 -
   1.190 -  protected:
   1.191 -
   1.192 -    virtual LpCplex* _cloneSolver() const;
   1.193 -    virtual LpCplex* _newSolver() const;
   1.194 -
   1.195 -    virtual const char* _solverName() const;
   1.196 -
   1.197 -    virtual SolveExitStatus _solve();
   1.198 -    virtual Value _getPrimal(int i) const;
   1.199 -    virtual Value _getDual(int i) const;
   1.200 -    virtual Value _getPrimalValue() const;
   1.201 -
   1.202 -    virtual VarStatus _getColStatus(int i) const;
   1.203 -    virtual VarStatus _getRowStatus(int i) const;
   1.204 -
   1.205 -    virtual Value _getPrimalRay(int i) const;
   1.206 -    virtual Value _getDualRay(int i) const;
   1.207 -
   1.208 -    virtual ProblemType _getPrimalType() const;
   1.209 -    virtual ProblemType _getDualType() const;
   1.210 -
   1.211 -  public:
   1.212 -
   1.213 -    /// Solve with primal simplex method
   1.214 -    SolveExitStatus solvePrimal();
   1.215 -
   1.216 -    /// Solve with dual simplex method
   1.217 -    SolveExitStatus solveDual();
   1.218 -
   1.219 -    /// Solve with barrier method
   1.220 -    SolveExitStatus solveBarrier();
   1.221 -
   1.222 -  };
   1.223 -
   1.224 -  /// \brief Interface for the CPLEX MIP solver
   1.225 -  ///
   1.226 -  /// This class implements an interface for the CPLEX MIP solver.
   1.227 -  ///\ingroup lp_group
   1.228 -  class MipCplex : public CplexBase, public MipSolver {
   1.229 -  public:
   1.230 -    /// \e
   1.231 -    MipCplex();
   1.232 -    /// \e
   1.233 -    MipCplex(const CplexEnv&);
   1.234 -    /// \e
   1.235 -    MipCplex(const MipCplex&);
   1.236 -    /// \e
   1.237 -    virtual ~MipCplex();
   1.238 -
   1.239 -  protected:
   1.240 -
   1.241 -    virtual MipCplex* _cloneSolver() const;
   1.242 -    virtual MipCplex* _newSolver() const;
   1.243 -
   1.244 -    virtual const char* _solverName() const;
   1.245 -
   1.246 -    virtual ColTypes _getColType(int col) const;
   1.247 -    virtual void _setColType(int col, ColTypes col_type);
   1.248 -
   1.249 -    virtual SolveExitStatus _solve();
   1.250 -    virtual ProblemType _getType() const;
   1.251 -    virtual Value _getSol(int i) const;
   1.252 -    virtual Value _getSolValue() const;
   1.253 -
   1.254 -  };
   1.255 -
   1.256 -} //END OF NAMESPACE LEMON
   1.257 -
   1.258 -#endif //LEMON_LP_CPLEX_H
   1.259 -