source: trunk/Bonmin/src/Apps/BonMin.cpp @ 1721

Last change on this file since 1721 was 1721, checked in by pbonami, 9 years ago

Update to Cbc-2.5

  • Property svn:eol-style set to native
  • Property svn:keywords set to "Author Date Id Revision"
File size: 2.3 KB
Line 
1// (C) Copyright International Business Machines Corporation and Carnegie Mellon University 2006, 2007
2// All Rights Reserved.
3// This code is published under the Common Public License.
4//
5// Authors :
6// Andreas Waechter, International Business Machines Corporation
7// Pierre Bonami, Carnegie Mellon University,
8//
9// Date : 02/15/2006
10
11
12#if defined(_MSC_VER)
13// Turn off compiler warning about long names
14#  pragma warning(disable:4786)
15#endif
16#include <iomanip>
17#include <fstream>
18
19#include "CoinTime.hpp"
20#include "BonAmplSetup.hpp"
21#include "BonCbc.hpp"
22#include "BonVersions.hpp"
23#define CATCH_ERRORS
24using namespace Bonmin;
25int main (int argc, char *argv[])
26{
27  using namespace Ipopt;
28  char * pbName = NULL;
29 
30  std::cout<<"Bonmin "
31           <<BONMIN_VERSION; 
32  std::cout<<" using Cbc "
33         <<CBC_VERSION; 
34  std::cout<<" and Ipopt "
35         <<IPOPT_VERSION<<std::endl; 
36  if(argc > 1) {
37    pbName = new char[strlen(argv[1])+1];
38    strcpy(pbName, argv[1]);
39  }
40#define CATCH_ERRORS
41#ifdef CATCH_ERRORS
42  try
43#endif
44  {
45
46    //FILE * fp = fopen("log","w");
47    BonminAmplSetup bonmin;
48    bonmin.initialize(argv);
49    Bab bb;
50
51    bb(bonmin);//do branch and bound
52
53  }
54#ifdef CATCH_ERRORS
55  catch(TNLPSolver::UnsolvedError *E) {
56    E->writeDiffFiles();
57    E->printError(std::cerr);
58    //There has been a failure to solve a problem with Ipopt.
59    //And we will output file with information on what has been changed in the problem to make it fail.
60    //Now depending on what algorithm has been called (B-BB or other) the failed problem may be at different place.
61    //    const OsiSolverInterface &si1 = (algo > 0) ? nlpSolver : *model.solver();
62  }
63  catch(OsiTMINLPInterface::SimpleError &E) {
64    std::cerr<<E.className()<<"::"<<E.methodName()
65    <<std::endl
66    <<E.message()<<std::endl;
67  }
68  catch(CoinError &E) {
69    std::cerr<<E.className()<<"::"<<E.methodName()
70    <<std::endl
71    <<E.message()<<std::endl;
72  }
73  catch (Ipopt::OPTION_INVALID &E)
74  {
75    std::cerr<<"Ipopt exception : "<<E.Message()<<std::endl;
76  }
77  catch (Ipopt::IpoptException &E)
78  {
79    std::cerr<<"Ipopt exception : "<<E.Message()<<std::endl;
80  }
81  catch(...) {
82    std::cerr<<pbName<<" unrecognized exception"<<std::endl;
83    std::cerr<<pbName<<"\t Finished \t exception"<<std::endl;
84    throw;
85  }
86#endif
87 
88  delete [] pbName;
89  return 0;
90}
91
Note: See TracBrowser for help on using the repository browser.