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-2019 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 "soplex/spxdefines.h"
22 #include "soplex/spxsolver.h"
23 #include "soplex/spxpricer.h"
24 #include "soplex/spxratiotester.h"
25 #include "soplex/spxstarter.h"
26 #include "soplex/slinsolver.h"
27 #include "soplex/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 
46  if(!ofs)
47  return false;
48 
49  ofs << "# SoPlex version " << SOPLEX_VERSION / 100
50  << "." << (SOPLEX_VERSION / 10) % 10
51  << "." << SOPLEX_VERSION % 10
52  << "." << SOPLEX_SUBVERSION << std::endl << std::endl;
53  ofs << "# run SoPlex as follows:" << std::endl;
54  ofs << "# bin/soplex --loadset=spxcheck.set --readbas=spxcheck.bas spxcheck.mps\n" << std::endl;
55  ofs << "int:representation = " << (rep() == SPxSolver::COLUMN ? "1" : "2") << std::endl;
56  ofs << "int:factor_update_max = " << basis().getMaxUpdates() << std::endl;
57  ofs << "int:pricer = ";
58 
59  if(!strcmp(pricer()->getName(), "Auto"))
60  ofs << " 0" << std::endl;
61  else if(!strcmp(pricer()->getName(), "Dantzig"))
62  ofs << "1" << std::endl;
63  else if(!strcmp(pricer()->getName(), "ParMult"))
64  ofs << "2" << std::endl;
65  else if(!strcmp(pricer()->getName(), "Devex"))
66  ofs << "3" << std::endl;
67  else if(!strcmp(pricer()->getName(), "Steep"))
68  ofs << "4" << std::endl;
69  else if(!strcmp(pricer()->getName(), "SteepEx"))
70  ofs << "5" << std::endl;
71 
72  ofs << "int:ratiotester = ";
73 
74  if(!strcmp(ratiotester()->getName(), "Default"))
75  ofs << "0" << std::endl;
76  else if(!strcmp(ratiotester()->getName(), "Harris"))
77  ofs << "1" << std::endl;
78  else if(!strcmp(ratiotester()->getName(), "Fast"))
79  ofs << "2" << std::endl;
80  else if(!strcmp(ratiotester()->getName(), "Bound Flipping"))
81  ofs << "3" << std::endl;
82 
83  ofs << "real:feastol = " << feastol() << std::endl;
84  ofs << "real:opttol = " << opttol() << std::endl;
85  ofs << "real:epsilon_zero = " << epsilon() << std::endl;
86  ofs << "real:infty = " << infinity << std::endl;
87  ofs << "uint:random_seed = " << random.getSeed() << std::endl;
88  ofs.close();
89 
90  // write LP
91  ofname = std::string(filename) + ".mps";
92  ofs.open(ofname.c_str());
93 
94  if(!ofs)
95  return false;
96 
97  writeMPS(ofs, rowNames, colNames, NULL);
98  ofs.close();
99 
100  // write basis
101  ofname = std::string(filename) + ".bas";
102  return writeBasisFile(ofname.c_str(), rowNames, colNames, cpxFormat);
103 }
104 
105 } // namespace soplex
SoPlex start basis generation base class.
THREADLOCAL const Real infinity
Definition: spxdefines.cpp:26
const SPxRatioTester * ratiotester() const
return loaded SPxRatioTester.
Definition: spxsolver.h:1781
Abstract pricer base class.
Real feastol() const
allowed primal feasibility tolerance.
Definition: spxsolver.h:803
Abstract ratio test base class.
#define SOPLEX_VERSION
Definition: spxdefines.h:45
Implementation of Sparse Linear Solver.
Sparse Linear Solver virtual base class.
const SPxPricer * pricer() const
return loaded SPxPricer.
Definition: spxsolver.h:1771
int getMaxUpdates() const
returns maximum number of updates before a refactorization is performed
Definition: spxbasis.h:458
main LP solver class
virtual bool writeState(const char *filename, const NameSet *rowNames=NULL, const NameSet *colNames=NULL, const bool cpxFormat=false) const
Real epsilon() const
values are considered to be 0.
Definition: spxsolver.h:784
Debugging, floating point type and parameter definitions.
Set of strings.Class NameSet implements a symbol or name table. It allows to store or remove names (i...
Definition: nameset.h:61
virtual bool writeBasisFile(const char *filename, const NameSet *rowNames, const NameSet *colNames, const bool cpxFormat=false) const
Definition: spxfileio.cpp:39
Everything should be within this namespace.
virtual void writeMPS(std::ostream &out, const NameSet *rowNames, const NameSet *colNames, const DIdxSet *p_intvars=0) const
Writes a file in MPS format to out.
uint32_t getSeed() const
returns the initial seed shift
Definition: random.h:113
Random random
The random number generator used throughout the whole computation. Its seed can be modified...
Definition: spxsolver.h:424
#define SOPLEX_SUBVERSION
Definition: spxdefines.h:46
Real opttol() const
allowed optimality, i.e., dual feasibility tolerance.
Definition: spxsolver.h:811
const SPxBasis & basis() const
Return current basis.
Definition: spxsolver.h:1761
Representation rep() const
return the current basis representation.
Definition: spxsolver.h:506
columnwise representation.
Definition: spxsolver.h:108