reader.h
Go to the documentation of this file.
1 #ifndef __NAMES_HPP__
2 #define __NAMES_HPP__
3 
4 #include <map>
5 #include <vector>
6 #include <string>
7 #include <iostream>
8 
9 /* The classes in this file are used for reading in an MPS file.
10  Rname is used for storing the names and signs of the constraints.
11  Cname is used for storing the names of the variables.
12 */
13 
14 using std::string;
15 using std::map;
16 using std::vector;
17 using std::cout;
18 using std::endl;
19 
20 class LP_parms;
21 class VOL_lp;
22 
23 // The function that actually reads in the MPS file
24 int reader(const LP_parms &lp_par, VOL_lp *lp_pb);
25 
26 //#############################################################################
27 
28 class Rname {
29 public:
30  int nrows;
31  map<string, int> name;
32  vector<string> sign;
33 public:
34  Rname() : nrows(0) {}
35  ~Rname() {}
36  int original_index(const string & Name) {
37  map<string, int>::iterator j = name.find(Name);
38  if ( j == name.end() ) {
39  cout << " name not found: " << Name << endl;
40  abort();
41  }
42  return j->second;
43  }
44  void add(const string &Name, const string &Sign) {
45  map<string, int>::iterator j = name.find(Name);
46  if ( j==name.end() ){
47  name[Name]=nrows++;
48  sign.push_back(Sign);
49  } else {
50  cout << " duplicated row: " << Name << endl;
51  abort();
52  }
53  }
54 };
55 
56 //#############################################################################
57 
58 class Cname{
59 private:
60  int ncols;
61 public:
62  map<string, int> name;
63 public:
64  Cname() : ncols(0) {}
65  ~Cname() {}
66  int original_index(const string & Name) {
67  map<string, int>::iterator j = name.find(Name);
68  if ( j == name.end() ) {
69  cout << " name not found: " << Name << endl;
70  abort();
71  }
72  return j->second;
73  }
74  void add(const string &Name) {
75  map<string, int>::iterator j = name.find(Name);
76  if ( j==name.end() ){
77  name[Name]=ncols++;
78  } else {
79  cout << " duplicated row: " << Name << endl;
80  abort();
81  }
82  }
83 };
84 
85 //#############################################################################
86 
87 #endif