Couenne  0.5.7
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
virtual exprAux * standardize(CouenneProblem *, bool addAux=true)
generate auxiliary variable
expression ** arglist_
argument list is an array of pointers to other expressions
Code for virtual comparisons enum expr_type code()
return code to classify type of expression
virtual enum pos printPos() const
print position (PRE, INSIDE, POST)
#define COUENNE_INFINITY
pos
position where the operator should be printed when printing the expression
Simplification expression * simplify()
simplification
expr_type
code returned by the method expression::code()
Cloning method exprMin * clone(Domain *d=NULL) const
Cloning method.
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)
general n-ary operator-type expression: requires argument list.
double CouNumber
main number type in Couenne
char char * val
Differentiation expression * differentiate(int)
differentiation
virtual std::string printOp() const
print operator
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
Constructor with only two arguments exprMin(expression *el0, expression *el1)
Function for the evaluation of the expression CouNumber operator()()
null function for evaluating the expression
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
Expression base class.
Constructor exprMin(expression **al, int n)
void getBounds(expression *&, expression *&)
Get lower and upper bound of an expression (if any)
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.
Reduce expression in standard creating additional aux bool addAux
general include file for different compilers