| 
alpar@484
 | 
     1  | 
/* -*- mode: C++; indent-tabs-mode: nil; -*-
  | 
| 
alpar@484
 | 
     2  | 
 *
  | 
| 
alpar@484
 | 
     3  | 
 * This file is a part of LEMON, a generic C++ optimization library.
  | 
| 
alpar@484
 | 
     4  | 
 *
  | 
| 
alpar@484
 | 
     5  | 
 * Copyright (C) 2003-2008
  | 
| 
alpar@484
 | 
     6  | 
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
  | 
| 
alpar@484
 | 
     7  | 
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  | 
| 
alpar@484
 | 
     8  | 
 *
  | 
| 
alpar@484
 | 
     9  | 
 * Permission to use, modify and distribute this software is granted
  | 
| 
alpar@484
 | 
    10  | 
 * provided that this copyright notice appears in all copies. For
  | 
| 
alpar@484
 | 
    11  | 
 * precise terms see the accompanying LICENSE file.
  | 
| 
alpar@484
 | 
    12  | 
 *
  | 
| 
alpar@484
 | 
    13  | 
 * This software is provided "AS IS" with no warranty of any kind,
  | 
| 
alpar@484
 | 
    14  | 
 * express or implied, and with no claim as to its suitability for any
  | 
| 
alpar@484
 | 
    15  | 
 * purpose.
  | 
| 
alpar@484
 | 
    16  | 
 *
  | 
| 
alpar@484
 | 
    17  | 
 */
  | 
| 
alpar@484
 | 
    18  | 
  | 
| 
alpar@484
 | 
    19  | 
#ifndef LEMON_SOPLEX_H
  | 
| 
alpar@484
 | 
    20  | 
#define LEMON_SOPLEX_H
  | 
| 
alpar@484
 | 
    21  | 
  | 
| 
alpar@484
 | 
    22  | 
///\file
  | 
| 
alpar@484
 | 
    23  | 
///\brief Header of the LEMON-SOPLEX lp solver interface.
  | 
| 
alpar@484
 | 
    24  | 
  | 
| 
alpar@484
 | 
    25  | 
#include <vector>
  | 
| 
alpar@484
 | 
    26  | 
#include <string>
  | 
| 
alpar@484
 | 
    27  | 
  | 
| 
alpar@484
 | 
    28  | 
#include <lemon/lp_base.h>
  | 
| 
alpar@484
 | 
    29  | 
  | 
| 
alpar@484
 | 
    30  | 
// Forward declaration
  | 
| 
alpar@484
 | 
    31  | 
namespace soplex {
 | 
| 
alpar@484
 | 
    32  | 
  class SoPlex;
  | 
| 
alpar@484
 | 
    33  | 
}
  | 
| 
alpar@484
 | 
    34  | 
  | 
| 
alpar@484
 | 
    35  | 
namespace lemon {
 | 
| 
alpar@484
 | 
    36  | 
  | 
| 
alpar@484
 | 
    37  | 
  /// \ingroup lp_group
  | 
| 
alpar@484
 | 
    38  | 
  ///
  | 
| 
alpar@484
 | 
    39  | 
  /// \brief Interface for the SOPLEX solver
  | 
| 
alpar@484
 | 
    40  | 
  ///
  | 
| 
alpar@484
 | 
    41  | 
  /// This class implements an interface for the SoPlex LP solver.
  | 
| 
alpar@484
 | 
    42  | 
  /// The SoPlex library is an object oriented lp solver library
  | 
| 
alpar@484
 | 
    43  | 
  /// developed at the Konrad-Zuse-Zentrum für Informationstechnik
  | 
| 
alpar@484
 | 
    44  | 
  /// Berlin (ZIB). You can find detailed information about it at the
  | 
| 
alpar@484
 | 
    45  | 
  /// <tt>http://soplex.zib.de</tt> address.
  | 
| 
alpar@485
 | 
    46  | 
  class SoplexLp : public LpSolver {
 | 
| 
alpar@484
 | 
    47  | 
  private:
  | 
| 
alpar@484
 | 
    48  | 
  | 
| 
alpar@484
 | 
    49  | 
    soplex::SoPlex* soplex;
  | 
| 
alpar@484
 | 
    50  | 
  | 
| 
alpar@484
 | 
    51  | 
    std::vector<std::string> _col_names;
  | 
| 
alpar@484
 | 
    52  | 
    std::map<std::string, int> _col_names_ref;
  | 
| 
alpar@484
 | 
    53  | 
  | 
| 
alpar@484
 | 
    54  | 
    std::vector<std::string> _row_names;
  | 
| 
alpar@484
 | 
    55  | 
    std::map<std::string, int> _row_names_ref;
  | 
| 
alpar@484
 | 
    56  | 
  | 
| 
alpar@484
 | 
    57  | 
  private:
  | 
| 
alpar@484
 | 
    58  | 
  | 
| 
alpar@484
 | 
    59  | 
    // these values cannot be retrieved element by element
  | 
| 
alpar@484
 | 
    60  | 
    mutable std::vector<Value> _primal_values;
  | 
| 
alpar@484
 | 
    61  | 
    mutable std::vector<Value> _dual_values;
  | 
| 
alpar@484
 | 
    62  | 
  | 
| 
alpar@484
 | 
    63  | 
    mutable std::vector<Value> _primal_ray;
  | 
| 
alpar@484
 | 
    64  | 
    mutable std::vector<Value> _dual_ray;
  | 
| 
alpar@484
 | 
    65  | 
  | 
| 
alpar@484
 | 
    66  | 
    void _clear_temporals();
  | 
| 
alpar@484
 | 
    67  | 
  | 
| 
alpar@484
 | 
    68  | 
  public:
  | 
| 
alpar@484
 | 
    69  | 
  | 
| 
alpar@484
 | 
    70  | 
    /// \e
  | 
| 
alpar@485
 | 
    71  | 
    SoplexLp();
  | 
| 
alpar@484
 | 
    72  | 
    /// \e
  | 
| 
alpar@485
 | 
    73  | 
    SoplexLp(const SoplexLp&);
  | 
| 
alpar@484
 | 
    74  | 
    /// \e
  | 
| 
alpar@485
 | 
    75  | 
    ~SoplexLp();
  | 
| 
alpar@587
 | 
    76  | 
    /// \e
  | 
| 
alpar@587
 | 
    77  | 
    virtual SoplexLp* newSolver() const;
  | 
| 
alpar@587
 | 
    78  | 
    /// \e
  | 
| 
alpar@587
 | 
    79  | 
    virtual SoplexLp* cloneSolver() const;
  | 
| 
alpar@484
 | 
    80  | 
  | 
| 
alpar@484
 | 
    81  | 
  protected:
  | 
| 
alpar@484
 | 
    82  | 
  | 
| 
alpar@484
 | 
    83  | 
    virtual const char* _solverName() const;
  | 
| 
alpar@484
 | 
    84  | 
  | 
| 
alpar@484
 | 
    85  | 
    virtual int _addCol();
  | 
| 
alpar@484
 | 
    86  | 
    virtual int _addRow();
  | 
| 
alpar@484
 | 
    87  | 
  | 
| 
alpar@484
 | 
    88  | 
    virtual void _eraseCol(int i);
  | 
| 
alpar@484
 | 
    89  | 
    virtual void _eraseRow(int i);
  | 
| 
alpar@484
 | 
    90  | 
  | 
| 
alpar@484
 | 
    91  | 
    virtual void _eraseColId(int i);
  | 
| 
alpar@484
 | 
    92  | 
    virtual void _eraseRowId(int i);
  | 
| 
alpar@484
 | 
    93  | 
  | 
| 
alpar@484
 | 
    94  | 
    virtual void _getColName(int col, std::string& name) const;
  | 
| 
alpar@484
 | 
    95  | 
    virtual void _setColName(int col, const std::string& name);
  | 
| 
alpar@484
 | 
    96  | 
    virtual int _colByName(const std::string& name) const;
  | 
| 
alpar@484
 | 
    97  | 
  | 
| 
alpar@484
 | 
    98  | 
    virtual void _getRowName(int row, std::string& name) const;
  | 
| 
alpar@484
 | 
    99  | 
    virtual void _setRowName(int row, const std::string& name);
  | 
| 
alpar@484
 | 
   100  | 
    virtual int _rowByName(const std::string& name) const;
  | 
| 
alpar@484
 | 
   101  | 
  | 
| 
alpar@484
 | 
   102  | 
    virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
  | 
| 
alpar@484
 | 
   103  | 
    virtual void _getRowCoeffs(int i, InsertIterator b) const;
  | 
| 
alpar@484
 | 
   104  | 
  | 
| 
alpar@484
 | 
   105  | 
    virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
  | 
| 
alpar@484
 | 
   106  | 
    virtual void _getColCoeffs(int i, InsertIterator b) const;
  | 
| 
alpar@484
 | 
   107  | 
  | 
| 
alpar@484
 | 
   108  | 
    virtual void _setCoeff(int row, int col, Value value);
  | 
| 
alpar@484
 | 
   109  | 
    virtual Value _getCoeff(int row, int col) const;
  | 
| 
alpar@484
 | 
   110  | 
  | 
| 
alpar@484
 | 
   111  | 
    virtual void _setColLowerBound(int i, Value value);
  | 
| 
alpar@484
 | 
   112  | 
    virtual Value _getColLowerBound(int i) const;
  | 
| 
alpar@484
 | 
   113  | 
    virtual void _setColUpperBound(int i, Value value);
  | 
| 
alpar@484
 | 
   114  | 
    virtual Value _getColUpperBound(int i) const;
  | 
| 
alpar@484
 | 
   115  | 
  | 
| 
alpar@484
 | 
   116  | 
    virtual void _setRowLowerBound(int i, Value value);
  | 
| 
alpar@484
 | 
   117  | 
    virtual Value _getRowLowerBound(int i) const;
  | 
| 
alpar@484
 | 
   118  | 
    virtual void _setRowUpperBound(int i, Value value);
  | 
| 
alpar@484
 | 
   119  | 
    virtual Value _getRowUpperBound(int i) const;
  | 
| 
alpar@484
 | 
   120  | 
  | 
| 
alpar@484
 | 
   121  | 
    virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
  | 
| 
alpar@484
 | 
   122  | 
    virtual void _getObjCoeffs(InsertIterator b) const;
  | 
| 
alpar@484
 | 
   123  | 
  | 
| 
alpar@484
 | 
   124  | 
    virtual void _setObjCoeff(int i, Value obj_coef);
  | 
| 
alpar@484
 | 
   125  | 
    virtual Value _getObjCoeff(int i) const;
  | 
| 
alpar@484
 | 
   126  | 
  | 
| 
alpar@484
 | 
   127  | 
    virtual void _setSense(Sense sense);
  | 
| 
alpar@484
 | 
   128  | 
    virtual Sense _getSense() const;
  | 
| 
alpar@484
 | 
   129  | 
  | 
| 
alpar@484
 | 
   130  | 
    virtual SolveExitStatus _solve();
  | 
| 
alpar@484
 | 
   131  | 
    virtual Value _getPrimal(int i) const;
  | 
| 
alpar@484
 | 
   132  | 
    virtual Value _getDual(int i) const;
  | 
| 
alpar@484
 | 
   133  | 
  | 
| 
alpar@484
 | 
   134  | 
    virtual Value _getPrimalValue() const;
  | 
| 
alpar@484
 | 
   135  | 
  | 
| 
alpar@484
 | 
   136  | 
    virtual Value _getPrimalRay(int i) const;
  | 
| 
alpar@484
 | 
   137  | 
    virtual Value _getDualRay(int i) const;
  | 
| 
alpar@484
 | 
   138  | 
  | 
| 
alpar@484
 | 
   139  | 
    virtual VarStatus _getColStatus(int i) const;
  | 
| 
alpar@484
 | 
   140  | 
    virtual VarStatus _getRowStatus(int i) const;
  | 
| 
alpar@484
 | 
   141  | 
  | 
| 
alpar@484
 | 
   142  | 
    virtual ProblemType _getPrimalType() const;
  | 
| 
alpar@484
 | 
   143  | 
    virtual ProblemType _getDualType() const;
  | 
| 
alpar@484
 | 
   144  | 
  | 
| 
alpar@484
 | 
   145  | 
    virtual void _clear();
  | 
| 
alpar@484
 | 
   146  | 
  | 
| 
alpar@484
 | 
   147  | 
  };
  | 
| 
alpar@484
 | 
   148  | 
  | 
| 
alpar@484
 | 
   149  | 
} //END OF NAMESPACE LEMON
  | 
| 
alpar@484
 | 
   150  | 
  | 
| 
alpar@484
 | 
   151  | 
#endif //LEMON_SOPLEX_H
  | 
| 
alpar@484
 | 
   152  | 
  |