Query improvements in the min cost flow algorithms.
- External flow and potential maps can be used.
- New query functions: flow() and potential().
- CycleCanceling also provides dual solution (node potentials).
- Doc improvements.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
21 /// \brief Solver for SAT problems.
23 /// This demo progam solves the SAT problem, i.e. the boolean
24 /// satisfiability problem. The problem in general case is
27 /// The program uses an integer linear program solver. A <tt>{0,
28 /// 1}</tt> variable is assigned to each boolean variable. The
29 /// disjunctions are converted to linear inequalities as each negation
30 /// is replaced with a substraction from one and each disjunction is
31 /// converted to addition. The generated linear expression should be
44 using namespace lemon;
47 int main(int argc, const char *argv[]) {
49 std::cerr << "The SAT solver demo" << std::endl << std::endl;
50 std::cerr << "The parameter should be a filename" << std::endl;
51 std::cerr << "Each line of the file should contain a bool expression:"
53 std::cerr << " [not] <variable> [or [not] <variable>]..." << std::endl;
54 std::cerr << "The program prints a feasible solution if it exists"
65 while (getline(is, line)) {
66 istringstream ls(line);
82 Mip::Col col = mip.colByName(var);
86 mip.colName(col, var);
87 mip.colLowerBound(col, 0);
88 mip.colUpperBound(col, 1);
89 mip.integer(col, true);
92 expr += (neg ? 1 - col : col);
94 } while (ls >> op && op == "or");
96 std::cerr << "Wrong bool expression" << std::endl;
99 mip.addRow(expr >= 1);
104 if (mip.mipStatus() == Mip::OPTIMAL) {
105 for (Mip::ColIt it(mip); it != INVALID; ++it) {
106 std::cout << mip.colName(it) << " = "
107 << (mip.primal(it) == 1 ? "true" : "false")
111 std::cout << "There is no feasible solution." << std::endl;