equal
deleted
inserted
replaced
32 |
32 |
33 ///\file |
33 ///\file |
34 ///\brief The interface of the LP solver interface. |
34 ///\brief The interface of the LP solver interface. |
35 ///\ingroup lp_group |
35 ///\ingroup lp_group |
36 namespace lemon { |
36 namespace lemon { |
|
37 |
|
38 /// Function to decide whether a floating point value is finite or not. |
|
39 |
|
40 /// Retruns true if the argument is not infinity, minus infinity or NaN. |
|
41 /// It does the same as the isfinite() function defined by C99. |
|
42 template <typename T> |
|
43 bool isFinite(T value) |
|
44 { |
|
45 typedef std::numeric_limits<T> Lim; |
|
46 if (Lim::has_infinity && (value == Lim::infinity() || value == |
|
47 -Lim::infinity()) || |
|
48 (Lim::has_quiet_NaN || Lim::has_signaling_NaN) && value != value) |
|
49 { |
|
50 return false; |
|
51 } |
|
52 return true; |
|
53 } |
37 |
54 |
38 ///Common base class for LP solvers |
55 ///Common base class for LP solvers |
39 |
56 |
40 ///\todo Much more docs |
57 ///\todo Much more docs |
41 ///\ingroup lp_group |
58 ///\ingroup lp_group |
455 Value &upperBound() { return _ub; } |
472 Value &upperBound() { return _ub; } |
456 ///The const version of \ref upperBound() |
473 ///The const version of \ref upperBound() |
457 const Value &upperBound() const { return _ub; } |
474 const Value &upperBound() const { return _ub; } |
458 ///Is the constraint lower bounded? |
475 ///Is the constraint lower bounded? |
459 bool lowerBounded() const { |
476 bool lowerBounded() const { |
460 using namespace std; |
477 return isFinite(_lb); |
461 return finite(_lb); |
|
462 } |
478 } |
463 ///Is the constraint upper bounded? |
479 ///Is the constraint upper bounded? |
464 bool upperBounded() const { |
480 bool upperBounded() const { |
465 using namespace std; |
481 return isFinite(_ub); |
466 return finite(_ub); |
|
467 } |
482 } |
468 |
483 |
469 void prettyPrint(std::ostream &os) { |
484 void prettyPrint(std::ostream &os) { |
470 if (_lb==-LpSolverBase::INF||isNaN(_lb)) |
485 if (_lb==-LpSolverBase::INF||isNaN(_lb)) |
471 os<<"-infty<="; |
486 os<<"-infty<="; |