COIN-OR::LEMON - Graph Library

Changeset 1263:a490938ad0aa in lemon-0.x for src/work/athos


Ignore:
Timestamp:
03/25/05 17:19:03 (19 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1690
Message:
  • LpGlpk? added to the makefile
  • missing const_cast<>() added
  • prop for two new functions (solve() and solution())
Location:
src/work/athos/lp
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/work/athos/lp/Makefile

    r1256 r1263  
    99lp_solver_skeleton.o: lp_solver_skeleton.cc lp_solver_skeleton.h lp_base.h \
    1010                lin_expr.h
     11lp_glpk.o: lp_glpk.cc lp_glpk.h lp_base.h \
     12                lin_expr.h
    1113lp_test.o: lp_test.cc lp_base.h lin_expr.h lp_solver_skeleton.h lp_base.h \
    1214                lin_expr.h
    1315
    14 lp_test: lp_test.o lp_base.o lp_solver_skeleton.o
    15         g++ -o $@ $^
     16lp_test: lp_test.o lp_base.o lp_solver_skeleton.o lp_glpk.o
     17        g++ -o $@ $^ -lglpk
  • src/work/athos/lp/lp_base.h

    r1259 r1263  
    101101  public:
    102102
     103    ///\e
     104    enum SolutionType {
     105      ///\e
     106      INFEASIBLE = 0,
     107      ///\e
     108      UNBOUNDED = 1,
     109      ///\e
     110      OPTIMAL = 2,
     111      ///\e
     112      FEASIBLE = 3,
     113    };
     114     
    103115    ///The floating point type used by the solver
    104116    typedef double Value;
     
    161173    _FixId cols;
    162174
    163     //MATRIX MANIPULATING FUNCTIONS
    164 
    165175    /// \e
    166176    virtual int _addCol() = 0;
     
    213223
    214224    ///\e
     225   
     226    ///\bug Wrong interface
     227    ///
     228    virtual SolutionType _solve() = 0;
     229
     230    ///\e
     231
     232    ///\bug Wrong interface
     233    ///
     234    virtual Value _getSolution(int i) = 0;
     235    ///\e
    215236
    216237    ///\bug unimplemented!!!!
     
    222243    virtual ~LpSolverBase() {}
    223244
     245    ///\name Building up and modification of the LP
     246
     247    ///@{
     248
    224249    ///Add a new empty column (i.e a new variable) to the LP
    225250    Col addCol() { Col c; c.id=cols.insert(_addCol()); return c;}
     251
    226252    ///\brief Fill the elements of a container with newly created columns
    227253    ///(i.e a new variables)
     
    262288    }
    263289#endif
     290
    264291    ///Add a new empty row (i.e a new constaint) to the LP
    265292
     
    349376        setObjCoeff((*i).first,(*i).second);
    350377    }
     378
     379    ///@}
     380
     381
     382    ///\name Solving the LP
     383
     384    ///@{
     385
     386    ///\e
     387    SolutionType solve() { return _solve(); }
     388   
     389    ///@}
     390   
     391    ///\name Obtaining the solution LP
     392
     393    ///@{
     394
     395    ///\e
     396    Value solution(Col c) { return _getSolution(cols.floatingId(c.id)); }
     397
     398    ///@}
    351399   
    352400  }; 
  • src/work/athos/lp/lp_glpk.cc

    r1261 r1263  
    4242    void LpGlpk::_setRowCoeffs(int i,
    4343                               int length,
    44                                int   * indices,
    45                                Value   * values )
    46     {
    47         lpx_set_mat_row(lp, i, length, indices, values);
     44                               const int   * indices,
     45                               const Value   * values )
     46    {
     47      lpx_set_mat_row(lp, i, length,
     48                      const_cast<int * >(indices) ,
     49                      const_cast<Value * >(values));
    4850    }
    4951 
    5052    void LpGlpk::_setColCoeffs(int i,
    5153                               int length,
    52                                int   * indices,
    53                                Value   * values)
    54     {
    55         lpx_set_mat_col(lp, i, length, indices, values);
     54                               const int   * indices,
     55                               const Value   * values)
     56    {
     57      lpx_set_mat_col(lp, i, length,
     58                      const_cast<int * >(indices),
     59                      const_cast<Value * >(values));
    5660    }
    5761 
     
    234238    }
    235239
     240
     241  LpGlpk::SolutionType LpGlpk::_solve()
     242  {
     243    return OPTIMAL;
     244  }
     245
     246  LpGlpk::Value LpGlpk::_getSolution(int i)
     247  {
     248    return 0;
     249  }
     250 
     251
     252
    236253} //END OF NAMESPACE LEMON
    237254
  • src/work/athos/lp/lp_glpk.h

    r1261 r1263  
    5656    virtual void _setRowCoeffs(int i,
    5757                               int length,
    58                                int   * indices,
    59                                Value   * values );
     58                               const int   * indices,
     59                               const Value   * values );
    6060    virtual void _setColCoeffs(int i,
    6161                               int length,
    62                                int   * indices,
    63                                Value   * values);
     62                               const int   * indices,
     63                               const Value   * values);
    6464    virtual void _setColLowerBound(int i, Value value);
    6565    virtual void _setColUpperBound(int i, Value value);
     
    6767    virtual void _setRowUpperBound(int i, Value value);
    6868    virtual void _setObjCoeff(int i, Value obj_coef);
     69    ///\e
     70   
     71    ///\bug Unimplemented
     72    ///
     73    virtual SolutionType _solve();
     74    ///\e
     75   
     76    ///\bug Unimplemented
     77    ///
     78    virtual Value _getSolution(int i);
    6979
    7080  };
  • src/work/athos/lp/lp_solver_skeleton.cc

    r1254 r1263  
    6565  {
    6666  }
     67
     68  LpSolverSkeleton::SolutionType LpSolverSkeleton::_solve()
     69  {
     70    return OPTIMAL;
     71  }
     72
     73  LpSolverSkeleton::Value LpSolverSkeleton::_getSolution(int i)
     74  {
     75    return 0;
     76  }
    6777 
    6878} //namespace lemon
  • src/work/athos/lp/lp_solver_skeleton.h

    r1254 r1263  
    4444    virtual void _setRowUpperBound(int i, Value value);
    4545    virtual void _setObjCoeff(int i, Value obj_coef);
     46    virtual SolutionType _solve();
     47    virtual Value _getSolution(int i);
     48
    4649  }; 
    4750
  • src/work/athos/lp/lp_test.cc

    r1259 r1263  
    11#include"lp_solver_skeleton.h"
     2#include"lp_glpk.h"
    23
    34using namespace lemon;
    45
    5 int main()
     6void lpTest(LpSolverBase & lp)
    67{
    7   typedef LpSolverSkeleton LP;
    8   LP lp;
     8  typedef LpSolverBase LP;
    99
    1010  std::vector<LP::Col> x;
     
    3838  lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);
    3939}
     40
     41
     42int main()
     43{
     44  LpSolverSkeleton lp_skel;
     45  LpGlpk lp_glpk;
     46
     47  lpTest(lp_skel);
     48  lpTest(lp_glpk);
     49}
Note: See TracChangeset for help on using the changeset viewer.