Couenne 0.5.8
Loading...
Searching...
No Matches
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
18namespace Couenne {
19
21
22class 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
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)
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
#define COUENNE_INFINITY
Cut Generator for linear convexifications.
Class for MINLP problems with symbolic information.
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
Auxiliary variable.
class for maxima
virtual int Linearity()
get a measure of "how linear" the expression is (see CouenneTypes.h)
std::string printOp() const
print operator
exprMax(expression *el0, expression *el1)
Constructor with only two arguments.
virtual enum expr_type code()
code for comparisons
exprMax(expression **al, int n)
Constructor.
void generateCuts(expression *w, OsiCuts &cs, const CouenneCutGenerator *cg, t_chg_bounds *=NULL, int=-1, CouNumber=-COUENNE_INFINITY, CouNumber=COUENNE_INFINITY)
generate equality between *this and *w
CouNumber operator()()
function for the evaluation of the expression
enum pos printPos() const
print position
expression * differentiate(int)
differentiation
expression * simplify()
simplification
exprMax * clone(Domain *d=NULL) const
cloning method
void getBounds(expression *&, expression *&)
Get lower and upper bound of an expression (if any)
virtual exprAux * standardize(CouenneProblem *, bool addAux=true)
reduce expression in standard form, creating additional aux variables (and constraints)
general n-ary operator-type expression: requires argument list.
int nargs_
number of arguments (cardinality of arglist)
expression ** arglist_
argument list is an array of pointers to other expressions
expression ** clonearglist(Domain *d=NULL) const
clone argument list (for use with clone method)
storage class for previously evaluated expressions
Expression base class.
status of lower/upper bound of a variable, to be checked/modified in bound tightening
general include file for different compilers
pos
position where the operator should be printed when printing the expression
double CouNumber
main number type in Couenne
expr_type
code returned by the method expression::code()