lemon/clp.h
changeset 802 994c7df296c9
parent 540 9db62975c32b
child 746 e4554cd6b2bf
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/lemon/clp.h	Thu Dec 10 17:05:35 2009 +0100
     1.3 @@ -0,0 +1,163 @@
     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_CLP_H
    1.23 +#define LEMON_CLP_H
    1.24 +
    1.25 +///\file
    1.26 +///\brief Header of the LEMON-CLP lp solver interface.
    1.27 +
    1.28 +#include <vector>
    1.29 +#include <string>
    1.30 +
    1.31 +#include <lemon/lp_base.h>
    1.32 +
    1.33 +class ClpSimplex;
    1.34 +
    1.35 +namespace lemon {
    1.36 +
    1.37 +  /// \ingroup lp_group
    1.38 +  ///
    1.39 +  /// \brief Interface for the CLP solver
    1.40 +  ///
    1.41 +  /// This class implements an interface for the Clp LP solver.  The
    1.42 +  /// Clp library is an object oriented lp solver library developed at
    1.43 +  /// the IBM. The CLP is part of the COIN-OR package and it can be
    1.44 +  /// used with Common Public License.
    1.45 +  class ClpLp : public LpSolver {
    1.46 +  protected:
    1.47 +
    1.48 +    ClpSimplex* _prob;
    1.49 +
    1.50 +    std::map<std::string, int> _col_names_ref;
    1.51 +    std::map<std::string, int> _row_names_ref;
    1.52 +
    1.53 +  public:
    1.54 +
    1.55 +    /// \e
    1.56 +    ClpLp();
    1.57 +    /// \e
    1.58 +    ClpLp(const ClpLp&);
    1.59 +    /// \e
    1.60 +    ~ClpLp();
    1.61 +
    1.62 +    /// \e
    1.63 +    virtual ClpLp* newSolver() const;
    1.64 +    /// \e
    1.65 +    virtual ClpLp* cloneSolver() const;
    1.66 +
    1.67 +  protected:
    1.68 +
    1.69 +    mutable double* _primal_ray;
    1.70 +    mutable double* _dual_ray;
    1.71 +
    1.72 +    void _init_temporals();
    1.73 +    void _clear_temporals();
    1.74 +
    1.75 +  protected:
    1.76 +
    1.77 +    virtual const char* _solverName() const;
    1.78 +
    1.79 +    virtual int _addCol();
    1.80 +    virtual int _addRow();
    1.81 +
    1.82 +    virtual void _eraseCol(int i);
    1.83 +    virtual void _eraseRow(int i);
    1.84 +
    1.85 +    virtual void _eraseColId(int i);
    1.86 +    virtual void _eraseRowId(int i);
    1.87 +
    1.88 +    virtual void _getColName(int col, std::string& name) const;
    1.89 +    virtual void _setColName(int col, const std::string& name);
    1.90 +    virtual int _colByName(const std::string& name) const;
    1.91 +
    1.92 +    virtual void _getRowName(int row, std::string& name) const;
    1.93 +    virtual void _setRowName(int row, const std::string& name);
    1.94 +    virtual int _rowByName(const std::string& name) const;
    1.95 +
    1.96 +    virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
    1.97 +    virtual void _getRowCoeffs(int i, InsertIterator b) const;
    1.98 +
    1.99 +    virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
   1.100 +    virtual void _getColCoeffs(int i, InsertIterator b) const;
   1.101 +
   1.102 +    virtual void _setCoeff(int row, int col, Value value);
   1.103 +    virtual Value _getCoeff(int row, int col) const;
   1.104 +
   1.105 +    virtual void _setColLowerBound(int i, Value value);
   1.106 +    virtual Value _getColLowerBound(int i) const;
   1.107 +    virtual void _setColUpperBound(int i, Value value);
   1.108 +    virtual Value _getColUpperBound(int i) const;
   1.109 +
   1.110 +    virtual void _setRowLowerBound(int i, Value value);
   1.111 +    virtual Value _getRowLowerBound(int i) const;
   1.112 +    virtual void _setRowUpperBound(int i, Value value);
   1.113 +    virtual Value _getRowUpperBound(int i) const;
   1.114 +
   1.115 +    virtual void _setObjCoeffs(ExprIterator, ExprIterator);
   1.116 +    virtual void _getObjCoeffs(InsertIterator) const;
   1.117 +
   1.118 +    virtual void _setObjCoeff(int i, Value obj_coef);
   1.119 +    virtual Value _getObjCoeff(int i) const;
   1.120 +
   1.121 +    virtual void _setSense(Sense sense);
   1.122 +    virtual Sense _getSense() const;
   1.123 +
   1.124 +    virtual SolveExitStatus _solve();
   1.125 +
   1.126 +    virtual Value _getPrimal(int i) const;
   1.127 +    virtual Value _getDual(int i) const;
   1.128 +
   1.129 +    virtual Value _getPrimalValue() const;
   1.130 +
   1.131 +    virtual Value _getPrimalRay(int i) const;
   1.132 +    virtual Value _getDualRay(int i) const;
   1.133 +
   1.134 +    virtual VarStatus _getColStatus(int i) const;
   1.135 +    virtual VarStatus _getRowStatus(int i) const;
   1.136 +
   1.137 +    virtual ProblemType _getPrimalType() const;
   1.138 +    virtual ProblemType _getDualType() const;
   1.139 +
   1.140 +    virtual void _clear();
   1.141 +
   1.142 +    virtual void _messageLevel(MessageLevel);
   1.143 +    
   1.144 +  public:
   1.145 +
   1.146 +    ///Solves LP with primal simplex method.
   1.147 +    SolveExitStatus solvePrimal();
   1.148 +
   1.149 +    ///Solves LP with dual simplex method.
   1.150 +    SolveExitStatus solveDual();
   1.151 +
   1.152 +    ///Solves LP with barrier method.
   1.153 +    SolveExitStatus solveBarrier();
   1.154 +
   1.155 +    ///Returns the constraint identifier understood by CLP.
   1.156 +    int clpRow(Row r) const { return rows(id(r)); }
   1.157 +
   1.158 +    ///Returns the variable identifier understood by CLP.
   1.159 +    int clpCol(Col c) const { return cols(id(c)); }
   1.160 +
   1.161 +  };
   1.162 +
   1.163 +} //END OF NAMESPACE LEMON
   1.164 +
   1.165 +#endif //LEMON_CLP_H
   1.166 +