/home/coin/SVN-release/OS-2.4.1/Couenne/src/problem/CouenneGlobalCutOff.cpp

Go to the documentation of this file.
00001 /* $Id: CouenneGlobalCutOff.cpp 560 2011-04-17 10:01:15Z stefan $
00002  *
00003  * Name:    CouenneGlobalCutOff.cpp
00004  * Author:  Pietro Belotti, Lehigh University
00005  *          Andreas Waechter, IBM
00006  * Purpose: a cutoff that replicates itself, implementation
00007  *
00008  * (C) Carnegie-Mellon University, 2010.
00009  * This file is licensed under the Eclipse Public License (EPL)
00010  */
00011 
00012 #include "CouenneGlobalCutOff.hpp"
00013 
00014 #include "CoinFinite.hpp"
00015 #include "CoinHelperFunctions.hpp"
00016 
00017 using namespace Couenne;
00018 
00019 GlobalCutOff::GlobalCutOff (): 
00020   cutoff_ (COIN_DBL_MAX), 
00021   sol_    (NULL), 
00022   size_   (0), 
00023   valid_  (false) {}
00024 
00025 GlobalCutOff::GlobalCutOff (double c, const double *s, int n): 
00026   cutoff_ (c),
00027   sol_    (NULL),
00028   size_   (n),
00029   valid_  (false) {
00030   if (s) {
00031     sol_   = CoinCopyOfArray (s, n);
00032     size_  = n;
00033     valid_ = true;
00034   }
00035 }
00036 
00037 
00038 GlobalCutOff::~GlobalCutOff () 
00039 {if (sol_) delete [] sol_;}
00040 
00041 
00042 void GlobalCutOff::setCutOff (const CouenneProblem *p, double cutoff, const double *s) {
00043 
00044   cutoff_ = cutoff;
00045 
00046   valid_ = (s != NULL);
00047 
00048   if (s) {
00049 
00050     if (!sol_) 
00051       sol_ = new CouNumber [size_ = p -> nVars ()];
00052 
00053     CoinCopyN (s, p -> nOrigVars (), sol_); // fill first variables with values from NLP
00054     CoinFillN (sol_ + p -> nOrigVars (), p -> nVars () - p -> nOrigVars (), 0.); // pad with zeros
00055 
00056     p -> getAuxs (sol_);
00057   }
00058 }

Generated on Thu Nov 10 03:05:45 2011 by  doxygen 1.4.7