# CouenneExprCopy.hpp

Go to the documentation of this file.

    00001 /* $Id: CouenneExprCopy.hpp 490 2011-01-14 16:07:12Z pbelotti $
    00002  *
    00003  * Name:    exprCopy.hpp
    00004  * Author:  Pietro Belotti
    00005  * Purpose: definition of the class exprCopy
    00006  *
    00007  * (C) Carnegie-Mellon University, 2006-10.
    00008  * This file is licensed under the Eclipse Public License (EPL)
    00009  */
    00010
    00011 #ifndef COUENNE_EXPRCOPY_HPP
    00012 #define COUENNE_EXPRCOPY_HPP
    00013
    00014 #include <iostream>
    00015
    00016 #include "CouenneTypes.hpp"
    00017 #include "CouenneExpression.hpp"
    00018
    00019 namespace Couenne {
    00020
    00021 class CouenneObject;
    00022
    00023 // expression copy (points to VALUE of another expression)
    00024
    00025 class exprCopy: public expression {
    00026
    00027  protected:
    00028
    00030   expression *copy_;
    00031
    00033   CouNumber value_;
    00034
    00035  public:
    00036
    00038   inline enum nodeType Type () const
    00039     {return copy_ -> Type ();}
    00040
    00042   //exprCopy () {}
    00043
    00045   exprCopy (expression *copy):
    00046     //copy_  (getOriginal (copy)),// -> Original ()),
    00047     copy_  (copy),// -> Original ()),
    00048     value_ (0.) {}
    00049
    00051   exprCopy (const exprCopy &e, Domain *d = NULL);
    00052
    00055   virtual ~exprCopy () {
    00056     if (copy_)
    00057       delete copy_;
    00058   }
    00059
    00061   virtual inline expression *clone (Domain *d = NULL) const
    00062   {return new exprCopy (*this, d);}
    00063
    00067   inline const expression *Original () const
    00068   {return copy_ -> Original ();}
    00069
    00072   inline bool isaCopy () const
    00073   {return true;}
    00074
    00076   inline expression *Copy () const
    00077   {return (copy_ -> isaCopy ()) ? copy_ -> Copy () : copy_;}
    00078
    00080   inline expression *Image () const
    00081   {return copy_ -> Image ();}
    00082
    00084   inline int Index () const
    00085   {return copy_ -> Index ();}
    00086
    00088   inline int nArgs () const
    00089   {return copy_ -> nArgs ();}
    00090
    00092   inline expression **ArgList () const
    00093   {return copy_ -> ArgList ();}
    00094
    00096   inline void ArgList (expression **al)
    00097   {copy_ -> ArgList (al);}
    00098
    00100   inline expression *Argument () const
    00101   {return copy_ -> Argument ();}
    00102
    00104   inline expression **ArgPtr ()
    00105   {return copy_ -> ArgPtr ();}
    00106
    00108   virtual void print (std::ostream &out = std::cout,
    00109                       bool descend      = false) const;
    00110
    00112   virtual inline CouNumber Value () const
    00113   {return value_;}
    00114
    00116   virtual inline CouNumber operator () ()
    00117   {return (value_ = (*copy_) ());}
    00118     //    {return (*copy_) ();}
    00119     //    {return (copy_ -> Value ());}
    00120
    00122   inline CouNumber gradientNorm (const double *x)
    00123   {return copy_ -> gradientNorm (x);}
    00124
    00126   inline expression *differentiate (int index)
    00127   {return copy_ -> differentiate (index);}
    00128
    00131   inline int DepList (std::set <int> &deplist,
    00132                       enum dig_type   type = ORIG_ONLY)
    00133   {return copy_ -> DepList (deplist, type);}
    00134
    00136   inline expression *simplify ()
    00137   {return copy_ -> simplify ();}
    00138
    00140   inline int Linearity ()
    00141   {return copy_ -> Linearity ();}
    00142
    00143   inline bool isInteger ()
    00144   {return copy_ -> isInteger ();}
    00145
    00147   virtual inline bool isDefinedInteger ()
    00148   {return copy_ -> isDefinedInteger ();}
    00149
    00151   inline void getBounds (expression *&lower, expression *&upper)
    00152   {copy_ -> getBounds (lower, upper);}
    00153
    00155   inline void getBounds (CouNumber &lower, CouNumber &upper)
    00156   {copy_ -> getBounds (lower, upper);}
    00157
    00158
    00160   inline exprAux *standardize (CouenneProblem *p, bool addAux = true)
    00161   {return copy_ -> standardize (p, addAux);}
    00162
    00164   inline void generateCuts (expression *w, //const OsiSolverInterface &si,
    00165                             OsiCuts &cs, const CouenneCutGenerator *cg,
    00166                             t_chg_bounds *chg = NULL, int wind= -1,
    00167                             CouNumber lb = -COUENNE_INFINITY,
    00168                             CouNumber ub =  COUENNE_INFINITY)
    00169
    00170   {copy_ -> generateCuts (w, /*si,*/ cs, cg, chg, wind, lb, ub);}
    00171
    00173   inline enum expr_type code ()
    00174   {return copy_ -> code ();}
    00175
    00177   inline enum convexity convexity () const
    00178   {return copy_ -> convexity ();}
    00179
    00181   int compare (expression &e)
    00182   {return copy_ -> compare (e);}
    00183
    00185   inline int rank ()
    00186   {return copy_ -> rank ();}
    00187
    00189   inline bool impliedBound (int wind, CouNumber *l, CouNumber *u, t_chg_bounds *chg)
    00190   {return copy_ -> impliedBound (wind, l, u, chg);}
    00191
    00194   inline int Multiplicity ()
    00195   {return copy_ -> Multiplicity ();}
    00196
    00199   inline CouNumber selectBranch (const CouenneObject *obj,
    00200                                  const OsiBranchingInformation *info,
    00201                                  expression * &var,
    00202                                  double * &brpts,
    00203                                  double * &brDist, // distance of current LP
    00204                                                    // point to new convexifications
    00205                                  int &way)
    00206
    00207   {return copy_ -> selectBranch (obj, info, var, brpts, brDist, way);}
    00208
    00210   void replace (exprVar *, exprVar *);
    00211
    00213   inline void fillDepSet (std::set <DepNode *, compNode> *dep, DepGraph *g)
    00214   {copy_ -> fillDepSet (dep, g);}
    00215
    00217   void realign (const CouenneProblem *p);
    00218   //{copy_ -> realign (p);}
    00219
    00221   bool isBijective() const
    00222   {return copy_ -> isBijective ();}
    00223
    00225   CouNumber inverse (expression *vardep) const
    00226   {return copy_ -> inverse (vardep);}
    00227
    00229   void closestFeasible (expression *varind, expression *vardep,
    00230                                 CouNumber& left, CouNumber& right) const
    00231   {copy_ -> closestFeasible (varind, vardep, left, right);}
    00232
    00235   bool isCuttable (CouenneProblem *problem, int index) const
    00236   {return copy_ -> isCuttable (problem, index);}
    00237 };
    00238
    00239 }
    00240
    00241 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines