/home/coin/SVN-release/OS-2.4.0/Bonmin/src/Apps/BonMin.cpp

Go to the documentation of this file.
00001 // (C) Copyright International Business Machines Corporation and Carnegie Mellon University 2006, 2007
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // Authors :
00006 // Andreas Waechter, International Business Machines Corporation
00007 // Pierre Bonami, Carnegie Mellon University,
00008 //
00009 // Date : 02/15/2006
00010 
00011 
00012 #include <iomanip>
00013 #include <fstream>
00014 
00015 #include "CoinPragma.hpp"
00016 #include "BonminConfig.h"
00017 #include "IpoptConfig.h"
00018 #include "CbcConfig.h"
00019 #include "CoinTime.hpp"
00020 #include "BonAmplSetup.hpp"
00021 #include "BonCbc.hpp"
00022 
00023 #ifndef NDEBUG
00024 #define CATCH_ERRORS
00025 #endif
00026 
00027 using namespace Bonmin;
00028 int main (int argc, char *argv[])
00029 {
00030   using namespace Ipopt;
00031   char * pbName = NULL;
00032   
00033   std::cout<<"Bonmin "
00034            <<BONMIN_VERSION; 
00035   std::cout<<" using Cbc "
00036          <<CBC_VERSION; 
00037   std::cout<<" and Ipopt "
00038          <<IPOPT_VERSION<<std::endl; 
00039   if(argc > 1) {
00040     pbName = new char[strlen(argv[1])+1];
00041     strcpy(pbName, argv[1]);
00042   }
00043 #define CATCH_ERRORS 
00044 #ifdef CATCH_ERRORS
00045   try
00046 #endif 
00047   {
00048 
00049     //FILE * fp = fopen("log","w");
00050     BonminAmplSetup bonmin;
00051     bonmin.initialize(argv);
00052 
00053     {
00054     Bab bb;
00055 
00056     bb(bonmin);//do branch and bound
00057     }
00058   }
00059 #ifdef CATCH_ERRORS
00060   catch(TNLPSolver::UnsolvedError *E) {
00061     E->writeDiffFiles();
00062     E->printError(std::cerr);
00063     //There has been a failure to solve a problem with Ipopt.
00064     //And we will output file with information on what has been changed in the problem to make it fail.
00065     //Now depending on what algorithm has been called (B-BB or other) the failed problem may be at different place.
00066     //    const OsiSolverInterface &si1 = (algo > 0) ? nlpSolver : *model.solver();
00067   }
00068   catch(OsiTMINLPInterface::SimpleError &E) {
00069     std::cerr<<E.className()<<"::"<<E.methodName()
00070     <<std::endl
00071     <<E.message()<<std::endl;
00072   }
00073   catch(CoinError &E) {
00074     std::cerr<<E.className()<<"::"<<E.methodName()
00075     <<std::endl
00076     <<E.message()<<std::endl;
00077   }
00078   catch (Ipopt::OPTION_INVALID &E)
00079   {
00080     std::cerr<<"Ipopt exception : "<<E.Message()<<std::endl;
00081   }
00082   catch (Ipopt::IpoptException &E)
00083   {
00084     std::cerr<<"Ipopt exception : "<<E.Message()<<std::endl;
00085   }
00086   catch(...) {
00087     std::cerr<<pbName<<" unrecognized exception"<<std::endl;
00088     std::cerr<<pbName<<"\t Finished \t exception"<<std::endl;
00089     throw;
00090   }
00091 #endif
00092   
00093   delete [] pbName;
00094   return 0;
00095 }
00096 

Generated on Thu Sep 22 03:05:54 2011 by  doxygen 1.4.7