| 1 |
// (C) Copyright CNRS and others 2010 |
| 2 |
// All Rights Reserved. |
| 3 |
// This code is published under the Eclipse Public License. |
| 4 |
// |
| 5 |
// Authors : |
| 6 |
// Pierre Bonami, Université de la Méditérannée |
| 7 |
// |
| 8 |
// Date : 05/22/2010 |
| 9 |
|
| 10 |
#include <iomanip> |
| 11 |
#include <fstream> |
| 12 |
|
| 13 |
#include "CoinPragma.hpp" |
| 14 |
#include "BonminConfig.h" |
| 15 |
#include "IpoptConfig.h" |
| 16 |
#include "CbcConfig.h" |
| 17 |
#include "CoinTime.hpp" |
| 18 |
#include "RobotSetup.hpp" |
| 19 |
#include "BonCbc.hpp" |
| 20 |
|
| 21 |
#define CATCH_ERRORS |
| 22 |
using namespace Bonmin; |
| 23 |
int main (int argc, char *argv[]) |
| 24 |
{ |
| 25 |
using namespace Ipopt; |
| 26 |
char * pbName = NULL; |
| 27 |
|
| 28 |
std::cout<<"Bonmin " |
| 29 |
<<BONMIN_VERSION; |
| 30 |
std::cout<<" using Cbc " |
| 31 |
<<CBC_VERSION; |
| 32 |
std::cout<<" and Ipopt " |
| 33 |
<<IPOPT_VERSION<<std::endl; |
| 34 |
if(argc > 1) { |
| 35 |
pbName = new char[strlen(argv[1])+1]; |
| 36 |
strcpy(pbName, argv[1]); |
| 37 |
} |
| 38 |
#ifdef CATCH_ERRORS |
| 39 |
try |
| 40 |
#endif |
| 41 |
{ |
| 42 |
|
| 43 |
//FILE * fp = fopen("log","w"); |
| 44 |
RobotSetup bonmin; |
| 45 |
bonmin.initialize(argv); |
| 46 |
Bab bb; |
| 47 |
|
| 48 |
bb(bonmin);//do branch and bound |
| 49 |
|
| 50 |
} |
| 51 |
#ifdef CATCH_ERRORS |
| 52 |
catch(TNLPSolver::UnsolvedError *E) { |
| 53 |
E->writeDiffFiles(); |
| 54 |
E->printError(std::cerr); |
| 55 |
//There has been a failure to solve a problem with Ipopt. |
| 56 |
//And we will output file with information on what has been changed in the problem to make it fail. |
| 57 |
//Now depending on what algorithm has been called (B-BB or other) the failed problem may be at different place. |
| 58 |
// const OsiSolverInterface &si1 = (algo > 0) ? nlpSolver : *model.solver(); |
| 59 |
} |
| 60 |
catch(OsiTMINLPInterface::SimpleError &E) { |
| 61 |
std::cerr<<E.className()<<"::"<<E.methodName() |
| 62 |
<<std::endl |
| 63 |
<<E.message()<<std::endl; |
| 64 |
} |
| 65 |
catch(CoinError &E) { |
| 66 |
std::cerr<<E.className()<<"::"<<E.methodName() |
| 67 |
<<std::endl |
| 68 |
<<E.message()<<std::endl; |
| 69 |
} |
| 70 |
catch (Ipopt::OPTION_INVALID &E) |
| 71 |
{ |
| 72 |
std::cerr<<"Ipopt exception : "<<E.Message()<<std::endl; |
| 73 |
} |
| 74 |
catch (Ipopt::IpoptException &E) |
| 75 |
{ |
| 76 |
std::cerr<<"Ipopt exception : "<<E.Message()<<std::endl; |
| 77 |
} |
| 78 |
catch(...) { |
| 79 |
std::cerr<<pbName<<" unrecognized exception"<<std::endl; |
| 80 |
std::cerr<<pbName<<"\t Finished \t exception"<<std::endl; |
| 81 |
throw; |
| 82 |
} |
| 83 |
#endif |
| 84 |
|
| 85 |
delete [] pbName; |
| 86 |
return 0; |
| 87 |
} |
| 88 |
|