source: branches/Couenne/Couenne/src/expression/exprCopy.h @ 534

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

moved include files to make them doxygenable. Introduced three-way branching, with fixed intervals for now. Added check for small bound interval within all generateCuts()

File size: 3.5 KB
Line 
1/*
2 * Name:    exprCopy.h
3 * Author:  Pietro Belotti
4 * Purpose: definition of the class exprCopy
5 *
6 * (C) Pietro Belotti. This file is licensed under the Common Public License (CPL)
7 */
8
9#ifndef COUENNE_EXPRCOPY_H
10#define COUENNE_EXPRCOPY_H
11
12#include <iostream>
13
14#include <CouenneTypes.h>
15#include <expression.h>
16
17
18// expression copy (points to VALUE of another expression)
19
20class exprCopy: public expression {
21
22 protected:
23
24  /// the expression this object is a (reference) copy of
25  expression *copy_;
26
27 public:
28
29  /// node type
30  inline enum nodeType Type () 
31    {return copy_ -> Type ();}
32
33  /// Constructor, destructor
34  exprCopy  (expression *copy):
35    copy_ (copy) {}
36
37  /// copy constructor
38  exprCopy (const exprCopy &e) {
39    copy_ = e.Original () -> clone ();
40  }
41
42  /// cloning method
43  virtual exprCopy *clone () const
44    {return new exprCopy (*this);}
45
46  /// If this is an exprClone of a exprClone of an expr???, point to
47  /// the original expr??? instead of an exprClone -- improves computing
48  /// efficiency
49  inline const expression *Original () const
50    {return copy_ -> Original ();}
51
52  /// get variable index in problem
53  inline int Index () const
54    {return copy_ -> Index ();}
55
56  /// I/O
57  virtual void print (std::ostream &out) const
58  {out << "["; copy_ -> Original () -> print (out); out << "]";}
59
60  /// value (empty)
61  virtual inline CouNumber Value () const 
62    //    {return currValue_;}
63    {return copy_ -> Value ();} // *** Check this! Should be the commented one
64
65  // FIX ME! a copy should just return an already evaluated number,
66  // that's why it is very important that exprCopy should only be used
67  // in successive evaluations.
68
69  /// null function for evaluating the expression
70  virtual inline CouNumber operator () () 
71    {return (currValue_ = (*copy_) ());}
72  //    {return (currValue_ = copy_ -> Value ());}
73
74  /// differentiation
75  inline expression *differentiate (int index) 
76    {return copy_ -> differentiate (index);}
77
78  /// dependence on variable set
79  inline bool dependsOn (int *varlist, int n) 
80    {return copy_ -> dependsOn (varlist, n);}
81
82  /// simplify expression (useful for derivatives)
83  inline expression *simplify () 
84    {return copy_ -> simplify ();}
85
86  /// get a measure of "how linear" the expression is (see CouenneTypes.h)
87  inline int Linearity ()
88    {return copy_ -> Linearity ();}
89
90  /// Get lower and upper bound of an expression (if any)
91  inline void getBounds (expression *&lower, expression *&upper) 
92    {copy_ -> getBounds (lower, upper);}
93
94  /// Create standard formulation of this expression
95  inline exprAux *standardize (CouenneProblem *p)
96    {return copy_ -> standardize (p);}
97
98  /// generate convexification cut for constraint w = this
99  inline void generateCuts (exprAux *w, const OsiSolverInterface &si, 
100                            OsiCuts &cs, const CouenneCutGenerator *cg) 
101    {copy_ -> generateCuts (w, si, cs, cg);}
102
103  /// return an index to the variable's argument that is better fixed
104  /// in a branching rule for solving a nonconvexity gap
105  virtual expression *getFixVar () 
106    {return copy_ -> getFixVar ();}
107
108  /// code for comparisons
109  virtual enum expr_type code () 
110    {return copy_ -> code ();}
111
112  /// compare this with other expression
113  int compare (expression &e) 
114    {return copy_ -> compare (e);}
115
116  /// used in rank-based branching variable choice
117  virtual int rank (CouenneProblem *p)
118    {return copy_ -> rank (p);} 
119
120  /// implied bound processing
121  bool impliedBound (int wind, CouNumber *l, CouNumber *u, char *chg)
122    {return copy_ -> impliedBound (wind, l, u, chg);}
123};
124
125#endif
Note: See TracBrowser for help on using the repository browser.