source: trunk/Bonmin/experimental/Bcp/BM.cpp @ 530

Last change on this file since 530 was 530, checked in by ladanyi, 13 years ago

prepare Bcp for changing some LPs into TM storage places. Serial version works, currently debugging parallel version.

  • Property svn:eol-style set to native
  • Property svn:keywords set to "Author Date Id Revision"
File size: 4.4 KB
Line 
1// (C) Copyright International Business Machines Corporation and Carnegie Mellon University 2006, 2007
2// All Rights Reserved.
3// This code is published under the Common 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
21using namespace std;
22
23//#############################################################################
24
25int main(int argc, char* argv[])
26{
27    CoinError::printErrors_ = true;
28    BM_init user_init;
29    int retcode = -1;
30    try {
31      retcode = bcp_main(argc, argv, &user_init);
32    }
33    catch(Bonmin::TNLPSolver::UnsolvedError &E) {
34      E.writeDiffFiles();
35      E.printError(std::cerr);
36   }
37   catch(Bonmin::OsiTMINLPInterface::SimpleError &E) {
38     std::cerr<<E.className()<<"::"<<E.methodName()
39              <<std::endl
40              <<E.message()<<std::endl;
41   }
42   catch(CoinError &E) {
43     std::cerr<<E.className()<<"::"<<E.methodName()
44              <<std::endl
45              <<E.message()<<std::endl;
46   }
47   catch (Ipopt::OPTION_INVALID &E)
48   {
49    std::cerr<<"Ipopt exception : "<<E.Message()<<std::endl;
50   }
51   catch(...) {
52     std::cerr<<" unrecognized exception"<<std::endl;
53     throw;
54   }
55
56    return retcode;
57}
58
59//#############################################################################
60
61template <>
62void BCP_parameter_set<BM_par>::create_keyword_list() {
63    // Create the list of keywords for parameter file reading
64    keys.push_back(make_pair(BCP_string("BranchingStrategy"),
65                             BCP_parameter(BCP_IntPar, BranchingStrategy)));
66    keys.push_back(make_pair(BCP_string("FullStrongBranch"),
67                             BCP_parameter(BCP_IntPar, FullStrongBranch)));
68    keys.push_back(make_pair(BCP_string("PrintBranchingInfo"),
69                             BCP_parameter(BCP_CharPar, PrintBranchingInfo)));
70    keys.push_back(make_pair(BCP_string("CombinedDistanceAndPriority"),
71                             BCP_parameter(BCP_CharPar,
72                                           CombinedDistanceAndPriority)));
73    keys.push_back(make_pair(BCP_string("SosWithLowPriorityMoreImportant"),
74                             BCP_parameter(BCP_CharPar,
75                                           SosWithLowPriorityMoreImportant)));
76    keys.push_back(make_pair(BCP_string("VarWithLowPriorityMoreImportant"),
77                             BCP_parameter(BCP_CharPar,
78                                           VarWithLowPriorityMoreImportant)));
79    keys.push_back(make_pair(BCP_string("NumNlpFailureMax"),
80                             BCP_parameter(BCP_IntPar, NumNlpFailureMax)));
81    keys.push_back(make_pair(BCP_string("WarmStartStrategy"),
82                             BCP_parameter(BCP_IntPar, WarmStartStrategy)));
83    keys.push_back(make_pair(BCP_string("NL_filename"),
84                             BCP_parameter(BCP_StringPar, NL_filename)));
85    keys.push_back(make_pair(BCP_string("IpoptParamfile"),
86                             BCP_parameter(BCP_StringPar, IpoptParamfile)));
87}
88
89/****************************************************************************/
90
91template <>
92void BCP_parameter_set<BM_par>::set_default_entries() {
93    set_entry(BranchingStrategy, BM_OsiChooseStrong);
94    set_entry(FullStrongBranch, 0);
95    set_entry(PrintBranchingInfo, true);
96    set_entry(CombinedDistanceAndPriority, true);
97    set_entry(SosWithLowPriorityMoreImportant, true);
98    set_entry(VarWithLowPriorityMoreImportant, true);
99    set_entry(NumNlpFailureMax, 5);
100    set_entry(WarmStartStrategy, WarmStartFromRoot);
101    set_entry(NL_filename, "");
102    set_entry(IpoptParamfile, "");
103}
104
105//#############################################################################
106
107BCP_lp_user *
108BM_init::lp_init(BCP_lp_prob& p)
109{
110    return new BM_lp;
111}
112
113/****************************************************************************/
114
115BCP_tm_user *
116BM_init::tm_init(BCP_tm_prob& p,
117                 const int argnum, const char * const * arglist)
118{
119    BM_tm* tm = new BM_tm;
120
121    if (argnum == 2) {
122        tm->par.read_from_file(arglist[1]);
123    } else if (argnum == 1) {
124        // work with defaults
125    } else {
126        tm->par.read_from_arglist(argnum, arglist);
127    }
128
129    tm->readIpopt();
130
131    return tm;
132}
133
134/****************************************************************************/
135
136BCP_user_pack *
137BM_init::packer_init(BCP_user_class* p)
138{
139    return new BM_pack;
140}
Note: See TracBrowser for help on using the repository browser.