lemon/lp_base.h
changeset 2345 bfcaad2b84e8
parent 2328 b4931ae52069
child 2363 2aabce558574
     1.1 --- a/lemon/lp_base.h	Thu Jan 11 22:08:18 2007 +0000
     1.2 +++ b/lemon/lp_base.h	Fri Jan 12 16:29:06 2007 +0000
     1.3 @@ -19,6 +19,9 @@
     1.4  #ifndef LEMON_LP_BASE_H
     1.5  #define LEMON_LP_BASE_H
     1.6  
     1.7 +#include<iostream>
     1.8 +
     1.9 +
    1.10  #include<vector>
    1.11  #include<map>
    1.12  #include<limits>
    1.13 @@ -269,7 +272,7 @@
    1.14      
    1.15      ///Linear expression of variables and a constant component
    1.16      
    1.17 -    ///This data structure strores a linear expression of the variables
    1.18 +    ///This data structure stores a linear expression of the variables
    1.19      ///(\ref Col "Col"s) and also has a constant component.
    1.20      ///
    1.21      ///There are several ways to access and modify the contents of this
    1.22 @@ -327,7 +330,7 @@
    1.23        typedef std::map<Col,Value> Base;
    1.24        
    1.25        Value const_comp;
    1.26 -  public:
    1.27 +    public:
    1.28        typedef True IsLinExpression;
    1.29        ///\e
    1.30        Expr() : Base(), const_comp(0) { }
    1.31 @@ -404,6 +407,26 @@
    1.32  	const_comp/=c;
    1.33  	return *this;
    1.34        }
    1.35 +
    1.36 +      //std::ostream &
    1.37 +      void prettyPrint(std::ostream &os) {
    1.38 +	//std::fmtflags os.flags();
    1.39 +	//os.setf(std::ios::showpos);
    1.40 +	Base::iterator j=Base::begin();
    1.41 +	if (j!=Base::end())
    1.42 +	  os<<j->second<<"*x["<<id(j->first)<<"]";
    1.43 +	++j;
    1.44 +	for (; j!=Base::end(); ++j){
    1.45 +	  if (j->second>=0)
    1.46 +	    os<<"+";
    1.47 +	  os<<j->second<<"*x["<<id(j->first)<<"]";
    1.48 +	}
    1.49 +	//Nem valami korrekt, de nem talaltam meg, hogy kell
    1.50 +	//os.unsetf(std::ios::showpos);
    1.51 +
    1.52 +	//return os;
    1.53 +      }
    1.54 +
    1.55      };
    1.56      
    1.57      ///Linear constraint
    1.58 @@ -496,6 +519,20 @@
    1.59  	using namespace std;
    1.60  	return finite(_ub);
    1.61        }
    1.62 +
    1.63 +      void prettyPrint(std::ostream &os) {
    1.64 +	if (_lb==-LpSolverBase::INF||isNaN(_lb))
    1.65 +	  os<<"-infty<=";
    1.66 +	else
    1.67 +	  os<<_lb<<"<=";
    1.68 +	_expr.prettyPrint(os);
    1.69 +	if (_ub==LpSolverBase::INF)
    1.70 +	  os<<"<=infty";
    1.71 +	else
    1.72 +	  os<<"<="<<_ub;
    1.73 +	//return os;
    1.74 +      }
    1.75 +
    1.76      };
    1.77      
    1.78      ///Linear expression of rows
    1.79 @@ -1490,6 +1527,16 @@
    1.80    }
    1.81  
    1.82    ///\e
    1.83 +
    1.84 +  ///\relates LpSolverBase::Constr
    1.85 +  ///
    1.86 +  inline LpSolverBase::Constr operator==(const LpSolverBase::Expr &e,
    1.87 +					 const LpSolverBase::Value &f) 
    1.88 +  {
    1.89 +    return LpSolverBase::Constr(f,e,f);
    1.90 +  }
    1.91 +
    1.92 +  ///\e
    1.93    
    1.94    ///\relates LpSolverBase::Constr
    1.95    ///