1.1 --- a/lemon/lp_clp.h Mon Jan 12 12:25:55 2009 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,179 +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_CLP_H
1.23 -#define LEMON_LP_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 LpClp : 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 - LpClp();
1.57 - /// \e
1.58 - LpClp(const LpClp&);
1.59 - /// \e
1.60 - ~LpClp();
1.61 -
1.62 - protected:
1.63 -
1.64 - mutable double* _primal_ray;
1.65 - mutable double* _dual_ray;
1.66 -
1.67 - void _init_temporals();
1.68 - void _clear_temporals();
1.69 -
1.70 - protected:
1.71 -
1.72 - virtual LpClp* _newSolver() const;
1.73 - virtual LpClp* _cloneSolver() const;
1.74 -
1.75 - virtual const char* _solverName() const;
1.76 -
1.77 - virtual int _addCol();
1.78 - virtual int _addRow();
1.79 -
1.80 - virtual void _eraseCol(int i);
1.81 - virtual void _eraseRow(int i);
1.82 -
1.83 - virtual void _eraseColId(int i);
1.84 - virtual void _eraseRowId(int i);
1.85 -
1.86 - virtual void _getColName(int col, std::string& name) const;
1.87 - virtual void _setColName(int col, const std::string& name);
1.88 - virtual int _colByName(const std::string& name) const;
1.89 -
1.90 - virtual void _getRowName(int row, std::string& name) const;
1.91 - virtual void _setRowName(int row, const std::string& name);
1.92 - virtual int _rowByName(const std::string& name) const;
1.93 -
1.94 - virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
1.95 - virtual void _getRowCoeffs(int i, InsertIterator b) const;
1.96 -
1.97 - virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
1.98 - virtual void _getColCoeffs(int i, InsertIterator b) const;
1.99 -
1.100 - virtual void _setCoeff(int row, int col, Value value);
1.101 - virtual Value _getCoeff(int row, int col) const;
1.102 -
1.103 - virtual void _setColLowerBound(int i, Value value);
1.104 - virtual Value _getColLowerBound(int i) const;
1.105 - virtual void _setColUpperBound(int i, Value value);
1.106 - virtual Value _getColUpperBound(int i) const;
1.107 -
1.108 - virtual void _setRowLowerBound(int i, Value value);
1.109 - virtual Value _getRowLowerBound(int i) const;
1.110 - virtual void _setRowUpperBound(int i, Value value);
1.111 - virtual Value _getRowUpperBound(int i) const;
1.112 -
1.113 - virtual void _setObjCoeffs(ExprIterator, ExprIterator);
1.114 - virtual void _getObjCoeffs(InsertIterator) const;
1.115 -
1.116 - virtual void _setObjCoeff(int i, Value obj_coef);
1.117 - virtual Value _getObjCoeff(int i) const;
1.118 -
1.119 - virtual void _setSense(Sense sense);
1.120 - virtual Sense _getSense() const;
1.121 -
1.122 - virtual SolveExitStatus _solve();
1.123 -
1.124 - virtual Value _getPrimal(int i) const;
1.125 - virtual Value _getDual(int i) const;
1.126 -
1.127 - virtual Value _getPrimalValue() const;
1.128 -
1.129 - virtual Value _getPrimalRay(int i) const;
1.130 - virtual Value _getDualRay(int i) const;
1.131 -
1.132 - virtual VarStatus _getColStatus(int i) const;
1.133 - virtual VarStatus _getRowStatus(int i) const;
1.134 -
1.135 - virtual ProblemType _getPrimalType() const;
1.136 - virtual ProblemType _getDualType() const;
1.137 -
1.138 - virtual void _clear();
1.139 -
1.140 - public:
1.141 -
1.142 - ///Solves LP with primal simplex method.
1.143 - SolveExitStatus solvePrimal();
1.144 -
1.145 - ///Solves LP with dual simplex method.
1.146 - SolveExitStatus solveDual();
1.147 -
1.148 - ///Solves LP with barrier method.
1.149 - SolveExitStatus solveBarrier();
1.150 -
1.151 - ///Returns the constraint identifier understood by CLP.
1.152 - int clpRow(Row r) const { return rows(id(r)); }
1.153 -
1.154 - ///Returns the variable identifier understood by CLP.
1.155 - int clpCol(Col c) const { return cols(id(c)); }
1.156 -
1.157 - ///Enum for \c messageLevel() parameter
1.158 - enum MessageLevel {
1.159 - /// no output (default value)
1.160 - MESSAGE_NO_OUTPUT = 0,
1.161 - /// print final solution
1.162 - MESSAGE_FINAL_SOLUTION = 1,
1.163 - /// print factorization
1.164 - MESSAGE_FACTORIZATION = 2,
1.165 - /// normal output
1.166 - MESSAGE_NORMAL_OUTPUT = 3,
1.167 - /// verbose output
1.168 - MESSAGE_VERBOSE_OUTPUT = 4
1.169 - };
1.170 - ///Set the verbosity of the messages
1.171 -
1.172 - ///Set the verbosity of the messages
1.173 - ///
1.174 - ///\param m is the level of the messages output by the solver routines.
1.175 - void messageLevel(MessageLevel m);
1.176 -
1.177 - };
1.178 -
1.179 -} //END OF NAMESPACE LEMON
1.180 -
1.181 -#endif //LEMON_LP_CLP_H
1.182 -