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