| 1 |
// (C) Copyright Carnegie Mellon University 2005 |
| 2 |
// All Rights Reserved. |
| 3 |
// This code is published under the Eclipse Public License. |
| 4 |
// |
| 5 |
// Authors : |
| 6 |
// Pierre Bonami, Carnegie Mellon University, |
| 7 |
// |
| 8 |
// Date : 26/05/2005 |
| 9 |
|
| 10 |
#ifndef BoundsReader_HPP |
| 11 |
#define BoundsReader_HPP |
| 12 |
|
| 13 |
#include <string> |
| 14 |
#include "BonOsiTMINLPInterface.hpp" |
| 15 |
|
| 16 |
|
| 17 |
namespace Bonmin { |
| 18 |
/** Reads a file containing change bounds for variables. |
| 19 |
Files follows pretty much the Bounds section in MPS standard.*/ |
| 20 |
class BoundsReader |
| 21 |
{ |
| 22 |
public: |
| 23 |
//Default constructor |
| 24 |
BoundsReader(): |
| 25 |
fileName_(), |
| 26 |
lowerBounds_(NULL), |
| 27 |
upperBounds_(NULL), |
| 28 |
nLower_(0), |
| 29 |
nUpper_(0) |
| 30 |
{} |
| 31 |
|
| 32 |
// Constructor with name of the file to read passed. |
| 33 |
BoundsReader(const std::string &fileName): |
| 34 |
fileName_(fileName), |
| 35 |
lowerBounds_(NULL), |
| 36 |
upperBounds_(NULL), |
| 37 |
indexLowers_(NULL), |
| 38 |
indexUppers_(NULL), |
| 39 |
nLower_(0), |
| 40 |
nUpper_(0) |
| 41 |
{} |
| 42 |
|
| 43 |
// Set the name of the file to read. |
| 44 |
void setFileName(const std::string &fileName) |
| 45 |
{ |
| 46 |
fileName_ = fileName; |
| 47 |
} |
| 48 |
|
| 49 |
// Destructor |
| 50 |
~BoundsReader(); |
| 51 |
|
| 52 |
// Cleanup allocated data |
| 53 |
void gutsOfDestructor(); |
| 54 |
|
| 55 |
|
| 56 |
// Read the file with given fileName |
| 57 |
void read(const std::string &); |
| 58 |
|
| 59 |
//Read the file named fileName_ |
| 60 |
void read(); |
| 61 |
|
| 62 |
//Read fileName_ and apply the bounds read to solver |
| 63 |
void readAndApply(OsiTMINLPInterface * solver); |
| 64 |
private: |
| 65 |
|
| 66 |
/// Current file |
| 67 |
std::string fileName_; |
| 68 |
/// changed lower bounds |
| 69 |
double * lowerBounds_; |
| 70 |
/// changed upper bounds |
| 71 |
double * upperBounds_; |
| 72 |
/// index of the changed lowerBounds_ |
| 73 |
int * indexLowers_; |
| 74 |
/// index of the changed upperBounds_ |
| 75 |
int * indexUppers_; |
| 76 |
/// number of changed lowerBounds_ |
| 77 |
int nLower_; |
| 78 |
/// number of changed upperBounds_ |
| 79 |
int nUpper_; |
| 80 |
}; |
| 81 |
} |
| 82 |
#endif |