source: branches/Couenne/Couenne/src/include/exprVar.h @ 445

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

fixed NaN bounds in initAux, added rank and multiplicity to branch selection, added (unused for now) extra cuts to exprMul, use double bounds (natural + branch) for auxiliary variables

File size: 2.6 KB
Line 
1/*
2 * Name:    exprVar.h
3 * Author:  Pietro Belotti
4 * Purpose: definition of the class exprVar for variables
5 *
6 * (C) Pietro Belotti. This file is licensed under the Common Public License (CPL)
7 */
8
9#ifndef COUENNE_EXPRVAR_H
10#define COUENNE_EXPRVAR_H
11
12#include <iostream>
13
14#include <CouenneTypes.h>
15#include <expression.h>
16#include <exprConst.h>
17
18class CouenneProblem;
19
20
21/// variable-type operator. All variables of the expression must be
22/// objects of this class
23
24class exprVar: public expression {
25
26 protected:
27
28  int varIndex_; //< the index of the variable's current value
29
30 public:
31
32  /// node type
33  virtual inline enum nodeType Type () 
34    {return VAR;}
35
36  /// Constructor
37  exprVar (int varIndex):
38    varIndex_ (varIndex) {}
39
40  /// destructor
41  virtual ~exprVar () {}
42
43  /// copy constructor
44  exprVar (const exprVar &e):
45    varIndex_ (e.Index ()) {}
46
47  /// cloning method
48  virtual exprVar *clone () const
49    {return new exprVar (*this);}
50
51  /// get variable index in problem
52  inline int Index () const
53    {return varIndex_;}
54
55  /// print
56  virtual void print (std::ostream &out) const
57    {out << "x_" << varIndex_;}
58
59  /// return the value of the variable
60  virtual inline CouNumber operator () () 
61    {return (currValue_ = expression::variables_ [varIndex_]);}
62
63  /// return the value of the variable
64  inline CouNumber Value ()
65    {return currValue_;}
66
67  /// differentiation
68  virtual inline expression *differentiate (int index) 
69    {return new exprConst ((index == varIndex_) ? 1 : 0);}
70
71  /// dependence on variable set
72  virtual bool dependsOn (int *, int);
73
74  /// simplify
75  inline expression *simplify () 
76    {return NULL;}
77
78  /// get a measure of "how linear" the expression is (see CouenneTypes.h)
79  virtual inline int Linearity ()
80    {return LINEAR;}
81
82  /// is this expression integer?
83  virtual bool isInteger ()
84    {return false;}
85
86  /// Get lower and upper bound of an expression (if any)
87  virtual void getBounds (expression *&, expression *&);
88
89  /// generate convexification cut for constraint w = this
90  void generateCuts (exprAux *w, const OsiSolverInterface &si, 
91                     OsiCuts &cs, const CouenneCutGenerator *cg);
92
93  /// return an index to the variable's argument that is better fixed
94  /// in a branching rule for solving a nonconvexity gap
95  virtual expression *getFixVar () {return this;}
96
97  /// code for comparison
98  virtual enum expr_type code () {return COU_EXPRVAR;}
99
100  /// implied bound processing
101  virtual bool impliedBound (int, CouNumber *, CouNumber *, char *);
102
103  /// rank of an original variable is always one
104  virtual int rank (CouenneProblem *p) 
105    {return 1;}
106};
107
108#endif
Note: See TracBrowser for help on using the repository browser.