CouenneRestoreUnused.cpp
Go to the documentation of this file.
1 /* $Id: CouenneRestoreUnused.cpp 899 2012-08-15 12:48:27Z pbelotti $
2  *
3  * Name: CouenneRestoreUnused.cpp
4  * Authors: Pietro Belotti, Lehigh University
5  * Purpose: Restore a consistent value of duplicate variables
6  *
7  * This file is licensed under the Eclipse Public License (EPL)
8  */
9 
10 #include "CouenneProblem.hpp"
11 #include "CouenneExprVar.hpp"
12 
13 using namespace Couenne;
14 
20 
21  if (nUnusedOriginals_ < 0) { // no structure yet, identify and store
22 
24 
25  int
26  nOrig = nOrigVars (),
27  nvars = nVars ();
28 
29  unusedOriginalsIndices_ = (int *) malloc (nvars * sizeof (int)); // will trim it later
30 
31  for (int i=0; i<nvars; i++) {
32 
33  int indVar = numbering_ [i];
34 
35  if ((indVar < nOrig) &&
36  (variables_ [indVar] -> Multiplicity () <= 0)) // found neglected variable!
38  }
39 
42  nUnusedOriginals_ * sizeof (int));
43  else {
46  }
47  }
48 }
49 
50 
55 
56  if (nUnusedOriginals_ <= 0) return;
57 
58  if (x)
59  domain_.push (nVars(), x,
60  domain_. current () -> lb (),
61  domain_. current () -> ub (), false); // no need for another copy
62 
63  for (int i=0; i<nUnusedOriginals_; i++) {
64 
65  int indVar = unusedOriginalsIndices_ [i];
66  expression *img = variables_ [indVar] -> Image ();
67 
68  if (img) {
69 
70  CouNumber value = (*img) ();
71 
72  X (indVar) = value;
73 
74  if (x)
75  x [indVar] = value;
76  }
77  }
78 
79  if (x)
80  domain_. pop ();
81 }
int nVars() const
Total number of variables.
int nUnusedOriginals_
number of unused originals
void restoreUnusedOriginals(CouNumber *=NULL) const
Some originals may be unused due to their zero multiplicity (that happens when they are duplicates)...
std::vector< exprVar * > variables_
Variables (original, auxiliary, and defined)
int nOrigVars() const
Number of orig. variables.
Domain domain_
current point and bounds;
int * numbering_
numbering of variables.
double CouNumber
main number type in Couenne
CouNumber * X() const
Return vector of variables.
void createUnusedOriginals()
Some originals may be unused due to their zero multiplicity (that happens when they are duplicates)...
void push(int dim, CouNumber *x, CouNumber *lb, CouNumber *ub, bool copy=true)
save current point and start using another
Definition: domain.cpp:166
int * unusedOriginalsIndices_
some originals may be unused due to their zero multiplicity (that happens when they are duplicates)...
Expression base class.
void fint fint fint real fint real * x