lemon/cbc.h
author Peter Kovacs <kpeter@inf.elte.hu>
Thu, 12 Nov 2009 23:30:45 +0100
changeset 809 22bb98ca0101
parent 576 745e182d0139
child 877 141f9c0db4a3
permissions -rw-r--r--
Entirely rework CostScaling (#180)

- Use the new interface similarly to NetworkSimplex.
- Rework the implementation using an efficient internal structure
for handling the residual network. This improvement made the
code much faster.
- Handle GEQ supply type (LEQ is not supported).
- Handle infinite upper bounds.
- Handle negative costs (for arcs of finite upper bound).
- Traits class + named parameter for the LargeCost type used in
internal computations.
- Extend the documentation.
deba@567
     1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
deba@567
     2
 *
deba@567
     3
 * This file is a part of LEMON, a generic C++ optimization library.
deba@567
     4
 *
deba@567
     5
 * Copyright (C) 2003-2009
deba@567
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
deba@567
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
deba@567
     8
 *
deba@567
     9
 * Permission to use, modify and distribute this software is granted
deba@567
    10
 * provided that this copyright notice appears in all copies. For
deba@567
    11
 * precise terms see the accompanying LICENSE file.
deba@567
    12
 *
deba@567
    13
 * This software is provided "AS IS" with no warranty of any kind,
deba@567
    14
 * express or implied, and with no claim as to its suitability for any
deba@567
    15
 * purpose.
deba@567
    16
 *
deba@567
    17
 */
deba@567
    18
deba@567
    19
// -*- C++ -*-
deba@567
    20
#ifndef LEMON_CBC_H
deba@567
    21
#define LEMON_CBC_H
deba@567
    22
deba@567
    23
///\file
deba@567
    24
///\brief Header of the LEMON-CBC mip solver interface.
deba@567
    25
///\ingroup lp_group
deba@567
    26
deba@567
    27
#include <lemon/lp_base.h>
deba@567
    28
deba@567
    29
class CoinModel;
deba@567
    30
class OsiSolverInterface;
deba@567
    31
class CbcModel;
deba@567
    32
deba@567
    33
namespace lemon {
deba@567
    34
deba@567
    35
  /// \brief Interface for the CBC MIP solver
deba@567
    36
  ///
deba@567
    37
  /// This class implements an interface for the CBC MIP solver.
deba@567
    38
  ///\ingroup lp_group
deba@567
    39
  class CbcMip : public MipSolver {
deba@567
    40
  protected:
deba@567
    41
deba@567
    42
    CoinModel *_prob;
deba@567
    43
    OsiSolverInterface *_osi_solver;
deba@567
    44
    CbcModel *_cbc_model;
deba@567
    45
deba@567
    46
  public:
deba@567
    47
deba@567
    48
    /// \e
deba@567
    49
    CbcMip();
deba@567
    50
    /// \e
deba@567
    51
    CbcMip(const CbcMip&);
deba@567
    52
    /// \e
deba@567
    53
    ~CbcMip();
deba@567
    54
    /// \e
deba@567
    55
    virtual CbcMip* newSolver() const;
deba@567
    56
    /// \e
deba@567
    57
    virtual CbcMip* cloneSolver() const;
deba@567
    58
deba@567
    59
  protected:
deba@567
    60
deba@567
    61
    virtual const char* _solverName() const;
deba@567
    62
deba@567
    63
    virtual int _addCol();
deba@567
    64
    virtual int _addRow();
deba@746
    65
    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
deba@567
    66
deba@567
    67
    virtual void _eraseCol(int i);
deba@567
    68
    virtual void _eraseRow(int i);
deba@567
    69
deba@567
    70
    virtual void _eraseColId(int i);
deba@567
    71
    virtual void _eraseRowId(int i);
deba@567
    72
deba@567
    73
    virtual void _getColName(int col, std::string& name) const;
deba@567
    74
    virtual void _setColName(int col, const std::string& name);
deba@567
    75
    virtual int _colByName(const std::string& name) const;
deba@567
    76
deba@567
    77
    virtual void _getRowName(int row, std::string& name) const;
deba@567
    78
    virtual void _setRowName(int row, const std::string& name);
deba@567
    79
    virtual int _rowByName(const std::string& name) const;
deba@567
    80
deba@567
    81
    virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
deba@567
    82
    virtual void _getRowCoeffs(int i, InsertIterator b) const;
deba@567
    83
deba@567
    84
    virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
deba@567
    85
    virtual void _getColCoeffs(int i, InsertIterator b) const;
deba@567
    86
deba@567
    87
    virtual void _setCoeff(int row, int col, Value value);
deba@567
    88
    virtual Value _getCoeff(int row, int col) const;
deba@567
    89
deba@567
    90
    virtual void _setColLowerBound(int i, Value value);
deba@567
    91
    virtual Value _getColLowerBound(int i) const;
deba@567
    92
    virtual void _setColUpperBound(int i, Value value);
deba@567
    93
    virtual Value _getColUpperBound(int i) const;
deba@567
    94
deba@567
    95
    virtual void _setRowLowerBound(int i, Value value);
deba@567
    96
    virtual Value _getRowLowerBound(int i) const;
deba@567
    97
    virtual void _setRowUpperBound(int i, Value value);
deba@567
    98
    virtual Value _getRowUpperBound(int i) const;
deba@567
    99
deba@567
   100
    virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
deba@567
   101
    virtual void _getObjCoeffs(InsertIterator b) const;
deba@567
   102
deba@567
   103
    virtual void _setObjCoeff(int i, Value obj_coef);
deba@567
   104
    virtual Value _getObjCoeff(int i) const;
deba@567
   105
deba@567
   106
    virtual void _setSense(Sense sense);
deba@567
   107
    virtual Sense _getSense() const;
deba@567
   108
deba@567
   109
    virtual ColTypes _getColType(int col) const;
deba@567
   110
    virtual void _setColType(int col, ColTypes col_type);
deba@567
   111
deba@567
   112
    virtual SolveExitStatus _solve();
deba@567
   113
    virtual ProblemType _getType() const;
deba@567
   114
    virtual Value _getSol(int i) const;
deba@567
   115
    virtual Value _getSolValue() const;
deba@567
   116
deba@567
   117
    virtual void _clear();
deba@567
   118
deba@576
   119
    virtual void _messageLevel(MessageLevel level);
deba@576
   120
    void _applyMessageLevel();
deba@567
   121
deba@576
   122
    int _message_level;
deba@567
   123
deba@576
   124
    
deba@567
   125
deba@567
   126
  };
deba@567
   127
deba@567
   128
}
deba@567
   129
deba@567
   130
#endif