lemon/lp_skeleton.h
author Peter Kovacs <kpeter@inf.elte.hu>
Sat, 10 Oct 2009 08:18:46 +0200
changeset 755 134852d7fb0a
parent 576 745e182d0139
child 877 141f9c0db4a3
permissions -rw-r--r--
Insert citations into the doc (#184)

- Add general citations to modules.
- Add specific citations for max flow and min cost flow algorithms.
- Add citations for the supported LP and MIP solvers.
- Extend the main page.
- Replace inproceedings entries with the journal versions.
- Add a new bibtex entry about network simplex.
- Remove unwanted entries.
deba@458
     1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
deba@458
     2
 *
deba@458
     3
 * This file is a part of LEMON, a generic C++ optimization library.
deba@458
     4
 *
deba@458
     5
 * Copyright (C) 2003-2008
deba@458
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
deba@458
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
deba@458
     8
 *
deba@458
     9
 * Permission to use, modify and distribute this software is granted
deba@458
    10
 * provided that this copyright notice appears in all copies. For
deba@458
    11
 * precise terms see the accompanying LICENSE file.
deba@458
    12
 *
deba@458
    13
 * This software is provided "AS IS" with no warranty of any kind,
deba@458
    14
 * express or implied, and with no claim as to its suitability for any
deba@458
    15
 * purpose.
deba@458
    16
 *
deba@458
    17
 */
deba@458
    18
deba@529
    19
#ifndef LEMON_LP_SKELETON_H
deba@529
    20
#define LEMON_LP_SKELETON_H
deba@458
    21
deba@458
    22
#include <lemon/lp_base.h>
deba@458
    23
deba@458
    24
///\file
alpar@540
    25
///\brief Skeleton file to implement LP/MIP solver interfaces
alpar@540
    26
///  
alpar@540
    27
///The classes in this file do nothing, but they can serve as skeletons when
alpar@540
    28
///implementing an interface to new solvers.
deba@458
    29
namespace lemon {
deba@458
    30
alpar@540
    31
  ///A skeleton class to implement LP/MIP solver base interface
alpar@540
    32
  
alpar@540
    33
  ///This class does nothing, but it can serve as a skeleton when
alpar@540
    34
  ///implementing an interface to new solvers.
deba@459
    35
  class SkeletonSolverBase : public virtual LpBase {
deba@458
    36
    int col_num,row_num;
deba@458
    37
deba@458
    38
  protected:
deba@458
    39
deba@459
    40
    SkeletonSolverBase()
deba@459
    41
      : col_num(-1), row_num(-1) {}
deba@459
    42
deba@458
    43
    /// \e
deba@458
    44
    virtual int _addCol();
deba@458
    45
    /// \e
deba@458
    46
    virtual int _addRow();
deba@458
    47
    /// \e
deba@746
    48
    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
deba@746
    49
    /// \e
deba@458
    50
    virtual void _eraseCol(int i);
deba@458
    51
    /// \e
deba@458
    52
    virtual void _eraseRow(int i);
deba@459
    53
deba@458
    54
    /// \e
deba@459
    55
    virtual void _getColName(int col, std::string& name) const;
deba@458
    56
    /// \e
deba@459
    57
    virtual void _setColName(int col, const std::string& name);
deba@458
    58
    /// \e
deba@458
    59
    virtual int _colByName(const std::string& name) const;
deba@458
    60
deba@458
    61
    /// \e
deba@459
    62
    virtual void _getRowName(int row, std::string& name) const;
deba@458
    63
    /// \e
deba@459
    64
    virtual void _setRowName(int row, const std::string& name);
deba@458
    65
    /// \e
deba@459
    66
    virtual int _rowByName(const std::string& name) const;
deba@459
    67
deba@458
    68
    /// \e
deba@459
    69
    virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
deba@459
    70
    /// \e
deba@459
    71
    virtual void _getRowCoeffs(int i, InsertIterator b) const;
deba@459
    72
    /// \e
deba@459
    73
    virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
deba@459
    74
    /// \e
deba@459
    75
    virtual void _getColCoeffs(int i, InsertIterator b) const;
deba@458
    76
deba@458
    77
    /// Set one element of the coefficient matrix
deba@458
    78
    virtual void _setCoeff(int row, int col, Value value);
deba@458
    79
deba@458
    80
    /// Get one element of the coefficient matrix
deba@458
    81
    virtual Value _getCoeff(int row, int col) const;
deba@458
    82
deba@458
    83
    /// The lower bound of a variable (column) have to be given by an
deba@458
    84
    /// extended number of type Value, i.e. a finite number of type
deba@458
    85
    /// Value or -\ref INF.
deba@458
    86
    virtual void _setColLowerBound(int i, Value value);
deba@458
    87
    /// \e
deba@458
    88
deba@458
    89
    /// The lower bound of a variable (column) is an
deba@458
    90
    /// extended number of type Value, i.e. a finite number of type
deba@458
    91
    /// Value or -\ref INF.
deba@458
    92
    virtual Value _getColLowerBound(int i) const;
deba@458
    93
deba@458
    94
    /// The upper bound of a variable (column) have to be given by an
deba@458
    95
    /// extended number of type Value, i.e. a finite number of type
deba@458
    96
    /// Value or \ref INF.
deba@458
    97
    virtual void _setColUpperBound(int i, Value value);
deba@458
    98
    /// \e
deba@458
    99
deba@458
   100
    /// The upper bound of a variable (column) is an
deba@458
   101
    /// extended number of type Value, i.e. a finite number of type
deba@458
   102
    /// Value or \ref INF.
deba@458
   103
    virtual Value _getColUpperBound(int i) const;
deba@458
   104
deba@459
   105
    /// The lower bound of a constraint (row) have to be given by an
deba@458
   106
    /// extended number of type Value, i.e. a finite number of type
deba@459
   107
    /// Value or -\ref INF.
deba@459
   108
    virtual void _setRowLowerBound(int i, Value value);
deba@458
   109
    /// \e
deba@458
   110
deba@459
   111
    /// The lower bound of a constraint (row) is an
deba@459
   112
    /// extended number of type Value, i.e. a finite number of type
deba@459
   113
    /// Value or -\ref INF.
deba@459
   114
    virtual Value _getRowLowerBound(int i) const;
deba@458
   115
deba@459
   116
    /// The upper bound of a constraint (row) have to be given by an
deba@459
   117
    /// extended number of type Value, i.e. a finite number of type
deba@459
   118
    /// Value or \ref INF.
deba@459
   119
    virtual void _setRowUpperBound(int i, Value value);
deba@458
   120
    /// \e
deba@458
   121
deba@459
   122
    /// The upper bound of a constraint (row) is an
deba@459
   123
    /// extended number of type Value, i.e. a finite number of type
deba@459
   124
    /// Value or \ref INF.
deba@459
   125
    virtual Value _getRowUpperBound(int i) const;
deba@458
   126
deba@458
   127
    /// \e
deba@459
   128
    virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
deba@459
   129
    /// \e
deba@459
   130
    virtual void _getObjCoeffs(InsertIterator b) const;
deba@459
   131
deba@458
   132
    /// \e
deba@458
   133
    virtual void _setObjCoeff(int i, Value obj_coef);
deba@458
   134
    /// \e
deba@458
   135
    virtual Value _getObjCoeff(int i) const;
deba@458
   136
deba@458
   137
    ///\e
deba@459
   138
    virtual void _setSense(Sense);
deba@459
   139
    ///\e
deba@459
   140
    virtual Sense _getSense() const;
deba@459
   141
deba@459
   142
    ///\e
deba@459
   143
    virtual void _clear();
deba@459
   144
deba@576
   145
    ///\e
deba@576
   146
    virtual void _messageLevel(MessageLevel);
deba@459
   147
  };
deba@459
   148
alpar@540
   149
  /// \brief Skeleton class for an LP solver interface
deba@459
   150
  ///
alpar@540
   151
  ///This class does nothing, but it can serve as a skeleton when
alpar@540
   152
  ///implementing an interface to new solvers.
alpar@540
   153
deba@459
   154
  ///\ingroup lp_group
alpar@540
   155
  class LpSkeleton : public LpSolver, public SkeletonSolverBase {
deba@459
   156
  public:
alpar@540
   157
    ///\e
alpar@540
   158
    LpSkeleton() : LpSolver(), SkeletonSolverBase() {}
alpar@540
   159
    ///\e
alpar@540
   160
    virtual LpSkeleton* newSolver() const;
alpar@540
   161
    ///\e
alpar@540
   162
    virtual LpSkeleton* cloneSolver() const;
deba@459
   163
  protected:
deba@459
   164
deba@459
   165
    ///\e
deba@459
   166
    virtual SolveExitStatus _solve();
deba@459
   167
deba@459
   168
    ///\e
deba@459
   169
    virtual Value _getPrimal(int i) const;
deba@459
   170
    ///\e
deba@459
   171
    virtual Value _getDual(int i) const;
deba@459
   172
deba@459
   173
    ///\e
deba@459
   174
    virtual Value _getPrimalValue() const;
deba@459
   175
deba@459
   176
    ///\e
deba@459
   177
    virtual Value _getPrimalRay(int i) const;
deba@459
   178
    ///\e
deba@459
   179
    virtual Value _getDualRay(int i) const;
deba@459
   180
deba@459
   181
    ///\e
deba@459
   182
    virtual ProblemType _getPrimalType() const;
deba@459
   183
    ///\e
deba@459
   184
    virtual ProblemType _getDualType() const;
deba@459
   185
deba@459
   186
    ///\e
deba@459
   187
    virtual VarStatus _getColStatus(int i) const;
deba@459
   188
    ///\e
deba@459
   189
    virtual VarStatus _getRowStatus(int i) const;
deba@459
   190
deba@459
   191
    ///\e
deba@459
   192
    virtual const char* _solverName() const;
deba@459
   193
deba@459
   194
  };
deba@459
   195
alpar@540
   196
  /// \brief Skeleton class for a MIP solver interface
deba@459
   197
  ///
alpar@540
   198
  ///This class does nothing, but it can serve as a skeleton when
alpar@540
   199
  ///implementing an interface to new solvers.
deba@459
   200
  ///\ingroup lp_group
alpar@540
   201
  class MipSkeleton : public MipSolver, public SkeletonSolverBase {
deba@459
   202
  public:
alpar@540
   203
    ///\e
alpar@540
   204
    MipSkeleton() : MipSolver(), SkeletonSolverBase() {}
alpar@540
   205
    ///\e
alpar@540
   206
    virtual MipSkeleton* newSolver() const;
alpar@540
   207
    ///\e
alpar@540
   208
    virtual MipSkeleton* cloneSolver() const;
deba@459
   209
deba@459
   210
  protected:
deba@459
   211
    ///\e
deba@458
   212
    virtual SolveExitStatus _solve();
deba@458
   213
deba@458
   214
    ///\e
deba@459
   215
    virtual Value _getSol(int i) const;
deba@458
   216
deba@458
   217
    ///\e
deba@459
   218
    virtual Value _getSolValue() const;
deba@458
   219
deba@458
   220
    ///\e
deba@459
   221
    virtual ProblemType _getType() const;
deba@458
   222
deba@458
   223
    ///\e
deba@459
   224
    virtual const char* _solverName() const;
deba@458
   225
  };
deba@458
   226
deba@458
   227
} //namespace lemon
deba@458
   228
deba@529
   229
#endif