source: trunk/Bonmin/src/IpoptInterface/IpCbcStartPointReader.cpp @ 1

Last change on this file since 1 was 1, checked in by andreasw, 13 years ago

imported initial code

  • Property svn:eol-style set to native
  • Property svn:keywords set to "Author Date Id Revision"
File size: 1.1 KB
Line 
1// (C) Copyright Carnegie Mellon University 2005
2// All Rights Reserved.
3// This code is published under the Common Public License.
4//
5// Authors :
6// Pierre Bonami, Carnegie Mellon University,
7//
8// Date : 26/05/2005
9#include "IpCbcStartPointReader.hpp"
10
11
12
13
14bool IpCbcStartPointReader::readFile()
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;
24  gutsOfDestructor();
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
36bool IpCbcStartPointReader::readAndApply(IpoptInterface& solver)
37{
38  readFile();
39  solver.setWarmStartOptions();
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}
Note: See TracBrowser for help on using the repository browser.