COIN-OR::LEMON - Graph Library

Changeset 459:ed54c0d13df0 in lemon-1.2 for lemon/lp_skeleton.h


Ignore:
Timestamp:
12/02/08 22:48:28 (11 years ago)
Author:
Balazs Dezso <deba@…>
Branch:
default
Children:
460:76ec7bd57026, 502:17cabb114d52
Phase:
public
Message:

Thorough redesign of the LP/MIP interface (#44)

  • Redesigned class structure
  • Redesigned iterators
  • Some functions in the basic interface redesigned
  • More complete setting functions
  • Ray retrieving functions
  • Lot of improvements
  • Cplex common env
  • CLP macro definition to config.h.in
  • Update lp.h to also use soplex and clp
  • Remove default_solver_name
  • New solverName() function in solvers
  • Handle exceptions for MipCplex? test
  • Rename tolerance parameter to epsilon
  • Rename MapIt? to CoeffIt?
  • Lot of documentation improvements
  • Various bugfixes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/lp_skeleton.h

    r458 r459  
    2727
    2828  ///A skeleton class to implement LP solver interfaces
    29   class LpSkeleton :public LpSolverBase {
     29  class SkeletonSolverBase : public virtual LpBase {
    3030    int col_num,row_num;
    3131
    3232  protected:
    3333
    34     ///\e
    35     virtual LpSolverBase* _newLp();
    36     ///\e
    37     virtual LpSolverBase* _copyLp();
     34    SkeletonSolverBase()
     35      : col_num(-1), row_num(-1) {}
     36
    3837    /// \e
    3938    virtual int _addCol();
     
    4443    /// \e
    4544    virtual void _eraseRow(int i);
    46     /// \e
    47     virtual void _getColName(int col, std::string & name) const;
    48     /// \e
    49     virtual void _setColName(int col, const std::string & name);
     45
     46    /// \e
     47    virtual void _getColName(int col, std::string& name) const;
     48    /// \e
     49    virtual void _setColName(int col, const std::string& name);
    5050    /// \e
    5151    virtual int _colByName(const std::string& name) const;
    5252
    5353    /// \e
    54     virtual void _setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e);
    55     /// \e
    56     virtual void _getRowCoeffs(int i, RowIterator b) const;
    57     /// \e
    58     virtual void _setColCoeffs(int i, ConstColIterator b, ConstColIterator e);
    59     /// \e
    60     virtual void _getColCoeffs(int i, ColIterator b) const;
     54    virtual void _getRowName(int row, std::string& name) const;
     55    /// \e
     56    virtual void _setRowName(int row, const std::string& name);
     57    /// \e
     58    virtual int _rowByName(const std::string& name) const;
     59
     60    /// \e
     61    virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
     62    /// \e
     63    virtual void _getRowCoeffs(int i, InsertIterator b) const;
     64    /// \e
     65    virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
     66    /// \e
     67    virtual void _getColCoeffs(int i, InsertIterator b) const;
    6168
    6269    /// Set one element of the coefficient matrix
     
    8895    virtual Value _getColUpperBound(int i) const;
    8996
    90 //     /// The lower bound of a linear expression (row) have to be given by an
    91 //     /// extended number of type Value, i.e. a finite number of type
    92 //     /// Value or -\ref INF.
    93 //     virtual void _setRowLowerBound(int i, Value value);
    94 //     /// \e
    95 
    96 //     /// The upper bound of a linear expression (row) have to be given by an
    97 //     /// extended number of type Value, i.e. a finite number of type
    98 //     /// Value or \ref INF.
    99 //     virtual void _setRowUpperBound(int i, Value value);
    100 
    101     /// The lower and upper bound of a linear expression (row) have to be
    102     /// given by an
    103     /// extended number of type Value, i.e. a finite number of type
    104     /// Value or +/-\ref INF.
    105     virtual void _setRowBounds(int i, Value lb, Value ub);
    106     /// \e
    107 
    108 
    109     /// The lower and the upper bound of
    110     /// a constraint (row) are
    111     /// extended numbers of type Value, i.e.  finite numbers of type
    112     /// Value, -\ref INF or \ref INF.
    113     virtual void _getRowBounds(int i, Value &lb, Value &ub) const;
    114     /// \e
    115 
    116 
    117     /// \e
    118     virtual void _clearObj();
     97    /// The lower bound of a constraint (row) have to be given by an
     98    /// extended number of type Value, i.e. a finite number of type
     99    /// Value or -\ref INF.
     100    virtual void _setRowLowerBound(int i, Value value);
     101    /// \e
     102
     103    /// The lower bound of a constraint (row) is an
     104    /// extended number of type Value, i.e. a finite number of type
     105    /// Value or -\ref INF.
     106    virtual Value _getRowLowerBound(int i) const;
     107
     108    /// The upper bound of a constraint (row) have to be given by an
     109    /// extended number of type Value, i.e. a finite number of type
     110    /// Value or \ref INF.
     111    virtual void _setRowUpperBound(int i, Value value);
     112    /// \e
     113
     114    /// The upper bound of a constraint (row) is an
     115    /// extended number of type Value, i.e. a finite number of type
     116    /// Value or \ref INF.
     117    virtual Value _getRowUpperBound(int i) const;
     118
     119    /// \e
     120    virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
     121    /// \e
     122    virtual void _getObjCoeffs(InsertIterator b) const;
     123
    119124    /// \e
    120125    virtual void _setObjCoeff(int i, Value obj_coef);
    121 
    122126    /// \e
    123127    virtual Value _getObjCoeff(int i) const;
    124128
    125129    ///\e
    126 
    127     ///\bug Wrong interface
    128     ///
     130    virtual void _setSense(Sense);
     131    ///\e
     132    virtual Sense _getSense() const;
     133
     134    ///\e
     135    virtual void _clear();
     136
     137  };
     138
     139  /// \brief Interface for a skeleton LP solver
     140  ///
     141  /// This class implements an interface for a skeleton LP solver.
     142  ///\ingroup lp_group
     143  class LpSkeleton : public SkeletonSolverBase, public LpSolver {
     144  public:
     145    LpSkeleton() : SkeletonSolverBase(), LpSolver() {}
     146
     147  protected:
     148
     149    ///\e
    129150    virtual SolveExitStatus _solve();
    130151
    131152    ///\e
    132 
    133     ///\bug Wrong interface
    134     ///
    135153    virtual Value _getPrimal(int i) const;
    136 
    137     ///\e
    138 
    139     ///\bug Wrong interface
    140     ///
     154    ///\e
    141155    virtual Value _getDual(int i) const;
    142156
    143157    ///\e
    144 
    145     ///\bug Wrong interface
    146     ///
    147158    virtual Value _getPrimalValue() const;
    148159
    149160    ///\e
    150 
    151     ///\bug Wrong interface
    152     ///
    153     virtual SolutionStatus _getPrimalStatus() const;
    154 
    155     ////e
    156     virtual SolutionStatus _getDualStatus() const;
    157 
    158 
    159     ///\e
    160     virtual ProblemTypes _getProblemType() const;
    161 
    162     ///\e
    163     virtual void _setMax();
    164     ///\e
    165     virtual void _setMin();
    166 
    167     ///\e
    168     virtual bool _isMax() const;
    169 
    170 
    171 
    172     ///\e
    173     virtual bool _isBasicCol(int i) const;
    174 
    175 
    176 
     161    virtual Value _getPrimalRay(int i) const;
     162    ///\e
     163    virtual Value _getDualRay(int i) const;
     164
     165    ///\e
     166    virtual ProblemType _getPrimalType() const;
     167    ///\e
     168    virtual ProblemType _getDualType() const;
     169
     170    ///\e
     171    virtual VarStatus _getColStatus(int i) const;
     172    ///\e
     173    virtual VarStatus _getRowStatus(int i) const;
     174
     175    ///\e
     176    virtual LpSkeleton* _newSolver() const;
     177    ///\e
     178    virtual LpSkeleton* _cloneSolver() const;
     179    ///\e
     180    virtual const char* _solverName() const;
     181
     182  };
     183
     184  /// \brief Interface for a skeleton MIP solver
     185  ///
     186  /// This class implements an interface for a skeleton MIP solver.
     187  ///\ingroup lp_group
     188  class MipSkeleton : public SkeletonSolverBase, public MipSolver {
    177189  public:
    178     LpSkeleton() : LpSolverBase(), col_num(0), row_num(0) {}
     190    MipSkeleton() : SkeletonSolverBase(), MipSolver() {}
     191
     192  protected:
     193    ///\e
     194
     195    ///\bug Wrong interface
     196    ///
     197    virtual SolveExitStatus _solve();
     198
     199    ///\e
     200
     201    ///\bug Wrong interface
     202    ///
     203    virtual Value _getSol(int i) const;
     204
     205    ///\e
     206
     207    ///\bug Wrong interface
     208    ///
     209    virtual Value _getSolValue() const;
     210
     211    ///\e
     212
     213    ///\bug Wrong interface
     214    ///
     215    virtual ProblemType _getType() const;
     216
     217    ///\e
     218    virtual MipSkeleton* _newSolver() const;
     219
     220    ///\e
     221    virtual MipSkeleton* _cloneSolver() const;
     222    ///\e
     223    virtual const char* _solverName() const;
     224
    179225  };
    180226
Note: See TracChangeset for help on using the changeset viewer.