Scippy

SoPlex

Sequential object-oriented simPlex

spxwritestate.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the class library */
4 /* SoPlex --- the Sequential object-oriented simPlex. */
5 /* */
6 /* Copyright (C) 1996-2015 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 #include <iostream>
17 #include <fstream>
18 #include <string.h>
19 #include <sstream>
20 
21 #include "spxdefines.h"
22 #include "spxsolver.h"
23 #include "spxpricer.h"
24 #include "spxratiotester.h"
25 #include "spxstarter.h"
26 #include "slinsolver.h"
27 #include "slufactor.h"
28 
29 namespace soplex
30 {
32  const char* filename,
33  const NameSet* rowNames,
34  const NameSet* colNames,
35  const bool cpxFormat
36  ) const
37 {
38 
39  std::string ofname;
40  std::ofstream ofs;
41 
42  // write parameter settings
43  ofname = std::string(filename) + ".set";
44  ofs.open(ofname.c_str());
45  if (!ofs)
46  return false;
47 
48  ofs << "# SoPlex version " << SOPLEX_VERSION / 100
49  << "." << (SOPLEX_VERSION / 10) % 10
50  << "." << SOPLEX_VERSION % 10
51  << "." << SOPLEX_SUBVERSION << std::endl << std::endl;
52  ofs << "# run SoPlex as follows:" << std::endl;
53  ofs << "# bin/soplex --loadset=spxcheck.set --readbas=spxcheck.bas spxcheck.mps\n" << std::endl;
54  ofs << "int:representation = " << ( rep() == SPxSolver::COLUMN ? "1" : "2" ) << std::endl;
55  ofs << "int:factor_update_max = " << basis().getMaxUpdates() << std::endl;
56  ofs << "int:pricer = ";
57  if (!strcmp(pricer()->getName(), "Auto"))
58  ofs << " 0" << std::endl;
59  else if (!strcmp(pricer()->getName(), "Dantzig"))
60  ofs << "1" << std::endl;
61  else if (!strcmp(pricer()->getName(), "ParMult"))
62  ofs << "2" << std::endl;
63  else if (!strcmp(pricer()->getName(), "Devex"))
64  ofs << "3" << std::endl;
65  else if (!strcmp(pricer()->getName(), "Steep"))
66  ofs << "4" << std::endl;
67  else if (!strcmp(pricer()->getName(), "SteepEx"))
68  ofs << "5" << std::endl;
69  ofs << "int:ratiotester = ";
70  if (!strcmp(ratiotester()->getName(), "Default"))
71  ofs << "0" << std::endl;
72  else if (!strcmp(ratiotester()->getName(), "Harris"))
73  ofs << "1" << std::endl;
74  else if (!strcmp(ratiotester()->getName(), "Fast"))
75  ofs << "2" << std::endl;
76  else if (!strcmp(ratiotester()->getName(), "Bound Flipping"))
77  ofs << "3" << std::endl;
78  ofs << "real:feastol = " << feastol() << std::endl;
79  ofs << "real:opttol = " << opttol() << std::endl;
80  ofs << "real:epsilon_zero = " << epsilon() << std::endl;
81  ofs << "real:infty = " << infinity << std::endl;
82  ofs.close();
83 
84  // write LP
85  ofname = std::string(filename) + ".mps";
86  ofs.open(ofname.c_str());
87  if (!ofs)
88  return false;
89 
90  writeMPS(ofs, rowNames, colNames, NULL);
91  ofs.close();
92 
93  // write basis
94  ofname = std::string(filename) + ".bas";
95  return writeBasisFile(ofname.c_str(), rowNames, colNames, cpxFormat);
96 }
97 
98 } // namespace soplex