Couenne  0.5.7
CouenneExprMax.hpp
Go to the documentation of this file.
1 /* $Id: CouenneExprMax.hpp 1147 2015-05-04 14:01:51Z stefan $
2  *
3  * Name: exprMax.hpp
4  * Author: Pietro Belotti
5  * Purpose: definition of $\f{\textrm{argmax}_{i\in I} y_i}$
6  *
7  * (C) Carnegie-Mellon University, 2006-09.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_EXPRMAX_H
12 #define COUENNE_EXPRMAX_H
13 
14 #include "CouenneExprOp.hpp"
15 #include "CouenneExprCopy.hpp"
16 #include "CouenneExprStore.hpp"
17 
18 namespace Couenne {
19 
21 
22 class exprMax: public exprOp {
23 
24  public:
25 
27  exprMax (expression **al, int n):
28  exprOp (al, n) {} //< non-leaf expression, with argument list
29 
32  exprOp (new expression * [4], 4) {
33  arglist_ [0] = new exprCopy (el0); arglist_ [1] = new exprStore (arglist_ [0]);
34  arglist_ [2] = new exprCopy (el1); arglist_ [3] = new exprStore (arglist_ [2]);
35  }
36 
38  exprMax *clone (Domain *d = NULL) const
39  {return new exprMax (clonearglist (d), nargs_);}
40 
42  std::string printOp () const
43  {return "max";}
44 
46  enum pos printPos () const
47  {return PRE;}
48 
50  inline CouNumber operator () ();
51 
53  inline expression *differentiate (int)
54  {return NULL;}
55 
57  inline expression *simplify ()
58  {return NULL;}
59 
61  virtual inline int Linearity ()
62  {return NONLINEAR;}
63 
64  // Get lower and upper bound of an expression (if any)
65  void getBounds (expression *&, expression *&);
66 
69  virtual inline exprAux *standardize (CouenneProblem *, bool addAux = true)
70  {return NULL;}
71 
73  void generateCuts (expression *w, //const OsiSolverInterface &si,
74  OsiCuts &cs, const CouenneCutGenerator *cg,
75  t_chg_bounds * = NULL, int = -1,
78 
80  virtual enum expr_type code ()
81  {return COU_EXPRMAX;}
82 };
83 
84 
86 
88 
89  CouNumber best_val = (*(arglist_ [0])) ();
90  int best_ind = 0;
91 
92  for (int ind = 2; ind < nargs_; ind += 2) {
93 
94  CouNumber val = (*(arglist_ [ind])) ();
95 
96  if (val > best_val) {
97  best_ind = ind;
98  best_val = val;
99  }
100  }
101 
102  return (*(arglist_ [best_ind + 1])) ();
103 }
104 
105 }
106 
107 #endif
virtual exprAux * standardize(CouenneProblem *, bool addAux=true)
generate auxiliary variable
expression ** arglist_
argument list is an array of pointers to other expressions
#define COUENNE_INFINITY
pos
position where the operator should be printed when printing the expression
expr_type
code returned by the method expression::code()
cloning method exprMax * clone(Domain *d=NULL) const
Cloning method.
Constructor with only two arguments exprMax(expression *el0, expression *el1)
Cut Generator for linear convexifications.
virtual void generateCuts(expression *w, OsiCuts &cs, const CouenneCutGenerator *cg, t_chg_bounds *chg=NULL, int wind=-1, CouNumber lb=-COUENNE_INFINITY, CouNumber ub=COUENNE_INFINITY)
generate convexification cut for constraint w = this
int nargs_
number of arguments (cardinality of arglist)
simplification expression * simplify()
simplification
general n-ary operator-type expression: requires argument list.
double CouNumber
main number type in Couenne
char char * val
virtual std::string printOp() const
print operator
void getBounds(expression *&, expression *&)
Get lower and upper bound of an expression (if any)
code for virtual comparisons enum expr_type code()
return code to classify type of expression
Class for MINLP problems with symbolic information.
expression ** clonearglist(Domain *d=NULL) const
clone argument list (for use with clone method)
storage class for previously evaluated expressions
reduce expression in standard creating additional aux bool addAux
Constructor exprMax(expression **al, int n)
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
print position enum pos printPos() const
print position (PRE, INSIDE, POST)
Expression base class.
function for the evaluation of the expression CouNumber operator()()
null function for evaluating the expression
differentiation expression * differentiate(int)
differentiation
virtual int Linearity()
get a measure of "how linear" the expression is (see CouenneTypes.h)
status of lower/upper bound of a variable, to be checked/modified in bound tightening
Auxiliary variable.
general include file for different compilers