exprTrilinear.cpp
Go to the documentation of this file.
1 /* $Id: exprTrilinear.cpp 490 2011-01-14 16:07:12Z pbelotti $
2  *
3  * Name: exprTrilinear.cpp
4  * Author: Pietro Belotti
5  * Purpose: definition of trilinear terms
6  *
7  * This file is licensed under the Eclipse Public License (EPL)
8  */
9 
10 #include <stdlib.h>
11 #include <assert.h>
12 
13 #include "CoinHelperFunctions.hpp"
14 #include "CouenneExprMul.hpp"
15 #include "CouenneExprTrilinear.hpp"
16 #include "CouenneExprSum.hpp"
17 #include "CouenneExprConst.hpp"
18 #include "CouenneExprClone.hpp"
19 #include "CouennePrecisions.hpp"
20 
21 using namespace Couenne;
22 
25  exprMul (al, n) {}
26 
27 
30 
31  exprMul (NULL, 0) {
32 
33  nargs_ = 3;
34  arglist_ = new expression * [nargs_];
35 
36  arglist_ [0] = arg0;
37  arglist_ [1] = arg1;
38  arglist_ [2] = arg2;
39 
40  qsort (arglist_, nargs_, sizeof (expression*), compareExpr);
41 }
42 
43 
46  expression *vardep,
47  CouNumber &left,
48  CouNumber &right) const {
49 
50  printf ("using VT and trilinear terms: not implemented yet\n");
51  exit (-1);
52 
53  // TODO: if use quadrilinear and VT, fill this
54 
55  // expression *varoth = arglist_ [0]; // suppose $w = cy$;
56 
57  // if (varoth -> Index () == varind -> Index ())
58  // varoth = arglist_ [1]; // actually no, it's $w = x*c$
59 
60  // assert (varoth -> Index () >= 0);
61 
62  // CouNumber
63  // x = (*varind) (),
64  // y = (*vardep) (),
65  // c = (*varoth) ();
66 
67  // if (c < 0.)
68  // if (y < c*x) {assert (y/c >= right); right = y/c;}
69  // else {assert (y/c <= left); left = y/c;}
70  // else if (c > 0.)
71  // if (y < c*x) {assert (y/c <= left); left = y/c;}
72  // else {assert (y/c >= right); right = y/c;}
73  // else left = - (right = COIN_DBL_MAX);
74 
75 }
76 
77 
80 
81  int
82  ind0 = arglist_ [0] -> Index (),
83  ind1 = arglist_ [1] -> Index (),
84  ind2 = arglist_ [2] -> Index ();
85 
86  CouNumber
87  x0 = (ind0 < 0) ? arglist_ [0] -> Value () : x [ind0],
88  x1 = (ind1 < 0) ? arglist_ [1] -> Value () : x [ind1],
89  x2 = (ind1 < 0) ? arglist_ [2] -> Value () : x [ind2];
90 
91  if (ind0 < 0)
92  if (ind1 < 0)
93  if (ind2 < 0) return 0.; // c*d*e
94  else return fabs (x0*x1); // c*d*y
95  else
96  if (ind2 < 0) return fabs (x0*x2); // c*y*e
97  else return fabs (x0*sqrt(x1*x1 + x2*x2)); // c*y*z
98  else
99  if (ind1 < 0)
100  if (ind2 < 0) return fabs (x1*x2); // x*d*e
101  else return fabs (x1*sqrt(x0*x0 + x2*x2)); // x*d*z
102  else
103  if (ind2 < 0) return fabs (x2*sqrt(x0*x0 + x1*x1)); // x*y*e
104  else return sqrt (x0*x0 + x1*x1 + x2*x2); // x*y*z
105 }
int compareExpr(const void *e0, const void *e1)
independent comparison
ULong x2
Definition: OSdtoa.cpp:1776
CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
ULong * x0
Definition: OSdtoa.cpp:1776
virtual int Index() const
Return index of variable (only valid for exprVar and exprAux)
ULong x1
Definition: OSdtoa.cpp:1776
exprTrilinear(expression **, int)
Constructor.
expression ** arglist_
argument list is an array of pointers to other expressions
double CouNumber
main number type in Couenne
int nargs_
number of arguments (cardinality of arglist)
virtual void closestFeasible(expression *varind, expression *vardep, CouNumber &left, CouNumber &right) const
compute and for Violation Transfer algorithm
Expression base class.
void fint * n
virtual CouNumber Value() const
value (empty)
void fint fint fint real fint real * x
class for multiplications,