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