source: branches/Couenne/Couenne/src/include/operators/exprSub.h @ 467

Last change on this file since 467 was 467, checked in by pbelotti, 13 years ago

fixed comparison of exprGroup

File size: 2.0 KB
Line 
1/*
2 * Name:    exprSub.h
3 * Author:  Pietro Belotti
4 * Purpose: definition of subtractions
5 *
6 * (C) Pietro Belotti. This file is licensed under the Common Public License (CPL)
7 */
8
9#ifndef COUENNE_EXPRSUB_H
10#define COUENNE_EXPRSUB_H
11
12#include <exprOp.h>
13#include <CouennePrecisions.h>
14#include <CouenneProblem.h>
15
16// class for subtraction
17
18class exprSub: public exprOp {
19
20 public:
21
22  // Constructors, destructor
23  exprSub  (expression **al, int n = 2): 
24    exprOp (al, n) {} //< non-leaf expression, with argument list
25
26  exprSub (expression *arg0, expression *arg1):
27    exprOp (arg0, arg1) {}
28
29  // cloning method
30  expression *clone () const
31    {return new exprSub (clonearglist (), nargs_);}
32
33  // I/O
34  void print (std::ostream&) const;
35
36  // function for the evaluation of the expression
37  CouNumber operator () ();
38
39  // differentiation
40  expression *differentiate (int index); 
41
42  // simplification
43  expression *simplify ();
44
45  // get a measure of "how linear" the expression is (see CouenneTypes.h)
46  virtual inline int Linearity () {
47
48    int lin1 = arglist_ [0] -> Linearity ();
49    int lin2 = arglist_ [1] -> Linearity ();
50
51    if (lin1 < lin2) return lin2;
52    else             return lin1;
53  }
54
55  // Get lower and upper bound of an expression (if any)
56  void getBounds (expression *&, expression *&);
57
58  // reduce expression in standard form, creating additional aux
59  // variables (and constraints)
60  virtual exprAux *standardize (CouenneProblem *p);
61
62  // generate equality between *this and *w
63  void generateCuts (exprAux *w, const OsiSolverInterface &si, 
64                     OsiCuts &cs, const CouenneCutGenerator *cg);
65
66  ///
67  virtual enum expr_type code () {return COU_EXPRSUB;}
68
69  /// implied bound processing
70  bool impliedBound (int, CouNumber *, CouNumber *, char *);
71};
72
73
74// compute subtraction
75
76inline CouNumber exprSub::operator () () {
77
78  //  exprOp:: operator () ();
79
80  //  register CouNumber ret = - *sp--;
81  return (currValue_ = (*(arglist_ [0])) () - (*(arglist_ [1])) ());
82}
83
84#endif
Note: See TracBrowser for help on using the repository browser.