Limbo
3.5.4
Toggle main menu visibility
Loading...
Searching...
No Matches
limbo
parsers
lp
bison
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
21
namespace
LpParser
{
22
24
using
std::cout;
25
using
std::endl;
26
using
std::cerr;
27
using
std::string;
28
using
std::vector;
29
using
std::pair;
30
using
std::make_pair;
31
using
std::ostringstream;
32
typedef
int
int32_t;
33
typedef
unsigned
int
uint32_t;
34
typedef
long
int64_t;
36
38
typedef
std::vector<int64_t>
IntegerArray
;
40
typedef
std::vector<std::string>
StringArray
;
41
42
#if 0
45
class
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
69
class
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
93
struct
Term
94
{
95
double
coef
;
96
string
var
;
97
101
Term
(
double
c,
string
const
& v) :
coef
(c),
var
(v) {}
102
};
103
105
typedef
std::vector<Term>
TermArray
;
106
107
// temporary data structures to hold parsed data
108
109
// forward declaration
114
class
LpDataBase
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
Math.h
mathematical utilities such as abs
LpParser::LpDataBase
Base class for lp database. Only pure virtual functions are defined. User needs to inheritate this ...
Definition
LpDataBase.h:115
LpParser::LpDataBase::add_constraint
virtual void add_constraint(string const &cname, TermArray const &terms, char compare, double constant)=0
add constraint that terms compare constant.
LpParser::LpDataBase::add_variable
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.
LpParser::LpDataBase::set_integer
virtual void set_integer(string const &vname, bool binary)=0
set integer variables
LpParser::LpDataBase::add_objective
virtual void add_objective(bool minimize, TermArray const &terms)=0
add object terms
LpParser::vector
LpParser
namespace for LpParser
Definition
LpDataBase.h:21
LpParser::StringArray
std::vector< std::string > StringArray
string array
Definition
LpDataBase.h:40
LpParser::IntegerArray
std::vector< int64_t > IntegerArray
integer array
Definition
LpDataBase.h:38
LpParser::TermArray
std::vector< Term > TermArray
array of terms
Definition
LpDataBase.h:105
limbo::lowest
T lowest()
generic function to get lowest value of numbers
LpParser::Term::var
string var
variable
Definition
LpDataBase.h:96
LpParser::Term::coef
double coef
coefficient
Definition
LpDataBase.h:95
LpParser::Term::Term
Term(double c, string const &v)
constructor
Definition
LpDataBase.h:101
Generated on
for Limbo by
1.17.0