source: branches/Couenne/Couenne/src/expression/operators/exprMin.h @ 534

Last change on this file since 534 was 534, checked in by pbelotti, 13 years ago

moved include files to make them doxygenable. Introduced three-way branching, with fixed intervals for now. Added check for small bound interval within all generateCuts()

File size: 2.4 KB
Line 
1/*
2 * Name:    exprMin.h
3 * Author:  Pietro Belotti
4 * Purpose: definition of $\f(x_{\argmin_{i\in I} y_i})$
5 *
6 * (C) Pietro Belotti 2006. This file is licensed under the Common Public License (CPL)
7 */
8
9#ifndef COUENNE_EXPRMIN_H
10#define COUENNE_EXPRMIN_H
11
12#include <exprOp.h>
13
14
15///  class for minima
16
17class exprMin: public exprOp {
18
19 public:
20
21  /// Constructors, destructor
22  exprMin  (expression **al, int n): 
23    exprOp (al, n) {}
24 
25  exprMin  (expression *el0, expression *el1):
26    exprOp (new expression * [4], 4) {
27    arglist_ [0] = el0; arglist_ [1] = new exprClone (el0);
28    arglist_ [2] = el1; arglist_ [3] = new exprClone (el1);
29  }
30
31  /// cloning method
32  exprMin *clone () const
33    {return new exprMin (clonearglist (), nargs_);}
34
35  /// I/O
36  void print (std::ostream &out) const
37    {exprOp:: print (out, "min", PRE);}
38
39  /// function for the evaluation of the expression
40  CouNumber operator () ();
41
42  /// differentiation
43  inline expression *differentiate (int) 
44    {return NULL;} 
45
46  /// simplification
47  inline expression *simplify () 
48    {return NULL;}
49
50  /// get a measure of "how linear" the expression is (see CouenneTypes.h)
51  virtual inline int Linearity () 
52    {return NONLINEAR;}
53
54  /// Get lower and upper bound of an expression (if any)
55  ///  void getBounds (expression *&, expression *&);
56
57  /// reduce expression in standard form, creating additional aux
58  /// variables (and constraints)
59  virtual inline exprAux *standardize (CouenneProblem *)
60    {return NULL;}
61
62  /// generate equality between *this and *w
63  void generateCuts (exprAux *w, const OsiSolverInterface &si, 
64                     OsiCuts &cs, const CouenneCutGenerator *cg);
65
66  /// code for comparisons
67  virtual enum expr_type code () {return COU_EXPRMIN;}
68};
69
70
71/// compute maximum
72
73inline CouNumber exprMin::operator () () {
74
75  CouNumber best_val = (*(arglist_ [0])) ();
76  int best_ind = 0;
77
78  for (int ind = 2; ind < nargs_; ind += 2) {
79
80    register CouNumber val = (*(arglist_ [ind])) ();
81
82    if (val < best_val) {
83      best_ind = ind;
84      best_val = val;
85    }
86  }
87
88  best_val = (*(arglist_ [best_ind + 1])) ();
89
90  return (currValue_ = best_val);
91  /*
92  exprOp:: operator () ();
93
94  register CouNumber best_val = *sp--;
95  register CouNumber best_el  = *sp--;
96
97  int n = nargs_ / 2;
98
99  while (--n) {
100
101    register CouNumber val = *sp--;
102    register CouNumber el  = *sp--;
103
104    if (el < best_el) {
105      best_el  = el;
106      best_val = val;
107    }
108  }
109
110  return (currValue_ = best_val);
111  */
112}
113
114#endif
Note: See TracBrowser for help on using the repository browser.