1 /* $Id$
2  *
3  * Name:    CouenneExprTrilinear.hpp
4  * Author:  Pietro Belotti
5  * Purpose: definition of product of three terms
6  *
7  * This file is licensed under the Eclipse Public License (EPL)
8  */
9 
10 #ifndef COUENNE_EXPRTRILINEAR_H
11 #define COUENNE_EXPRTRILINEAR_H
12 
13 #include <vector>
14 
15 #include "CouenneExprMul.hpp"
16 
17 namespace Couenne {
18 
19   /// class for multiplications
20 
21   class exprTrilinear: public exprMul {
22 
23   public:
24 
25     /// Constructor
26     exprTrilinear (expression **, int);
27 
28     /// Constructor with two arguments
29     exprTrilinear (expression *, expression *, expression *);
30 
31     /// Cloning method
clone(Domain * d=NULL) const32     expression *clone (Domain *d = NULL) const
33     {return new exprTrilinear (clonearglist (d), nargs_);}
34 
35     /// return l-2 norm of gradient at given point
36     CouNumber gradientNorm (const double *x);
37 
38     /// Get lower and upper bound of an expression (if any)
39     virtual void getBounds (expression *&, expression *&);
40 
41     /// Get value of lower and upper bound of an expression (if any)
42     virtual void getBounds (CouNumber &lb, CouNumber &ub);
43 
44     /// generate equality between *this and *w
45     void generateCuts (expression *w, //const OsiSolverInterface &si,
46 		       OsiCuts &cs, const CouenneCutGenerator *cg,
47 		       t_chg_bounds * = NULL, int = -1,
48 		       CouNumber = -COUENNE_INFINITY,
49 		       CouNumber =  COUENNE_INFINITY);
50 
51     /// code for comparison
code()52     virtual enum expr_type code ()
53     {return COU_EXPRTRILINEAR;}
54 
55     /// implied bound processing
56     bool impliedBound (int, CouNumber *, CouNumber *, t_chg_bounds *,
57 		       enum Couenne::expression::auxSign = Couenne::expression::AUX_EQ);
58 
59     /// set up branching object by evaluating many branching points for
60     /// each expression's arguments
61     virtual CouNumber selectBranch (const CouenneObject *obj,
62 				    const OsiBranchingInformation *info,
63 				    expression * &var,
64 				    double * &brpts,
65 				    double * &brDist, // distance of current LP
66 				    // point to new convexifications
67 				    int &way);
68 
69     /// compute \f$y^{lv}\f$ and \f$y^{uv}\f$ for Violation Transfer algorithm
70     virtual void closestFeasible (expression *varind,
71 				  expression *vardep,
72 				  CouNumber &left,
73 				  CouNumber &right) const;
74   };
75 }
76 
77 #endif
78