Vol 1.5.4
Loading...
Searching...
No Matches
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
22using std::string;
23using std::map;
24using std::vector;
25using std::cout;
26using std::endl;
27
28class LP_parms;
29class VOL_lp;
30
31// The function that actually reads in the MPS file
32int reader(const LP_parms &lp_par, VOL_lp *lp_pb);
33
34//#############################################################################
35
36class Rname {
37public:
38 int nrows;
39 map<string, int> name;
40 vector<string> sign;
41public:
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
66class Cname{
67private:
68 int ncols;
69public:
70 map<string, int> name;
71public:
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
Definition reader.h:66
int ncols
Definition reader.h:68
map< string, int > name
Definition reader.h:70
int original_index(const string &Name)
Definition reader.h:74
void add(const string &Name)
Definition reader.h:82
~Cname()
Definition reader.h:73
Cname()
Definition reader.h:72
Definition lp.h:24
Definition reader.h:36
int original_index(const string &Name)
Definition reader.h:44
int nrows
Definition reader.h:38
~Rname()
Definition reader.h:43
void add(const string &Name, const string &Sign)
Definition reader.h:52
Rname()
Definition reader.h:42
vector< string > sign
Definition reader.h:40
map< string, int > name
Definition reader.h:39
Definition lpc.h:17
int reader(const LP_parms &lp_par, VOL_lp *lp_pb)