Couenne  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CouenneExprGroup.hpp
Go to the documentation of this file.
1 /* $Id: CouenneExprGroup.hpp 615 2011-06-08 20:36:24Z pbelotti $
2  *
3  * Name: exprGroup.hpp
4  * Author: Pietro Belotti
5  * Purpose: definition of mixed sum expressions (constant+linear+nonlinear)
6  *
7  * (C) Carnegie-Mellon University, 2006-09.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_EXPRGROUP_H
12 #define COUENNE_EXPRGROUP_H
13 
14 #include <vector>
15 
16 #include "CouenneExprSum.hpp"
17 #include "CouenneExprVar.hpp"
18 
19 namespace Couenne {
20 
21 class Domain;
22 
24 
25 class exprGroup: public exprSum {
26 
27 public:
28 
29  typedef std::vector <std::pair <exprVar *, CouNumber> > lincoeff;
30 
31 protected:
32 
33  mutable lincoeff lcoeff_;
35 
36 public:
37 
41  lincoeff &,
42  expression ** = NULL,
43  int = 0);
44 
47  lincoeff &,
48  expression ** = NULL,
49  int = 0);
50 
52  exprGroup (const exprGroup &src, Domain *d = NULL);
53 
55  virtual ~exprGroup ();
56 
58  virtual expression *clone (Domain *d = NULL) const
59  {return new exprGroup (*this, d);}
60 
61  // Get constant, indices, and coefficients vectors, and number of linear terms
62  CouNumber getc0 () {return c0_;}
63  lincoeff &lcoeff () const {return lcoeff_;}
64 
66  virtual void print (std::ostream & = std::cout,
67  bool = false) const;
68 
70  virtual CouNumber operator () ();
71 
73  virtual CouNumber gradientNorm (const double *x);
74 
77  virtual int DepList (std::set <int> &deplist,
78  enum dig_type type = ORIG_ONLY);
79 
81  virtual expression *differentiate (int index);
82 
84  virtual expression *simplify ();
85 
87  virtual int Linearity ();
88 
90  virtual void getBounds (expression *&, expression *&);
91 
93  virtual void getBounds (CouNumber &, CouNumber &);
94 
96  virtual void generateCuts (expression *, //const OsiSolverInterface &,
97  OsiCuts &, const CouenneCutGenerator *,
98  t_chg_bounds * = NULL, int = -1,
101 
103  virtual int compare (exprGroup &);
104 
106  virtual enum expr_type code () {return COU_EXPRGROUP;}
107 
109  virtual bool isInteger ();
110 
112  virtual int rank ();
113 
115  virtual void fillDepSet (std::set <DepNode *, compNode> *, DepGraph *);
116 
118  virtual void replace (exprVar *x, exprVar *w);
119 
121  virtual void realign (const CouenneProblem *p);
122 };
123 
124 
126 
128 
129  CouNumber ret = c0_ + exprSum::operator () (); // add constant and nonlinear part
130 
131  // add linear part
132  for (lincoeff::iterator el = lcoeff_.begin (); el != lcoeff_.end (); ++el)
133  ret += el -> second * (*(el -> first)) ();
134 
135  return (CouNumber) ret;
136 }
137 
138 }
139 
140 #endif
Cut Generator for linear convexifications.
virtual ~exprGroup()
Destructor – needed to clear bounds.
class Group, with constant, linear and nonlinear terms:
virtual int rank()
used in rank-based branching variable choice
virtual CouNumber operator()()
Function for the evaluation of the expression.
virtual int Linearity()
get a measure of &quot;how linear&quot; the expression is:
virtual void generateCuts(expression *, OsiCuts &, const CouenneCutGenerator *, t_chg_bounds *=NULL, int=-1, CouNumber=-COUENNE_INFINITY, CouNumber=COUENNE_INFINITY)
special version for linear constraints
CouNumber getc0()
return constant term
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
virtual CouNumber operator()()
function for the evaluation of the expression
virtual void realign(const CouenneProblem *p)
redirect variables to proper variable vector
lincoeff & lcoeff() const
return linear term coefficients
CouNumber c0_
constant term
virtual CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
exprGroup(CouNumber, lincoeff &, expression **=NULL, int=0)
Constructor.
virtual enum expr_type code()
code for comparisons
virtual void fillDepSet(std::set< DepNode *, compNode > *, DepGraph *)
update dependence set with index of this variable
virtual expression * clone(Domain *d=NULL) const
Cloning method.
lincoeff lcoeff_
coefficients and indices of the linear term
Class for MINLP problems with symbolic information.
virtual int compare(exprGroup &)
only compare with people of the same kind
virtual expression * differentiate(int index)
differentiation
virtual bool isInteger()
is this expression integer?
static expression * genExprGroup(CouNumber, lincoeff &, expression **=NULL, int=0)
Generalized (static) constructor: check parameters and return a constant, a single variable...
virtual int DepList(std::set< int > &deplist, enum dig_type type=ORIG_ONLY)
fill in the set with all indices of variables appearing in the expression
virtual expression * simplify()
simplification
std::vector< std::pair< exprVar *, CouNumber > > lincoeff
double CouNumber
main number type in Couenne
virtual void print(std::ostream &=std::cout, bool=false) const
Print expression to iostream.
#define COUENNE_INFINITY
Dependence graph.
dig_type
type of digging when filling the dependence list
virtual void replace(exprVar *x, exprVar *w)
replace variable x with new (aux) w
variable-type operator
expr_type
code returned by the method expression::code()
Expression base class.
virtual void getBounds(expression *&, expression *&)
Get lower and upper bound of an expression (if any)
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...