Limbo 3.5.4
Loading...
Searching...
No Matches
LpDataBase.h
Go to the documentation of this file.
1
7
8#ifndef LPPARSER_DATABASE_H
9#define LPPARSER_DATABASE_H
10
11#include <string>
12#include <vector>
13#include <iostream>
14#include <fstream>
15#include <sstream>
16#include <cassert>
17#include <limits>
18#include <limbo/math/Math.h>
19
21namespace LpParser {
22
24using std::cout;
25using std::endl;
26using std::cerr;
27using std::string;
28using std::vector;
29using std::pair;
30using std::make_pair;
31using std::ostringstream;
32typedef int int32_t;
33typedef unsigned int uint32_t;
34typedef long int64_t;
36
38typedef std::vector<int64_t> IntegerArray;
40typedef std::vector<std::string> StringArray;
41
42#if 0
45class IntegerArray : public vector<int64_t>
46{
47 public:
49 typedef vector<int64_t> base_type;
50 using base_type::size_type;
51 using base_type::value_type;
52 using base_type::allocator_type;
54
57 IntegerArray(const allocator_type& alloc = allocator_type())
58 : base_type(alloc) {}
63 IntegerArray(size_type n, const value_type& val, const allocator_type& alloc = allocator_type())
64 : base_type(n, val, alloc) {}
65};
66
69class StringArray : public vector<string>
70{
71 public:
73 typedef vector<string> base_type;
74 using base_type::size_type;
75 using base_type::value_type;
76 using base_type::allocator_type;
78
81 StringArray(const allocator_type& alloc = allocator_type())
82 : base_type(alloc) {}
87 StringArray(size_type n, const value_type& val, const allocator_type& alloc = allocator_type())
88 : base_type(n, val, alloc) {}
89};
90#endif
91
93struct Term
94{
95 double coef;
96 string var;
97
101 Term(double c, string const& v) : coef(c), var(v) {}
102};
103
105typedef std::vector<Term> TermArray;
106
107// temporary data structures to hold parsed data
108
109// forward declaration
115{
116 public:
121 virtual void add_variable(string const& vname,
122 double l = limbo::lowest<double>(),
123 double r = std::numeric_limits<double>::max()) = 0;
129 virtual void add_constraint(string const& cname, TermArray const& terms, char compare, double constant) = 0;
133 virtual void add_objective(bool minimize, TermArray const& terms) = 0;
137 virtual void set_integer(string const& vname, bool binary) = 0;
138};
139
140} // namespace DefParser
141
142#endif
mathematical utilities such as abs
Base class for lp database. Only pure virtual functions are defined. User needs to inheritate this ...
Definition LpDataBase.h:115
virtual void add_constraint(string const &cname, TermArray const &terms, char compare, double constant)=0
add constraint that terms compare constant.
virtual void add_variable(string const &vname, double l=limbo::lowest< double >(), double r=std::numeric_limits< double >::max())=0
add variable that l <= vname <= r.
virtual void set_integer(string const &vname, bool binary)=0
set integer variables
virtual void add_objective(bool minimize, TermArray const &terms)=0
add object terms
namespace for LpParser
Definition LpDataBase.h:21
std::vector< std::string > StringArray
string array
Definition LpDataBase.h:40
std::vector< int64_t > IntegerArray
integer array
Definition LpDataBase.h:38
std::vector< Term > TermArray
array of terms
Definition LpDataBase.h:105
T lowest()
generic function to get lowest value of numbers
string var
variable
Definition LpDataBase.h:96
double coef
coefficient
Definition LpDataBase.h:95
Term(double c, string const &v)
constructor
Definition LpDataBase.h:101