COIN-OR::LEMON - Graph Library

Changeset 2345:bfcaad2b84e8 in lemon-0.x


Ignore:
Timestamp:
01/12/07 17:29:06 (13 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3137
Message:

One important thing only: equality-type constraint can now be added to an lp. The prettyPrint functions are not too pretty yet, I accept.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lemon/lp_base.h

    r2328 r2345  
    1919#ifndef LEMON_LP_BASE_H
    2020#define LEMON_LP_BASE_H
     21
     22#include<iostream>
     23
    2124
    2225#include<vector>
     
    270273    ///Linear expression of variables and a constant component
    271274   
    272     ///This data structure strores a linear expression of the variables
     275    ///This data structure stores a linear expression of the variables
    273276    ///(\ref Col "Col"s) and also has a constant component.
    274277    ///
     
    328331     
    329332      Value const_comp;
    330   public:
     333    public:
    331334      typedef True IsLinExpression;
    332335      ///\e
     
    405408        return *this;
    406409      }
     410
     411      //std::ostream &
     412      void prettyPrint(std::ostream &os) {
     413        //std::fmtflags os.flags();
     414        //os.setf(std::ios::showpos);
     415        Base::iterator j=Base::begin();
     416        if (j!=Base::end())
     417          os<<j->second<<"*x["<<id(j->first)<<"]";
     418        ++j;
     419        for (; j!=Base::end(); ++j){
     420          if (j->second>=0)
     421            os<<"+";
     422          os<<j->second<<"*x["<<id(j->first)<<"]";
     423        }
     424        //Nem valami korrekt, de nem talaltam meg, hogy kell
     425        //os.unsetf(std::ios::showpos);
     426
     427        //return os;
     428      }
     429
    407430    };
    408431   
     
    497520        return finite(_ub);
    498521      }
     522
     523      void prettyPrint(std::ostream &os) {
     524        if (_lb==-LpSolverBase::INF||isNaN(_lb))
     525          os<<"-infty<=";
     526        else
     527          os<<_lb<<"<=";
     528        _expr.prettyPrint(os);
     529        if (_ub==LpSolverBase::INF)
     530          os<<"<=infty";
     531        else
     532          os<<"<="<<_ub;
     533        //return os;
     534      }
     535
    499536    };
    500537   
     
    14911528
    14921529  ///\e
     1530
     1531  ///\relates LpSolverBase::Constr
     1532  ///
     1533  inline LpSolverBase::Constr operator==(const LpSolverBase::Expr &e,
     1534                                         const LpSolverBase::Value &f)
     1535  {
     1536    return LpSolverBase::Constr(f,e,f);
     1537  }
     1538
     1539  ///\e
    14931540 
    14941541  ///\relates LpSolverBase::Constr
  • lemon/lp_glpk.cc

    r2328 r2345  
    527527  LpGlpk::SolveExitStatus LpGlpk::_solve()
    528528  {
     529    // A way to check the problem to be solved
     530    //lpx_write_cpxlp(lp,"naittvan.cpx");   
     531
    529532    int i =  lpx_simplex(lp);
    530533    switch (i) {
  • test/lp_test.cc

    r2328 r2345  
    195195    //    std::cout<<e[p1]<<e[p2]<<e[p3]<<std::endl;
    196196    check(e.find(p2)==e.end(), buf.str());
    197 
     197   
    198198     
    199199
    200200
    201201    e=((p1+p2)+(p1-0.99*p2));
     202    //e.prettyPrint(std::cout);
     203    //(e<=2).prettyPrint(std::cout);
    202204    double tolerance=0.001;
    203205    e.simplify(tolerance);
Note: See TracChangeset for help on using the changeset viewer.