/home/coin/SVN-release/OS-2.2.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 #if defined(_MSC_VER)
00013 // Turn off compiler warning about long names
00014 #  pragma warning(disable:4786)
00015 #endif
00016 #include <iomanip>
00017 #include <fstream>
00018 
00019 #include "CoinTime.hpp"
00020 #include "BonAmplSetup.hpp"
00021 #include "BonCbc.hpp"
00022 #include "BonVersions.hpp"
00023 #define CATCH_ERRORS
00024 using namespace Bonmin;
00025 int main (int argc, char *argv[])
00026 {
00027   using namespace Ipopt;
00028   char * pbName = NULL;
00029   
00030   std::cout<<"Bonmin "
00031            <<BONMIN_VERSION; 
00032   std::cout<<" using Cbc "
00033          <<CBCVERSION; 
00034   std::cout<<" and Ipopt "
00035          <<IPOPT_VERSION<<std::endl; 
00036   if(argc > 1) {
00037     pbName = new char[strlen(argv[1])+1];
00038     strcpy(pbName, argv[1]);
00039   }
00040 #define CATCH_ERRORS 
00041 #ifdef CATCH_ERRORS
00042   try
00043 #endif 
00044   {
00045 
00046     //FILE * fp = fopen("log","w");
00047     BonminAmplSetup bonmin;
00048     bonmin.initialize(argv);
00049     Bab bb;
00050 
00051     bb(bonmin);//do branch and bound
00052 
00053   }
00054 #ifdef CATCH_ERRORS
00055   catch(TNLPSolver::UnsolvedError *E) {
00056     E->writeDiffFiles();
00057     E->printError(std::cerr);
00058     //There has been a failure to solve a problem with Ipopt.
00059     //And we will output file with information on what has been changed in the problem to make it fail.
00060     //Now depending on what algorithm has been called (B-BB or other) the failed problem may be at different place.
00061     //    const OsiSolverInterface &si1 = (algo > 0) ? nlpSolver : *model.solver();
00062   }
00063   catch(OsiTMINLPInterface::SimpleError &E) {
00064     std::cerr<<E.className()<<"::"<<E.methodName()
00065     <<std::endl
00066     <<E.message()<<std::endl;
00067   }
00068   catch(CoinError &E) {
00069     std::cerr<<E.className()<<"::"<<E.methodName()
00070     <<E.message()<<std::endl;
00071   }
00072   catch (Ipopt::OPTION_INVALID &E)
00073   {
00074     std::cerr<<"Ipopt exception : "<<E.Message()<<std::endl;
00075   }
00076   catch (Ipopt::IpoptException &E)
00077   {
00078     std::cerr<<"Ipopt exception : "<<E.Message()<<std::endl;
00079   }
00080   catch(...) {
00081     std::cerr<<pbName<<" unrecognized exception"<<std::endl;
00082     std::cerr<<pbName<<"\t Finished \t exception"<<std::endl;
00083     throw;
00084   }
00085 #endif
00086   
00087   delete [] pbName;
00088   return 0;
00089 }
00090 

Generated on Thu Aug 5 03:02:54 2010 by  doxygen 1.4.7