Couenne  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CouenneExprMin.hpp
Go to the documentation of this file.
1 /* $Id: CouenneExprMin.hpp 1147 2015-05-04 14:01:51Z stefan $
2  *
3  * Name: exprMin.hpp
4  * Author: Pietro Belotti
5  * Purpose: definition of $\f{\textrm{argmin}_{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_EXPRMIN_H
12 #define COUENNE_EXPRMIN_H
13 
14 #include "CouenneExprOp.hpp"
15 #include "CouenneExprCopy.hpp"
16 #include "CouenneExprStore.hpp"
17 
18 // TODO: CouenneObject might take expression of the form
19 // min(x1,x2,...,xn) and branch it by creating two subsets N1 and N2
20 // of N={1,2,...,n} and then impose the constraints
21 //
22 // (xi <= xj for i in N1, j in N2) OR
23 // (xi >= xj for i in N1, j in N2)
24 
25 namespace Couenne {
26 
28 
29 class exprMin: public exprOp {
30 
31  public:
32 
34  exprMin (expression **al, int n):
35  exprOp (al, n) {}
36 
39  exprOp (new expression * [4], 4) {
40  arglist_ [0] = new exprCopy (el0); arglist_ [1] = new exprStore (arglist_ [0]);
41  arglist_ [2] = new exprCopy (el1); arglist_ [3] = new exprStore (arglist_ [2]);
42  }
43 
45  exprMin *clone (Domain *d = NULL) const
46  {return new exprMin (clonearglist (d), nargs_);}
47 
49  std::string printOp () const
50  {return "min";}
51 
53  enum pos printPos () const
54  {return PRE;}
55 
58 
60  inline expression *differentiate (int)
61  {return NULL;}
62 
64  inline expression *simplify ()
65  {return NULL;}
66 
68  virtual inline int Linearity ()
69  {return NONLINEAR;}
70 
71  // Get lower and upper bound of an expression (if any)
72  void getBounds (expression *&, expression *&);
73 
76  virtual inline exprAux *standardize (CouenneProblem *, bool addAux = true)
77  {return NULL;}
78 
80  void generateCuts (expression *w, //const OsiSolverInterface &si,
81  OsiCuts &cs, const CouenneCutGenerator *cg,
82  t_chg_bounds * = NULL, int = -1,
85 
87  virtual enum expr_type code ()
88  {return COU_EXPRMIN;}
89 };
90 
91 
93 
95 
96  CouNumber best_val = (*(arglist_ [0])) ();
97  int best_ind = 0;
98 
99  for (int ind = 2; ind < nargs_; ind += 2) {
100 
101  CouNumber val = (*(arglist_ [ind])) ();
102 
103  if (val < best_val) {
104  best_ind = ind;
105  best_val = val;
106  }
107  }
108 
109  return (*(arglist_ [best_ind + 1])) ();
110 }
111 
112 }
113 
114 #endif
Cut Generator for linear convexifications.
Constructor exprMin(expression **al, int n)
pos
position where the operator should be printed when printing the expression
void getBounds(expression *&, expression *&)
Get lower and upper bound of an expression (if any)
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
virtual enum pos printPos() const
print position (PRE, INSIDE, POST)
Function for the evaluation of the expression CouNumber operator()()
null function for evaluating the expression
expression()
Constructor.
virtual exprAux * standardize(CouenneProblem *, bool addAux=true)
generate auxiliary variable
Code for virtual comparisons enum expr_type code()
return code to classify type of expression
virtual int Linearity()
get a measure of &quot;how linear&quot; the expression is (see CouenneTypes.h)
expression ** clonearglist(Domain *d=NULL) const
clone argument list (for use with clone method)
Class for MINLP problems with symbolic information.
Constructor with only two arguments exprMin(expression *el0, expression *el1)
Cloning method exprMin * clone(Domain *d=NULL) const
Cloning method.
expression ** arglist_
argument list is an array of pointers to other expressions
double CouNumber
main number type in Couenne
int nargs_
number of arguments (cardinality of arglist)
general n-ary operator-type expression: requires argument list.
#define COUENNE_INFINITY
Auxiliary variable.
virtual std::string printOp() const
print operator
expr_type
code returned by the method expression::code()
storage class for previously evaluated expressions
Reduce expression in standard creating additional aux bool addAux
Expression base class.
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
Simplification expression * simplify()
simplification
Differentiation expression * differentiate(int)
differentiation
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...