src/work/athos/lp/lp_solver_base.h
author alpar
Sun, 17 Apr 2005 18:57:22 +0000
changeset 1364 ee5959aa4410
permissions -rw-r--r--
- compile failure fixed
- newLp(), copyLp() added
- more doc.
athos@1249
     1
// -*- c++ -*-
athos@1249
     2
#ifndef LEMON_LP_SOLVER_BASE_H
athos@1249
     3
#define LEMON_LP_SOLVER_BASE_H
athos@1249
     4
athos@1249
     5
///\ingroup misc
athos@1249
     6
///\file
athos@1249
     7
athos@1249
     8
// #include <stdio.h>
athos@1249
     9
#include <stdlib.h>
athos@1249
    10
#include <iostream>
athos@1249
    11
#include <map>
athos@1249
    12
#include <limits>
athos@1249
    13
// #include <stdio>
athos@1249
    14
//#include <stdlib>
athos@1249
    15
athos@1249
    16
#include <iostream>
athos@1249
    17
#include <vector>
athos@1249
    18
#include <string>
athos@1249
    19
#include <list>
athos@1249
    20
#include <memory>
athos@1249
    21
#include <utility>
athos@1249
    22
athos@1249
    23
//#include <lemon/invalid.h>
athos@1249
    24
//#include <expression.h>
athos@1249
    25
//#include <stp.h>
athos@1249
    26
//#include <lemon/max_flow.h>
athos@1249
    27
//#include <augmenting_flow.h>
athos@1249
    28
//#include <iter_map.h>
athos@1249
    29
athos@1249
    30
using std::cout;
athos@1249
    31
using std::cin;
athos@1249
    32
using std::endl;
athos@1249
    33
athos@1249
    34
namespace lemon {
athos@1249
    35
  
athos@1249
    36
  template <typename _Value>
athos@1249
    37
  class LpSolverBase {
athos@1249
    38
    
athos@1249
    39
    /*! @name Uncategorized functions and types (public members)
athos@1249
    40
    */
athos@1249
    41
    //@{
athos@1249
    42
  public:
athos@1249
    43
athos@1249
    44
    //UNCATEGORIZED
athos@1249
    45
athos@1249
    46
    /// \e
athos@1249
    47
    typedef _Value Value;
athos@1249
    48
    /// \e 
athos@1249
    49
    static const Value INF;
athos@1249
    50
  public:
athos@1249
    51
    /// \e
athos@1249
    52
    LpSolverBase() { }
athos@1249
    53
    /// \e
athos@1249
    54
    virtual ~LpSolverBase() { }
athos@1249
    55
athos@1249
    56
    /*! @name Low level interface (protected members)
athos@1249
    57
      Problem manipulating functions in the low level interface
athos@1249
    58
    */
athos@1249
    59
    //@{
athos@1249
    60
  protected:
athos@1249
    61
athos@1249
    62
    //MATRIX MANIPULATING FUNCTIONS
athos@1249
    63
athos@1249
    64
    /// \e
athos@1249
    65
    virtual int _addCol() = 0;
athos@1249
    66
    /// \e
athos@1249
    67
    virtual int _addRow() = 0;
athos@1249
    68
    /// \e
athos@1249
    69
    virtual void _eraseCol(int i) = 0;
athos@1249
    70
    /// \e
athos@1249
    71
    virtual void _eraseRow(int i) = 0;
athos@1249
    72
    /// \e
athos@1249
    73
    virtual void _setRowCoeffs(int i, 
athos@1249
    74
			       const std::vector<std::pair<int, Value> >& coeffs) = 0;
athos@1249
    75
    /// \e
athos@1249
    76
    /// This routine modifies \c coeffs only by the \c push_back method.
athos@1249
    77
    virtual void _getRowCoeffs(int i, 
athos@1249
    78
			       std::vector<std::pair<int, Value> >& coeffs) = 0;
athos@1249
    79
    /// \e
athos@1249
    80
    virtual void _setColCoeffs(int i, 
athos@1249
    81
			       const std::vector<std::pair<int, Value> >& coeffs) = 0;
athos@1249
    82
    /// \e
athos@1249
    83
    /// This routine modifies \c coeffs only by the \c push_back method.
athos@1249
    84
    virtual void _getColCoeffs(int i, 
athos@1249
    85
			       std::vector<std::pair<int, Value> >& coeffs) = 0;
athos@1249
    86
    /// \e
athos@1249
    87
    virtual void _setCoeff(int col, int row, Value value) = 0;
athos@1249
    88
    /// \e
athos@1249
    89
    virtual Value _getCoeff(int col, int row) = 0;
athos@1249
    90
    //  public:
athos@1249
    91
    //    /// \e
athos@1249
    92
    //    enum Bound { FREE, LOWER, UPPER, DOUBLE, FIXED };
athos@1249
    93
  protected:
athos@1249
    94
    /// \e
athos@1249
    95
    /// The lower bound of a variable (column) have to be given by an 
athos@1249
    96
    /// extended number of type Value, i.e. a finite number of type 
athos@1249
    97
    /// Value or -INF.
athos@1249
    98
    virtual void _setColLowerBound(int i, Value value) = 0;
athos@1249
    99
    /// \e
athos@1249
   100
    /// The lower bound of a variable (column) is an 
athos@1249
   101
    /// extended number of type Value, i.e. a finite number of type 
athos@1249
   102
    /// Value or -INF.
athos@1249
   103
    virtual Value _getColLowerBound(int i) = 0;
athos@1249
   104
    /// \e
athos@1249
   105
    /// The upper bound of a variable (column) have to be given by an 
athos@1249
   106
    /// extended number of type Value, i.e. a finite number of type 
athos@1249
   107
    /// Value or INF.
athos@1249
   108
    virtual void _setColUpperBound(int i, Value value) = 0;
athos@1249
   109
    /// \e
athos@1249
   110
    /// The upper bound of a variable (column) is an 
athos@1249
   111
    /// extended number of type Value, i.e. a finite number of type 
athos@1249
   112
    /// Value or INF.
athos@1249
   113
    virtual Value _getColUpperBound(int i) = 0;
athos@1249
   114
    /// \e
athos@1249
   115
    /// The lower bound of a linear expression (row) have to be given by an 
athos@1249
   116
    /// extended number of type Value, i.e. a finite number of type 
athos@1249
   117
    /// Value or -INF.
athos@1249
   118
    virtual void _setRowLowerBound(int i, Value value) = 0;
athos@1249
   119
    /// \e
athos@1249
   120
    /// The lower bound of a linear expression (row) is an 
athos@1249
   121
    /// extended number of type Value, i.e. a finite number of type 
athos@1249
   122
    /// Value or -INF.
athos@1249
   123
    virtual Value _getRowLowerBound(int i) = 0;
athos@1249
   124
    /// \e
athos@1249
   125
    /// The upper bound of a linear expression (row) have to be given by an 
athos@1249
   126
    /// extended number of type Value, i.e. a finite number of type 
athos@1249
   127
    /// Value or INF.
athos@1249
   128
    virtual void _setRowUpperBound(int i, Value value) = 0;
athos@1249
   129
    /// \e
athos@1249
   130
    /// The upper bound of a linear expression (row) is an 
athos@1249
   131
    /// extended number of type Value, i.e. a finite number of type 
athos@1249
   132
    /// Value or INF.
athos@1249
   133
    virtual Value _getRowUpperBound(int i) = 0;
athos@1249
   134
    /// \e
athos@1249
   135
    virtual void _setObjCoeff(int i, Value obj_coef) = 0;
athos@1249
   136
    /// \e
athos@1249
   137
    virtual Value _getObjCoeff(int i) = 0;
athos@1249
   138
    
athos@1249
   139
    //SOLUTION RETRIEVING
athos@1249
   140
athos@1249
   141
    /// \e
athos@1249
   142
    virtual Value _getPrimal(int i) = 0;
athos@1249
   143
    //@}
athos@1249
   144
    
athos@1249
   145
athos@1249
   146
athos@1249
   147
    /*! @name MIP functions and types (public members)
athos@1249
   148
    */
athos@1249
   149
    //@{
athos@1249
   150
  protected:
athos@1249
   151
   /// \e
athos@1249
   152
    virtual void _setColCont(int i) = 0;
athos@1249
   153
    /// \e
athos@1249
   154
    virtual void _setColInt(int i) = 0;
athos@1249
   155
    /// \e
athos@1249
   156
    virtual Value _getMIPPrimal(int i) = 0;
athos@1249
   157
    //@}
athos@1249
   158
  };
athos@1249
   159
athos@1249
   160
} //namespace lemon
athos@1249
   161
athos@1249
   162
#endif //LEMON_LP_SOLVER_BASE_H