BM.cpp
Go to the documentation of this file.
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  }
37  // E.writeDiffFiles();
38  E.printError(std::cerr);
39  }
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 <>
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 <>
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 *
104 {
105  return new BM_lp;
106 }
107 
108 /****************************************************************************/
109 
110 BCP_tm_user *
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 
133 {
134  return new BM_pack;
135 }
136 
137 /****************************************************************************/
138 
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 }
Character parameter.
void create_keyword_list()
Method for creating the list of keyword looked for in the parameter file.
int main(int argc, char *argv[])
Definition: BB_tm.cpp:32
~BM_stats()
Definition: BM.cpp:139
virtual BCP_tm_user * tm_init(BCP_tm_prob &p, const int argnum, const char *const *arglist)
Definition: BM.cpp:111
NO OLD DOC.
Definition: BCP_lp.hpp:102
void set_default_entries()
Method for setting the default values for the parameters.
void read_from_arglist(const int argnum, const char *const *arglist)
Simply invoke reading from a stream.
This class is a very simple impelementation of a constant length string.
Definition: BCP_string.hpp:13
String parameter.
The BCP_lp_user class is the base class from which the user can derive a problem specific class to be...
Definition: BCP_lp_user.hpp:75
Definition: BM.hpp:273
int bcp_main(int argc, char *argv[], USER_initialize *user_init)
This is the function the user must invoke when (s)he is ready to turn contrl over to BCP...
Definition: BCP_tm_main.cpp:37
Definition: BM.hpp:446
Error class to throw exceptions from OsiTMINLPInterface.
virtual BCP_lp_user * lp_init(BCP_lp_prob &p)
Definition: BM.cpp:103
virtual BCP_user_pack * packer_init(BCP_user_class *p)
Definition: BM.cpp:132
void read_from_file(const char *paramfile)
Simply invoke reading from a stream.
NO OLD DOC.
Definition: BCP_tm.hpp:136
void printError(std::ostream &os)
Print error message.
This parameter indeintifies a single parameter entry.
Definition: BM.hpp:170
Definition: BM.hpp:460
BCP_parameter_set< BM_par > par
Definition: BM.hpp:177
We will throw this error when a problem is not solved.
Integer parameter.
The BCP_tm_user class is the base class from which the user can derive a problem specific class to be...
Definition: BCP_tm_user.hpp:58
void readIpopt()
Definition: BM_tm.cpp:29