source: pico/trunk/src/exec/pico/setupMappedMILP.cpp @ 4047

Revision 4047, 3.3 KB checked in by wehart, 8 years ago (diff)

Major rework of PICO-related packages, to rename pico-core to pebbl and
pico-milp to pico.

( Links to Acro-related mail archives at  http://software.sandia.gov/Acro/ )

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*  _________________________________________________________________________
2 *
3 *  PICO: A C++ library of scalable branch-and-bound and related methods.
4 *  Copyright (c) 2001, Sandia National Laboratories.
5 *  This software is distributed under the GNU Lesser General Public License.
6 *  For more information, see the README file in the top PICO directory.
7 *  _________________________________________________________________________
8 */
9//
10// setupMappedMILP.cpp
11//
12// Creates a MILP application that includes symbols from the variable and
13// constraint names!
14//
15
16#include <acro_config.h>
17#include <utilib/_math.h>
18#include <utilib/seconds.h>
19#include <utilib/ParameterList.h>
20#include <utilib/memdebug.h>
21#include <pebbl/fundamentals.h>
22#include <pico/milp.h>
23
24using namespace utilib;
25using namespace pico;
26using namespace std;
27
28
29int main(int argc, char** argv)
30{
31utilib::exception_mngr::set_mode(utilib::exception_mngr::Abort);
32CommonIO::begin();
33try {
34
35signal(SIGFPE,pebbl_abort_handler);
36
37int debug=0;
38bool preprocessLP=false;
39
40utilib::ParameterSet params;
41params.create_parameter("debug",debug,"<int>","0",
42        "TODO",utilib::ParameterLowerBound<int>(0));
43params.create_parameter("preprocessLP",preprocessLP,
44        "<bool>","false","TODO");
45
46ParameterList plist;
47plist.register_parameters(params);
48plist.register_parameters<MILPProblem>();
49plist.process_parameters(argc,argv,1);
50params.set_parameters(plist,false);
51if (params.get_parameter<bool>("help")) {
52plist.write_registered_parameters(cout);
53return -1;
54}
55
56BasicArray<int> listOfInts;
57CharString mapfile, rowlabels, collabels;
58
59//
60// PICO's parameter processing... (need this here????)
61//
62//parameter::readAll(argc, argv, 0, 10);
63//
64// My parameter processing...
65//
66if (argc == 1) {
67   ucout << "setupMappedMILP [-labels <rowfile> <colfile>] [-mapfile <mapfile>] <lp-file> <ofile-name>\n";
68   ucout.flush();
69   CommonIO::end();
70   return ERR;
71   }
72int argctr=1;
73if (strcmp(argv[argctr],"-labels") == 0) {
74   argctr++;
75   rowlabels = argv[argctr++];
76   collabels = argv[argctr++];
77   }
78if (strcmp(argv[argctr],"-mapfile") == 0) {
79   mapfile = argv[argctr+1];
80   argctr += 2;
81   }
82MILPProblem problem;
83problem.lp.init(pico::PicoLPSolver::defaultLP);
84problem.lp()->loadProblem(argv[argctr++], listOfInts);
85//
86// Here, we reset the name of the LP to make it consistent with the
87// name of the MPS file.  This is necessary, since this label is what is
88// used to find other files generated by gen_milp_app
89//
90CharString lpname = argv[argctr];
91char* str = strrchr(lpname.data(), (int)'.');
92if (str != NULL)
93   lpname.resize(str - lpname.data());
94problem.lp()->setName(lpname.data());
95
96CharString fname = argv[argctr++];
97
98//
99// Write out debugging information
100//
101if (debug) {
102   problem.lp()->write(ucout,verbose_format);
103   ucout << Flush;
104   }
105/*
106if (listOfInts.size() == 0) {
107   ucout << "No integer variables... no apparent need to generate a mapped LP." << endl;
108   CommonIO::end();
109   return 0;
110   }
111*/
112
113problem.initialize(listOfInts, debug);
114if (rowlabels != "")
115   problem.set_labels(rowlabels,collabels);
116if (params.get_parameter<bool>("preprocessLP"))
117   problem.preprocess();
118problem.generate_mapped_milp(fname,mapfile);
119
120}
121catch (const char* str) {
122  cerr << "ERROR: setupMappedMILP caught error: " << str << endl;
123  }
124catch (std::exception& err) {
125  cerr << "ERROR: setupMappedMILP caught exception: " << err.what() << endl;
126  }
127
128CommonIO::end();
129return 0;
130}
Note: See TracBrowser for help on using the repository browser.