diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-01-05 08:28:14 -0500 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-02-12 06:55:16 -0500 |
commit | de2e2536976faecc0a90d1276c9a02789bd479cc (patch) | |
tree | ad962cf80fcdddb74b47247dc4e81e7000ae9648 | |
parent | 299ad40e3f0ae8fe2a8436371cce7edd22d98b8c (diff) |
Add support for dumping LPs to iostreams
Quite handy when debugging LPs...
-rw-r--r-- | native/include/linprog/io.h | 2 | ||||
-rw-r--r-- | native/src/linprog/io.cpp | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/native/include/linprog/io.h b/native/include/linprog/io.h index 1e8885f..e956671 100644 --- a/native/include/linprog/io.h +++ b/native/include/linprog/io.h | |||
@@ -9,6 +9,8 @@ | |||
9 | 9 | ||
10 | std::ostream& operator<<(std::ostream &os, const LinearExpression &exp); | 10 | std::ostream& operator<<(std::ostream &os, const LinearExpression &exp); |
11 | 11 | ||
12 | std::ostream& operator<<(std::ostream &os, const LinearProgram &lp); | ||
13 | |||
12 | void dump_lp_solution( | 14 | void dump_lp_solution( |
13 | VarMapper& vars, | 15 | VarMapper& vars, |
14 | const ResourceSharingInfo& info, | 16 | const ResourceSharingInfo& info, |
diff --git a/native/src/linprog/io.cpp b/native/src/linprog/io.cpp index 14eeca5..801e833 100644 --- a/native/src/linprog/io.cpp +++ b/native/src/linprog/io.cpp | |||
@@ -22,6 +22,21 @@ std::ostream& operator<<(std::ostream &os, const LinearExpression &exp) | |||
22 | return os; | 22 | return os; |
23 | } | 23 | } |
24 | 24 | ||
25 | std::ostream& operator<<(std::ostream &os, const LinearProgram &lp) | ||
26 | { | ||
27 | os << "maximize " << *lp.get_objective() << " subject to:" << std::endl; | ||
28 | foreach (lp.get_equalities(), it) | ||
29 | { | ||
30 | os << *(it->first) << " = " << it->second << std::endl; | ||
31 | } | ||
32 | foreach (lp.get_inequalities(), it) | ||
33 | { | ||
34 | os << *(it->first) << " <= " << it->second << std::endl; | ||
35 | } | ||
36 | |||
37 | return os; | ||
38 | } | ||
39 | |||
25 | void dump_lp_solution( | 40 | void dump_lp_solution( |
26 | VarMapper& vars, | 41 | VarMapper& vars, |
27 | const ResourceSharingInfo& info, | 42 | const ResourceSharingInfo& info, |