aboutsummaryrefslogtreecommitdiffstats
path: root/native/src
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2012-08-07 14:10:06 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2013-02-12 06:49:39 -0500
commit673f367fc5835ebce3357dfebee9c0e414e5c09b (patch)
treeca95cb1afe91af4845627ec5a8370b364ec7193d /native/src
parent52c28dbda3f4ef2241182e32002b710b1a9eae0b (diff)
Add simple C++ linear program representation
- Constraints are expressed as lists of terms. - Linear programs consist of only equalities and less-than-or-equal constraints. - Solvers hide behind an abstract solution class that can evaluate linear expressions.
Diffstat (limited to 'native/src')
-rw-r--r--native/src/linprog/io.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/native/src/linprog/io.cpp b/native/src/linprog/io.cpp
new file mode 100644
index 0000000..1b5d503
--- /dev/null
+++ b/native/src/linprog/io.cpp
@@ -0,0 +1,22 @@
1#include <iostream>
2
3#include "linprog/io.h"
4
5std::ostream& operator<<(std::ostream &os, const LinearExpression &exp)
6{
7 bool first = true;
8 foreach (exp.get_terms(), term)
9 {
10 if (term->first < 0)
11 os << "- " << -term->first;
12 else if (!first)
13 os << "+ " << term->first;
14 else
15 os << term->first;
16
17 os << " X" << term->second << " ";
18 first = false;
19 }
20
21 return os;
22}