/home/coin/SVN-release/OS-1.1.1/Bonmin/experimental/Bcp/BM.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 // Laszlo Ladanyi, International Business Machines Corporation
00007 // Pierre Bonami, Carnegie Mellon University,
00008 //
00009 // Date : 03/15/2006
00010 #include <sstream>
00011 
00012 /* To get the cumulative time spent on a processor just use a gawk command
00013    like this below. Look at the output first; probably the process id needs
00014    to be prepended to the regexp and the procid may also change the $7 to
00015    some other word.
00016    gawk -e 'BEGIN {t=0} /^BCP_lp: Time spent in this node:/ {t+=$7} END {print t}' outfile
00017 */
00018 
00019 #include "BM.hpp"
00020 
00021 using namespace std;
00022 
00023 //#############################################################################
00024 
00025 int main(int argc, char* argv[])
00026 {
00027     CoinError::printErrors_ = true;
00028     BM_init user_init;
00029     int retcode = -1;
00030 #if 1
00031     retcode = bcp_main(argc, argv, &user_init);
00032 #else
00033     try {
00034       retcode = bcp_main(argc, argv, &user_init);
00035     }
00036     catch(Bonmin::TNLPSolver::UnsolvedError &E) {
00037       //      E.writeDiffFiles();
00038       E.printError(std::cerr);
00039    }
00040    catch(Bonmin::OsiTMINLPInterface::SimpleError &E) {
00041      std::cerr<<E.className()<<"::"<<E.methodName()
00042               <<std::endl
00043               <<E.message()<<std::endl;
00044    }
00045    catch(CoinError &E) {
00046      std::cerr<<E.className()<<"::"<<E.methodName()
00047               <<std::endl
00048               <<E.message()<<std::endl;
00049    }
00050    catch (Ipopt::OPTION_INVALID &E)
00051    {
00052     std::cerr<<"Ipopt exception : "<<E.Message()<<std::endl;
00053    }
00054    catch(...) {
00055      std::cerr<<" unrecognized exception"<<std::endl;
00056      throw;
00057    }
00058 #endif
00059 
00060     return retcode;
00061 }
00062 
00063 //#############################################################################
00064 
00065 template <>
00066 void BCP_parameter_set<BM_par>::create_keyword_list() {
00067     // Create the list of keywords for parameter file reading
00068     keys.push_back(make_pair(BCP_string("BM_DisregardPriorities"),
00069                              BCP_parameter(BCP_CharPar, DisregardPriorities)));
00070     keys.push_back(make_pair(BCP_string("BM_PrintBranchingInfo"),
00071                              BCP_parameter(BCP_CharPar, PrintBranchingInfo)));
00072     keys.push_back(make_pair(BCP_string("BM_UsePseudoCosts"),
00073                              BCP_parameter(BCP_IntPar, UsePseudoCosts)));
00074     keys.push_back(make_pair(BCP_string("BM_DecreasingSortInSetupList"),
00075                              BCP_parameter(BCP_IntPar, DecreasingSortInSetupList)));
00076     keys.push_back(make_pair(BCP_string("BM_PreferHighCombinationInBranching"),
00077                              BCP_parameter(BCP_IntPar, PreferHighCombinationInBranching)));
00078     keys.push_back(make_pair(BCP_string("BM_NumNlpFailureMax"),
00079                              BCP_parameter(BCP_IntPar, NumNlpFailureMax)));
00080     keys.push_back(make_pair(BCP_string("BM_NL_filename"),
00081                              BCP_parameter(BCP_StringPar, NL_filename)));
00082     keys.push_back(make_pair(BCP_string("BM_IpoptParamfile"),
00083                              BCP_parameter(BCP_StringPar, IpoptParamfile)));
00084 }
00085 
00086 /****************************************************************************/
00087 
00088 template <>
00089 void BCP_parameter_set<BM_par>::set_default_entries() {
00090     set_entry(DisregardPriorities, false);
00091     set_entry(PrintBranchingInfo, true);
00092     set_entry(UsePseudoCosts, 1);
00093     set_entry(DecreasingSortInSetupList, 1);
00094     set_entry(PreferHighCombinationInBranching, 0);
00095     set_entry(NumNlpFailureMax, 5);
00096     set_entry(NL_filename, "");
00097     set_entry(IpoptParamfile, "");
00098 }
00099 
00100 //#############################################################################
00101 
00102 BCP_lp_user *
00103 BM_init::lp_init(BCP_lp_prob& p)
00104 {
00105     return new BM_lp;
00106 }
00107 
00108 /****************************************************************************/
00109 
00110 BCP_tm_user *
00111 BM_init::tm_init(BCP_tm_prob& p,
00112                  const int argnum, const char * const * arglist)
00113 {
00114     BM_tm* tm = new BM_tm;
00115 
00116     if (argnum == 2) {
00117         tm->par.read_from_file(arglist[1]);
00118     } else if (argnum == 1) {
00119         // work with defaults
00120     } else {
00121         tm->par.read_from_arglist(argnum, arglist);
00122     }
00123 
00124     tm->readIpopt();
00125 
00126     return tm;
00127 }
00128 
00129 /****************************************************************************/
00130 
00131 BCP_user_pack *
00132 BM_init::packer_init(BCP_user_class* p)
00133 {
00134     return new BM_pack;
00135 }
00136 
00137 /****************************************************************************/
00138 
00139 BM_stats::~BM_stats()
00140 {
00141   // LACI: It would be nice to also print the process ID here, but I
00142   // wasn't sure how to get it...
00143 
00144   printf("Stats: #NodesSol = %d #SbSol = %d #Fixed = %d #SbDone = %d SumInd = %d SumPos = %e\n", numberNodeSolves_, numberSbSolves_, numberFixed_, numberStrongBranching_, sumStrongBranchingListIndices_, sumStrongBranchingListPositions_);
00145 }

Generated on Tue Sep 30 03:01:22 2008 by  doxygen 1.4.7