COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
02/10/05 19:53:30 (19 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1545
Message:

trying to add constraints of kind 1 <= x[2]+x[3] <= 4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/marci/lp/expression.h

    r1099 r1144  
    55#include <iostream>
    66#include <map>
     7#include <limits>
    78
    89namespace lemon {
     
    120121    return os;
    121122  }
     123
     124  template <typename _Col, typename _Value>
     125  class LConstr {
     126    //  protected:
     127  public:
     128    Expr<_Col, _Value> expr;
     129    _Value lo;
     130  public:
     131    LConstr(const Expr<_Col, _Value>& _expr, _Value _lo) :
     132      expr(_expr), lo(_lo) { }
     133  };
     134 
     135  template <typename _Col, typename _Value>
     136  LConstr<_Col, _Value>
     137  operator<=(_Value lo, const Expr<_Col, _Value>& expr) {
     138    return LConstr<_Col, _Value>(expr, lo);
     139  }
     140
     141  template <typename _Col, typename _Value>
     142  class UConstr {
     143    //  protected:
     144  public:
     145    Expr<_Col, _Value> expr;
     146    _Value up;
     147  public:
     148    UConstr(const Expr<_Col, _Value>& _expr, _Value _up) :
     149      expr(_expr), up(_up) { }
     150  };
     151
     152  template <typename _Col, typename _Value>
     153  UConstr<_Col, _Value>
     154  operator<=(const Expr<_Col, _Value>& expr, _Value up) {
     155    return UConstr<_Col, _Value>(expr, up);
     156  }
     157
     158  template <typename _Col, typename _Value>
     159  class Constr {
     160    //  protected:
     161  public:
     162    Expr<_Col, _Value> expr;
     163    _Value lo, up;
     164  public:
     165    Constr(const Expr<_Col, _Value>& _expr, _Value _lo, _Value _up) :
     166      expr(_expr), lo(_lo), up(_up) { }
     167    Constr(const LConstr<_Col, _Value>& _lconstr) :
     168      expr(_lconstr.expr),
     169      lo(_lconstr.lo),
     170      up(std::numeric_limits<_Value>::infinity()) { }
     171    Constr(const UConstr<_Col, _Value>& _uconstr) :
     172      expr(_uconstr.expr),
     173      lo(-std::numeric_limits<_Value>::infinity()),
     174      up(_uconstr.up) { }
     175  };
     176
     177  template <typename _Col, typename _Value>
     178  Constr<_Col, _Value>
     179  operator<=(const LConstr<_Col, _Value>& lconstr, _Value up) {
     180    return Constr<_Col, _Value>(lconstr.expr, lconstr.lo, up);
     181  }
     182
     183  template <typename _Col, typename _Value>
     184  Constr<_Col, _Value>
     185  operator<=(_Value lo, const UConstr<_Col, _Value>& uconstr) {
     186    return Constr<_Col, _Value>(uconstr.expr, lo, uconstr.up);
     187  }
     188
     189  template <typename _Col, typename _Value>
     190  Constr<_Col, _Value>
     191  operator==(const Expr<_Col, _Value>& expr, _Value value) {
     192    return Constr<_Col, _Value>(expr, value, value);
     193  }
    122194 
    123195} //namespace lemon
Note: See TracChangeset for help on using the changeset viewer.