# CouenneExprMax.hpp

Go to the documentation of this file.

    00001 /* $Id: CouenneExprMax.hpp 490 2011-01-14 16:07:12Z pbelotti $
    00002  *
    00003  * Name:    exprMax.hpp
    00004  * Author:  Pietro Belotti
    00005  * Purpose: definition of $\f(x_{\argmax_{i\in I} y_i})$
    00006  *
    00007  * (C) Carnegie-Mellon University, 2006-09.
    00008  * This file is licensed under the Eclipse Public License (EPL)
    00009  */
    00010
    00011 #ifndef COUENNE_EXPRMAX_H
    00012 #define COUENNE_EXPRMAX_H
    00013
    00014 #include "CouenneExprOp.hpp"
    00015 #include "CouenneExprCopy.hpp"
    00016 #include "CouenneExprStore.hpp"
    00017
    00018 namespace Couenne {
    00019
    00021
    00022 class exprMax: public exprOp {
    00023
    00024  public:
    00025
    00027   exprMax  (expression **al, int n):
    00028     exprOp (al, n) {} //< non-leaf expression, with argument list
    00029
    00031   exprMax  (expression *el0, expression *el1):
    00032     exprOp (new expression * [4], 4) {
    00033     arglist_ [0] = new exprCopy (el0); arglist_ [1] = new exprStore (arglist_ [0]);
    00034     arglist_ [2] = new exprCopy (el1); arglist_ [3] = new exprStore (arglist_ [2]);
    00035   }
    00036
    00038   exprMax *clone (Domain *d = NULL) const
    00039     {return new exprMax (clonearglist (d), nargs_);}
    00040
    00042   std::string printOp () const
    00043     {return "max";}
    00044
    00046   enum pos printPos () const
    00047     {return PRE;}
    00048
    00050   inline CouNumber operator () ();
    00051
    00053   inline expression *differentiate (int)
    00054     {return NULL;}
    00055
    00057   inline expression *simplify ()
    00058     {return NULL;}
    00059
    00061   virtual inline int Linearity ()
    00062     {return NONLINEAR;}
    00063
    00064   // Get lower and upper bound of an expression (if any)
    00065   void getBounds (expression *&, expression *&);
    00066
    00069   virtual inline exprAux *standardize (CouenneProblem *, bool addAux = true)
    00070     {return NULL;}
    00071
    00073   void generateCuts (expression *w, //const OsiSolverInterface &si,
    00074                      OsiCuts &cs, const CouenneCutGenerator *cg,
    00075                      t_chg_bounds * = NULL, int = -1,
    00076                      CouNumber = -COUENNE_INFINITY,
    00077                      CouNumber =  COUENNE_INFINITY);
    00078
    00080   virtual enum expr_type code ()
    00081   {return COU_EXPRMAX;}
    00082 };
    00083
    00084
    00086
    00087 inline CouNumber exprMax::operator () () {
    00088
    00089   CouNumber best_val = (*(arglist_ [0])) ();
    00090   int best_ind = 0;
    00091
    00092   for (int ind = 2; ind < nargs_; ind += 2) {
    00093
    00094     CouNumber val = (*(arglist_ [ind])) ();
    00095
    00096     if (val > best_val) {
    00097       best_ind = ind;
    00098       best_val = val;
    00099     }
    00100   }
    00101
    00102   return (*(arglist_ [best_ind + 1])) ();
    00103 }
    00104
    00105 }
    00106
    00107 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines