BonStartPointReader.cpp
Go to the documentation of this file.
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
10 
11 
12 namespace Bonmin {
13 
15  {
16  std::ifstream inFile(fileName_.c_str());
17  if(!inFile.is_open()) {
18  std::cerr<<"Error in opening initial point file";
19  return false;
20  }
21  int numPrimals;
22  int numDuals;
23  inFile>>numPrimals>>numDuals;
25  primals_ = new double [numPrimals];
26  duals_ = new double[numDuals];
27  for(int i = 0; i < numPrimals ; i++) {
28  inFile>>primals_[i];
29  }
30  for(int i = 0; i < numDuals ; i++) {
31  inFile>>duals_[i];
32  }
33  return true;
34  }
35 
37  {
38  readFile();
39  solver->solver()->enableWarmStart();
40  if(primals_)
41  solver->setColSolution(primals_);
42  else {
43  std::cerr<<"No warm start info ???"<<std::endl;
44  return 0;
45  }
46  if(duals_)
47  solver->setRowPrice(duals_);
48  else {
49  std::cerr<<"No warm start info ???"<<std::endl;
50  return 0;
51  }
52  return 1;
53  }
54 }
std::string fileName_
Name of the file with initial point.
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
void gutsOfDestructor()
Dealocate arrays.
double * primals_
Primal variables values.
bool readAndApply(OsiTMINLPInterface *solver)
Read warmstart info and apply to an IpoptInterface.
bool readFile()
Reads the .initP file.
const Bonmin::TNLPSolver * solver() const
double * duals_
Dual variables values.
virtual void setColSolution(const double *colsol)
Set the primal solution variable values Set the values for the starting point.
virtual void enableWarmStart()=0
Enable the warm start options in the solver.
virtual void setRowPrice(const double *rowprice)
Set dual solution variable values.