lemon/lp_glpk.h
author deba
Sun, 30 Sep 2007 19:19:33 +0000
changeset 2481 ddb851e1481a
parent 2391 14a343be7a5a
child 2553 bfced05fa852
permissions -rw-r--r--
Avoiding warnings
athos@1261
     1
/* -*- C++ -*-
athos@1261
     2
 *
alpar@1956
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@1956
     4
 *
alpar@2391
     5
 * Copyright (C) 2003-2007
alpar@1956
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@1359
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
athos@1261
     8
 *
athos@1261
     9
 * Permission to use, modify and distribute this software is granted
athos@1261
    10
 * provided that this copyright notice appears in all copies. For
athos@1261
    11
 * precise terms see the accompanying LICENSE file.
athos@1261
    12
 *
athos@1261
    13
 * This software is provided "AS IS" with no warranty of any kind,
athos@1261
    14
 * express or implied, and with no claim as to its suitability for any
athos@1261
    15
 * purpose.
athos@1261
    16
 *
athos@1261
    17
 */
athos@1261
    18
athos@1261
    19
#ifndef LEMON_LP_GLPK_H
athos@1261
    20
#define LEMON_LP_GLPK_H
athos@1261
    21
athos@1261
    22
///\file
athos@1261
    23
///\brief Header of the LEMON-GLPK lp solver interface.
deba@2370
    24
///\ingroup lp_group
athos@1261
    25
ladanyi@1356
    26
#include <lemon/lp_base.h>
athos@1261
    27
extern "C" {
alpar@1326
    28
#include <glpk.h>
athos@1261
    29
}
athos@1261
    30
athos@1261
    31
namespace lemon {
athos@1261
    32
athos@1261
    33
alpar@1398
    34
  /// \brief Interface for the GLPK LP solver
athos@1261
    35
  /// 
alpar@1398
    36
  /// This class implements an interface for the GLPK LP solver.
deba@2370
    37
  ///\ingroup lp_group
athos@2144
    38
  class LpGlpk : virtual public LpSolverBase {
alpar@1321
    39
  protected:
alpar@1321
    40
    LPX* lp;
deba@2441
    41
    bool solved;
alpar@1321
    42
    
athos@1261
    43
  public:
alpar@1321
    44
    
athos@1261
    45
    typedef LpSolverBase Parent;
athos@1261
    46
    
alpar@1321
    47
    LpGlpk();
alpar@2321
    48
    LpGlpk(const LpGlpk &);
alpar@1321
    49
    ~LpGlpk();
alpar@1321
    50
    
athos@1261
    51
  protected:
alpar@1364
    52
    virtual LpSolverBase &_newLp();
alpar@1364
    53
    virtual LpSolverBase &_copyLp();
alpar@1364
    54
athos@1261
    55
    virtual int _addCol();
athos@1261
    56
    virtual int _addRow();
athos@1432
    57
    virtual void _eraseCol(int i);
athos@1432
    58
    virtual void _eraseRow(int i);
deba@2366
    59
    virtual void _getColName(int col, std::string & name) const;
alpar@1895
    60
    virtual void _setColName(int col, const std::string & name);
deba@2366
    61
    virtual int _colByName(const std::string& name) const;
deba@2364
    62
    virtual void _setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e);
deba@2366
    63
    virtual void _getRowCoeffs(int i, RowIterator b) const;
deba@2364
    64
    virtual void _setColCoeffs(int i, ConstColIterator b, ConstColIterator e);
deba@2366
    65
    virtual void _getColCoeffs(int i, ColIterator b) const;
athos@1431
    66
    virtual void _setCoeff(int row, int col, Value value);
deba@2366
    67
    virtual Value _getCoeff(int row, int col) const;
athos@2324
    68
athos@1261
    69
    virtual void _setColLowerBound(int i, Value value);
deba@2366
    70
    virtual Value _getColLowerBound(int i) const;
athos@1261
    71
    virtual void _setColUpperBound(int i, Value value);
deba@2366
    72
    virtual Value _getColUpperBound(int i) const;
athos@2328
    73
athos@1379
    74
    virtual void _setRowBounds(int i, Value lower, Value upper);
deba@2366
    75
    virtual void _getRowBounds(int i, Value &lb, Value &ub) const;
athos@1261
    76
    virtual void _setObjCoeff(int i, Value obj_coef);
deba@2366
    77
    virtual Value _getObjCoeff(int i) const;
athos@1377
    78
    virtual void _clearObj();
athos@1376
    79
alpar@1263
    80
    ///\e
alpar@1263
    81
    
alpar@1321
    82
    ///\todo It should be clarified
alpar@1263
    83
    ///
alpar@1303
    84
    virtual SolveExitStatus _solve();
deba@2366
    85
    virtual Value _getPrimal(int i) const;
deba@2366
    86
    virtual Value _getDual(int i) const;
deba@2366
    87
    virtual Value _getPrimalValue() const;
deba@2366
    88
    virtual bool _isBasicCol(int i) const;
alpar@1312
    89
    ///\e
alpar@1312
    90
    
alpar@1321
    91
    ///\todo It should be clarified
alpar@1312
    92
    ///
deba@2366
    93
    virtual SolutionStatus _getPrimalStatus() const;
deba@2366
    94
    virtual SolutionStatus _getDualStatus() const;
deba@2366
    95
    virtual ProblemTypes _getProblemType() const;
athos@1460
    96
alpar@1321
    97
    virtual void _setMax();
alpar@1321
    98
    virtual void _setMin();
athos@1261
    99
deba@2366
   100
    virtual bool _isMax() const;
athos@2324
   101
alpar@1321
   102
  public:
alpar@1321
   103
    ///Set the verbosity of the messages
alpar@1321
   104
alpar@1326
   105
    ///Set the verbosity of the messages
alpar@1326
   106
    ///
alpar@1321
   107
    ///\param m is the level of the messages output by the solver routines.
alpar@1321
   108
    ///The possible values are:
alpar@1321
   109
    ///- 0 --- no output (default value)
alpar@1321
   110
    ///- 1 --- error messages only
alpar@1321
   111
    ///- 2 --- normal output
alpar@1321
   112
    ///- 3 --- full output (includes informational messages)
alpar@1321
   113
    void messageLevel(int m);
alpar@1326
   114
    ///Turns on or off the presolver
alpar@1326
   115
alpar@1326
   116
    ///Turns on (\c b is \c true) or off (\c b is \c false) the presolver
alpar@1326
   117
    ///
alpar@1326
   118
    ///The presolver is off by default.
alpar@1326
   119
    void presolver(bool b);
alpar@2321
   120
alpar@2321
   121
    LPX *lpx() {return lp;}
athos@1261
   122
  };
athos@1261
   123
} //END OF NAMESPACE LEMON
athos@1261
   124
athos@1261
   125
#endif //LEMON_LP_GLPK_H
athos@1261
   126