source: trunk/Bonmin/src/IpoptInterface/IpCbcColReader.hpp @ 1

Last change on this file since 1 was 1, checked in by andreasw, 13 years ago

imported initial code

  • Property svn:eol-style set to native
  • Property svn:keywords set to "Author Date Id Revision"
File size: 1.5 KB
Line 
1// (C) Copyright Carnegie Mellon University 2005
2// All Rights Reserved.
3// This code is published under the Common Public License.
4//
5// Authors :
6// Pierre Bonami, Carnegie Mellon University,
7//
8// Date : 26/05/2005
9
10#ifndef IpCbcColReader_HPP
11#define IpCbcColReader_HPP
12#include <string>
13#include <list>
14#include <fstream>
15#include <iostream>
16#include <CoinHelperFunctions.hpp>
17#include <ext/hash_map>
18
19/** A class for reading a .col file containing name for variable (ampl generated file).
20   */
21class IpCbcColReader
22{
23public:
24  /** Constructor with a file name given by a const char * */
25  IpCbcColReader(const char * fileName);
26  /** Constructor with a file name given by a string and also default (empty string) */
27  IpCbcColReader(const std::string & fileName="");
28  /** Reads the .col file*/
29  bool readFile();
30  /** Reads the .col file fileName*/
31  bool readFile(const std::string &fileName)
32  {
33    fileName_=fileName;
34    return readFile();
35  }
36
37  /** Copy the names to varNames */
38  void copyNames(std::string *varNames, int n_var);
39private:
40  /// Name of the file to read.
41  std::string fileName_;
42
43  /// String comparison strucutre.
44  struct eqstr
45  {
46    bool operator()(const char* s1, const char* s2) const
47    {
48      return strcmp(s1, s2) == 0;
49    }
50  };
51
52  /// Hash type.
53  typedef __gnu_cxx::hash_map<const char *, int> namesHash;//, __gnu_cxx::hash <const char *>, eqstr > namesHash;
54
55  ///Hash map used to store the indices.
56  namesHash varIndices_;
57  ///Variable names.
58  std::vector<std::string> varNames_;
59};
60
61#endif
Note: See TracBrowser for help on using the repository browser.