Couenne 0.5.8
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
19namespace Couenne {
20
21class Domain;
22
24
25class exprGroup: public exprSum {
26
27public:
28
29 typedef std::vector <std::pair <exprVar *, CouNumber> > lincoeff;
30
31protected:
32
33 mutable lincoeff lcoeff_;
35
36public:
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 &,
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
#define COUENNE_INFINITY
Cut Generator for linear convexifications.
Class for MINLP problems with symbolic information.
Dependence graph.
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
class Group, with constant, linear and nonlinear terms:
static expression * genExprGroup(CouNumber, lincoeff &, expression **=NULL, int=0)
Generalized (static) constructor: check parameters and return a constant, a single variable,...
virtual int compare(exprGroup &)
only compare with people of the same kind
virtual enum expr_type code()
code for comparisons
virtual CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
virtual void replace(exprVar *x, exprVar *w)
replace variable x with new (aux) w
virtual expression * simplify()
simplification
virtual void print(std::ostream &=std::cout, bool=false) const
Print expression to iostream.
lincoeff & lcoeff() const
return linear term coefficients
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 void getBounds(expression *&, expression *&)
Get lower and upper bound of an expression (if any)
virtual void getBounds(CouNumber &, CouNumber &)
Get lower and upper bound of an expression (if any)
CouNumber getc0()
return constant term
virtual bool isInteger()
is this expression integer?
virtual void fillDepSet(std::set< DepNode *, compNode > *, DepGraph *)
update dependence set with index of this variable
CouNumber c0_
constant term
std::vector< std::pair< exprVar *, CouNumber > > lincoeff
virtual CouNumber operator()()
function for the evaluation of the expression
exprGroup(const exprGroup &src, Domain *d=NULL)
Copy constructor.
virtual int Linearity()
get a measure of "how linear" the expression is:
virtual ~exprGroup()
Destructor – needed to clear bounds.
virtual void realign(const CouenneProblem *p)
redirect variables to proper variable vector
virtual void generateCuts(expression *, OsiCuts &, const CouenneCutGenerator *, t_chg_bounds *=NULL, int=-1, CouNumber=-COUENNE_INFINITY, CouNumber=COUENNE_INFINITY)
special version for linear constraints
virtual int rank()
used in rank-based branching variable choice
virtual expression * differentiate(int index)
differentiation
virtual expression * clone(Domain *d=NULL) const
Cloning method.
exprGroup(CouNumber, lincoeff &, expression **=NULL, int=0)
Constructor.
lincoeff lcoeff_
coefficients and indices of the linear term
virtual CouNumber operator()()
Function for the evaluation of the expression.
variable-type operator
Expression base class.
status of lower/upper bound of a variable, to be checked/modified in bound tightening
general include file for different compilers
dig_type
type of digging when filling the dependence list
double CouNumber
main number type in Couenne
expr_type
code returned by the method expression::code()