source: trunk/Couenne/src/problem/constraint.cpp @ 114

Last change on this file since 114 was 114, checked in by stefan, 13 years ago

for gcc 4.4

File size: 1.1 KB
Line 
1/*
2 * Name:    constraint.cpp
3 * Author:  Pietro Belotti
4 * Purpose: methods of the classes CouenneConstraint and LinearConstraint
5 *
6 * (C) Carnegie-Mellon University, 2006.
7 * This file is licensed under the Common Public License (CPL)
8 */
9
10#include "CouenneTypes.hpp"
11#include "CouenneProblemElem.hpp"
12
13#include <cstdio>
14
15// output nonlinear constraint
16
17void CouenneConstraint::print (std::ostream &out) {
18
19  bool samebounds = ((lb_ -> Type () == CONST) &&
20                     (ub_ -> Type () == CONST) && 
21                     (fabs (lb_ -> Value () - ub_ -> Value ()) < COUENNE_EPS));
22
23  // left hand side (a in a <= h(x) <= b)
24
25  if (lb_ && 
26      !samebounds &&
27      ((lb_ -> Type  () != CONST) ||
28       (lb_ -> Value () > - COUENNE_INFINITY))) {
29
30    lb_ -> print (out); fflush (stdout);
31    out  << " <= "; fflush (stdout);
32  }
33
34  // body: h(x) in a <= h(x) <= b
35
36  body_ -> print (out); fflush (stdout);
37
38  // right hand side
39
40  if (ub_ && ((ub_ -> Type  () != CONST) || 
41              (ub_ -> Value () <  COUENNE_INFINITY))) {
42
43    out << ' ';
44    if (!samebounds) out << "<";
45    out << "= "; fflush (stdout);
46    ub_ -> print (out); fflush (stdout);
47  } 
48
49  out << std::endl;
50}
Note: See TracBrowser for help on using the repository browser.