CouenneExprMin.hpp

Go to the documentation of this file.
00001 /* $Id: CouenneExprMin.hpp 792 2012-01-24 17:24:15Z pbelotti $
00002  *
00003  * Name:    exprMin.hpp
00004  * Author:  Pietro Belotti
00005  * Purpose: definition of $\f(x_{\argmin_{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_EXPRMIN_H
00012 #define COUENNE_EXPRMIN_H
00013 
00014 #include "CouenneExprOp.hpp"
00015 #include "CouenneExprCopy.hpp"
00016 #include "CouenneExprStore.hpp"
00017 
00018 // TODO: CouenneObject might take expression of the form
00019 // min(x1,x2,...,xn) and branch it by creating two subsets N1 and N2
00020 // of N={1,2,...,n} and then impose the constraints
00021 //
00022 // (xi <= xj for i in N1, j in N2) OR 
00023 // (xi >= xj for i in N1, j in N2)
00024 
00025 namespace Couenne {
00026 
00028 
00029 class exprMin: public exprOp {
00030 
00031  public:
00032 
00034   exprMin  (expression **al, int n): 
00035     exprOp (al, n) {}
00036  
00038   exprMin  (expression *el0, expression *el1):
00039     exprOp (new expression * [4], 4) {
00040     arglist_ [0] = new exprCopy (el0); arglist_ [1] = new exprStore (arglist_ [0]);
00041     arglist_ [2] = new exprCopy (el1); arglist_ [3] = new exprStore (arglist_ [2]);
00042   }
00043 
00045   exprMin *clone (Domain *d = NULL) const
00046     {return new exprMin (clonearglist (d), nargs_);}
00047 
00049   std::string printOp () const
00050     {return "min";}
00051 
00053   enum pos printPos () const
00054     {return PRE;}
00055 
00057   CouNumber operator () ();
00058 
00060   inline expression *differentiate (int) 
00061     {return NULL;} 
00062 
00064   inline expression *simplify () 
00065     {return NULL;}
00066 
00068   virtual inline int Linearity () 
00069     {return NONLINEAR;}
00070 
00071   // Get lower and upper bound of an expression (if any)
00072   void getBounds (expression *&, expression *&);
00073 
00076   virtual inline exprAux *standardize (CouenneProblem *, bool addAux = true)
00077     {return NULL;}
00078 
00080   void generateCuts (expression *w, //const OsiSolverInterface &si, 
00081                      OsiCuts &cs, const CouenneCutGenerator *cg, 
00082                      t_chg_bounds * = NULL, int = -1, 
00083                      CouNumber = -COUENNE_INFINITY, 
00084                      CouNumber =  COUENNE_INFINITY);
00085 
00087   virtual enum expr_type code () 
00088   {return COU_EXPRMIN;}
00089 };
00090 
00091 
00093 
00094 inline CouNumber exprMin::operator () () {
00095 
00096   CouNumber best_val = (*(arglist_ [0])) ();
00097   int best_ind = 0;
00098 
00099   for (int ind = 2; ind < nargs_; ind += 2) {
00100 
00101     CouNumber val = (*(arglist_ [ind])) ();
00102 
00103     if (val < best_val) {
00104       best_ind = ind;
00105       best_val = val;
00106     }
00107   }
00108 
00109   return (*(arglist_ [best_ind + 1])) ();
00110 }
00111 
00112 }
00113 
00114 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 12 Mar 2015 for Couenne by  doxygen 1.6.1