| 1 |
// (C) Copyright International Business Machines Corporation and Carnegie Mellon University 2006, 2007 |
| 2 |
// All Rights Reserved. |
| 3 |
// This code is published under the Eclipse Public License. |
| 4 |
// |
| 5 |
// Authors : |
| 6 |
// Laszlo Ladanyi, International Business Machines Corporation |
| 7 |
// Pierre Bonami, Carnegie Mellon University, |
| 8 |
// |
| 9 |
// Date : 03/15/2006 |
| 10 |
#include <sstream> |
| 11 |
|
| 12 |
/* To get the cumulative time spent on a processor just use a gawk command |
| 13 |
like this below. Look at the output first; probably the process id needs |
| 14 |
to be prepended to the regexp and the procid may also change the $7 to |
| 15 |
some other word. |
| 16 |
gawk -e 'BEGIN {t=0} /^BCP_lp: Time spent in this node:/ {t+=$7} END {print t}' outfile |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "BM.hpp" |
| 20 |
|
| 21 |
using namespace std; |
| 22 |
|
| 23 |
//############################################################################# |
| 24 |
|
| 25 |
int main(int argc, char* argv[]) |
| 26 |
{ |
| 27 |
CoinError::printErrors_ = true; |
| 28 |
BM_init user_init; |
| 29 |
int retcode = -1; |
| 30 |
#if 1 |
| 31 |
retcode = bcp_main(argc, argv, &user_init); |
| 32 |
#else |
| 33 |
try { |
| 34 |
retcode = bcp_main(argc, argv, &user_init); |
| 35 |
} |
| 36 |
catch(Bonmin::TNLPSolver::UnsolvedError &E) { |
| 37 |
// E.writeDiffFiles(); |
| 38 |
E.printError(std::cerr); |
| 39 |
} |
| 40 |
catch(Bonmin::OsiTMINLPInterface::SimpleError &E) { |
| 41 |
std::cerr<<E.className()<<"::"<<E.methodName() |
| 42 |
<<std::endl |
| 43 |
<<E.message()<<std::endl; |
| 44 |
} |
| 45 |
catch(CoinError &E) { |
| 46 |
std::cerr<<E.className()<<"::"<<E.methodName() |
| 47 |
<<std::endl |
| 48 |
<<E.message()<<std::endl; |
| 49 |
} |
| 50 |
catch (Ipopt::OPTION_INVALID &E) |
| 51 |
{ |
| 52 |
std::cerr<<"Ipopt exception : "<<E.Message()<<std::endl; |
| 53 |
} |
| 54 |
catch(...) { |
| 55 |
std::cerr<<" unrecognized exception"<<std::endl; |
| 56 |
throw; |
| 57 |
} |
| 58 |
#endif |
| 59 |
|
| 60 |
return retcode; |
| 61 |
} |
| 62 |
|
| 63 |
//############################################################################# |
| 64 |
|
| 65 |
template <> |
| 66 |
void BCP_parameter_set<BM_par>::create_keyword_list() { |
| 67 |
// Create the list of keywords for parameter file reading |
| 68 |
keys.push_back(make_pair(BCP_string("BM_DisregardPriorities"), |
| 69 |
BCP_parameter(BCP_CharPar, DisregardPriorities))); |
| 70 |
keys.push_back(make_pair(BCP_string("BM_PrintBranchingInfo"), |
| 71 |
BCP_parameter(BCP_CharPar, PrintBranchingInfo))); |
| 72 |
keys.push_back(make_pair(BCP_string("BM_UsePseudoCosts"), |
| 73 |
BCP_parameter(BCP_IntPar, UsePseudoCosts))); |
| 74 |
keys.push_back(make_pair(BCP_string("BM_DecreasingSortInSetupList"), |
| 75 |
BCP_parameter(BCP_IntPar, DecreasingSortInSetupList))); |
| 76 |
keys.push_back(make_pair(BCP_string("BM_PreferHighCombinationInBranching"), |
| 77 |
BCP_parameter(BCP_IntPar, PreferHighCombinationInBranching))); |
| 78 |
keys.push_back(make_pair(BCP_string("BM_NumNlpFailureMax"), |
| 79 |
BCP_parameter(BCP_IntPar, NumNlpFailureMax))); |
| 80 |
keys.push_back(make_pair(BCP_string("BM_NL_filename"), |
| 81 |
BCP_parameter(BCP_StringPar, NL_filename))); |
| 82 |
keys.push_back(make_pair(BCP_string("BM_IpoptParamfile"), |
| 83 |
BCP_parameter(BCP_StringPar, IpoptParamfile))); |
| 84 |
} |
| 85 |
|
| 86 |
/****************************************************************************/ |
| 87 |
|
| 88 |
template <> |
| 89 |
void BCP_parameter_set<BM_par>::set_default_entries() { |
| 90 |
set_entry(DisregardPriorities, false); |
| 91 |
set_entry(PrintBranchingInfo, true); |
| 92 |
set_entry(UsePseudoCosts, 1); |
| 93 |
set_entry(DecreasingSortInSetupList, 1); |
| 94 |
set_entry(PreferHighCombinationInBranching, 0); |
| 95 |
set_entry(NumNlpFailureMax, 5); |
| 96 |
set_entry(NL_filename, ""); |
| 97 |
set_entry(IpoptParamfile, ""); |
| 98 |
} |
| 99 |
|
| 100 |
//############################################################################# |
| 101 |
|
| 102 |
BCP_lp_user * |
| 103 |
BM_init::lp_init(BCP_lp_prob& p) |
| 104 |
{ |
| 105 |
return new BM_lp; |
| 106 |
} |
| 107 |
|
| 108 |
/****************************************************************************/ |
| 109 |
|
| 110 |
BCP_tm_user * |
| 111 |
BM_init::tm_init(BCP_tm_prob& p, |
| 112 |
const int argnum, const char * const * arglist) |
| 113 |
{ |
| 114 |
BM_tm* tm = new BM_tm; |
| 115 |
|
| 116 |
if (argnum == 2) { |
| 117 |
tm->par.read_from_file(arglist[1]); |
| 118 |
} else if (argnum == 1) { |
| 119 |
// work with defaults |
| 120 |
} else { |
| 121 |
tm->par.read_from_arglist(argnum, arglist); |
| 122 |
} |
| 123 |
|
| 124 |
tm->readIpopt(); |
| 125 |
|
| 126 |
return tm; |
| 127 |
} |
| 128 |
|
| 129 |
/****************************************************************************/ |
| 130 |
|
| 131 |
BCP_user_pack * |
| 132 |
BM_init::packer_init(BCP_user_class* p) |
| 133 |
{ |
| 134 |
return new BM_pack; |
| 135 |
} |
| 136 |
|
| 137 |
/****************************************************************************/ |
| 138 |
|
| 139 |
BM_stats::~BM_stats() |
| 140 |
{ |
| 141 |
// LACI: It would be nice to also print the process ID here, but I |
| 142 |
// wasn't sure how to get it... |
| 143 |
|
| 144 |
printf("Stats: #NodesSol = %d #SbSol = %d #Fixed = %d #SbDone = %d SumInd = %d SumPos = %e\n", numberNodeSolves_, numberSbSolves_, numberFixed_, numberStrongBranching_, sumStrongBranchingListIndices_, sumStrongBranchingListPositions_); |
| 145 |
} |