source: branches/Couenne/Couenne/src/include/operators/exprMul.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.1 KB
Line 
1/*
2 * Name:    exprMul.h
3 * Author:  Pietro Belotti
4 * Purpose: definition of multiplications
5 *
6 * (C) Pietro Belotti. This file is licensed under the Common Public License (CPL)
7 */
8
9#ifndef COUENNE_EXPRMUL_H
10#define COUENNE_EXPRMUL_H
11
12#include <exprOp.h>
13#include <exprAux.h>
14#include <CouenneProblem.h>
15
16/// class for multiplications
17
18class exprMul: public exprOp {
19
20 public:
21
22  /// Constructors, destructor
23  exprMul (expression **, int);
24
25  exprMul (expression *, expression *);
26
27  /// cloning method
28  expression *clone () const
29    {return new exprMul (clonearglist (), nargs_);}
30
31  /// print expression
32  void print (std::ostream&) const;
33
34  /// function for the evaluation of the expression
35  inline CouNumber operator () ();
36
37  /// differentiation
38  expression *differentiate (int index); 
39
40  /// simplification
41  expression *simplify ();
42
43  /// get a measure of "how linear" the expression is:
44  virtual int Linearity ();
45
46  /// Get lower and upper bound of an expression (if any)
47  void getBounds (expression *&, expression *&);
48
49  /// reduce expression in standard form, creating additional aux
50  /// variables (and constraints)
51  virtual exprAux *standardize (CouenneProblem *p);
52
53  /// generate equality between *this and *w
54  void generateCuts (exprAux *w, const OsiSolverInterface &si, 
55                     OsiCuts &cs, const CouenneCutGenerator *cg);
56
57  /// return an index to the variable's argument that is better fixed
58  /// in a branching rule for solving a nonconvexity gap
59  expression *getFixVar ();
60
61  /// code for comparison
62  virtual enum expr_type code () {return COU_EXPRMUL;}
63
64  /// implied bound processing
65  bool impliedBound (int, CouNumber *, CouNumber *, char *);
66};
67
68
69/// compute multiplication
70
71inline CouNumber exprMul:: operator () () {
72
73  register CouNumber ret = 1;
74
75  expression **al = arglist_;
76
77  for (register int n = nargs_; n--;)
78    ret *= (**al++) ();
79
80  return (currValue_ = ret);
81
82  /*
83  exprOp:: operator () ();
84
85  register CouNumber ret = *sp--;
86  register int    n   =  nargs_;
87
88  while (--n)
89    ret *= *sp--;
90
91    return (currValue_ = ret);
92  */
93}
94
95#endif
Note: See TracBrowser for help on using the repository browser.