- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/Cgl-0.53.1/Vol/examples/Volume-LP/reader.h

Go to the documentation of this file.

    00001 #ifndef __NAMES_HPP__
    00002 #define __NAMES_HPP__
    00003
    00004 #include <map>
    00005 #include <vector>
    00006 #include <string>
    00007 #include <iostream>
    00008
    00009 /* The classes in this file are used for reading in an MPS file.
    00010    Rname is used for storing the names and signs of the constraints.
    00011    Cname is used for storing the names of the variables.
    00012 */
    00013
    00014 using std::string;
    00015 using std::map;
    00016 using std::vector;
    00017 using std::cout;
    00018 using std::endl;
    00019
    00020 class LP_parms;
    00021 class VOL_lp;
    00022
    00023 // The function that actually reads in the MPS file
    00024 int reader(const LP_parms &lp_par, VOL_lp *lp_pb);
    00025
    00026 //#############################################################################
    00027
    00028 class Rname {
    00029 public:
    00030    int nrows;
    00031    map<string, int> name;
    00032    vector<string> sign;
    00033 public:
    00034    Rname() : nrows(0) {}
    00035    ~Rname() {}
    00036    int original_index(const string & Name) {
    00037       map<string, int>::iterator j = name.find(Name);
    00038       if ( j == name.end() ) {
    00039          cout << " name not found: " << Name << endl;
    00040          abort();
    00041       }
    00042       return j->second;
    00043    }
    00044    void add(const string &Name, const string &Sign) {
    00045       map<string, int>::iterator j = name.find(Name);
    00046       if ( j==name.end() ){
    00047          name[Name]=nrows++;
    00048          sign.push_back(Sign);
    00049       } else {
    00050          cout << " duplicated row: " << Name << endl;
    00051          abort();
    00052       }
    00053    }
    00054 };
    00055
    00056 //#############################################################################
    00057
    00058 class Cname{
    00059 private:
    00060    int ncols;
    00061 public:
    00062    map<string, int> name;
    00063 public:
    00064    Cname() : ncols(0) {}
    00065    ~Cname() {}
    00066    int original_index(const string & Name) {
    00067       map<string, int>::iterator j = name.find(Name);
    00068       if ( j == name.end() ) {
    00069          cout << " name not found: " << Name << endl;
    00070          abort();
    00071       }
    00072       return j->second;
    00073    }
    00074    void add(const string &Name) {
    00075       map<string, int>::iterator j = name.find(Name);
    00076       if ( j==name.end() ){
    00077          name[Name]=ncols++;
    00078       } else {
    00079          cout << " duplicated row: " << Name << endl;
    00080          abort();
    00081       }
    00082    }
    00083 };
    00084
    00085 //#############################################################################
    00086
    00087 #endif