CouenneGlobalCutOff.cpp
Go to the documentation of this file.
1 /* $Id: CouenneGlobalCutOff.cpp 560 2011-04-17 10:01:15Z stefan $
2  *
3  * Name: CouenneGlobalCutOff.cpp
4  * Author: Pietro Belotti, Lehigh University
5  * Andreas Waechter, IBM
6  * Purpose: a cutoff that replicates itself, implementation
7  *
8  * (C) Carnegie-Mellon University, 2010.
9  * This file is licensed under the Eclipse Public License (EPL)
10  */
11 
12 #include "CouenneGlobalCutOff.hpp"
13 
14 #include "CoinFinite.hpp"
15 #include "CoinHelperFunctions.hpp"
16 
17 using namespace Couenne;
18 
20  cutoff_ (COIN_DBL_MAX),
21  sol_ (NULL),
22  size_ (0),
23  valid_ (false) {}
24 
25 GlobalCutOff::GlobalCutOff (double c, const double *s, int n):
26  cutoff_ (c),
27  sol_ (NULL),
28  size_ (n),
29  valid_ (false) {
30  if (s) {
31  sol_ = CoinCopyOfArray (s, n);
32  size_ = n;
33  valid_ = true;
34  }
35 }
36 
37 
39 {if (sol_) delete [] sol_;}
40 
41 
42 void GlobalCutOff::setCutOff (const CouenneProblem *p, double cutoff, const double *s) {
43 
44  cutoff_ = cutoff;
45 
46  valid_ = (s != NULL);
47 
48  if (s) {
49 
50  if (!sol_)
51  sol_ = new CouNumber [size_ = p -> nVars ()];
52 
53  CoinCopyN (s, p -> nOrigVars (), sol_); // fill first variables with values from NLP
54  CoinFillN (sol_ + p -> nOrigVars (), p -> nVars () - p -> nOrigVars (), 0.); // pad with zeros
55 
56  p -> getAuxs (sol_);
57  }
58 }
bool valid_
Stored solution corresponds to cutoff.
double * sol_
Best solution.
Class for MINLP problems with symbolic information.
void fint fint fint fint fint fint fint fint fint fint real real real real real real real real * s
double CouNumber
main number type in Couenne
int size_
Size of the vector stored in sol (should be #var of reformulation)
void setCutOff(const CouenneProblem *p, double cutoff, const double *s=NULL)
double cutoff_
Value of the best solution.
void fint * n
real c