Hopefully fix all compilation errors.
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 Demonstrating the usage of LEMON's algorithm for solving the
22 /// Constrained shortest Path Problem
24 /// \include csp_demo.cc
27 #include <lemon/list_graph.h>
28 #include <lemon/csp.h>
29 #include <lemon/random.h>
32 using namespace lemon;
35 int main (int, char*[])
38 typedef ListGraph Graph;
39 typedef Graph::Node Node;
40 typedef Graph::Edge Edge;
41 typedef Graph::EdgeIt EdgeIt;
42 typedef Graph::EdgeMap<double> LengthMap;
48 std::vector<Node> nodes;
49 std::vector<Edge> edges;
51 for(int i=0;i<N;i++) nodes.push_back(g.addNode());
54 edges.push_back(g.addEdge(nodes[rnd[N]],nodes[rnd[N]]));
58 for(EdgeIt e(g);e!=INVALID;++e)
60 cost[e]=0.01+rnd(.99);
61 delay[e]=0.01+rnd(.99);
64 ConstrainedShortestPath<Graph,LengthMap,LengthMap> csp(g,cost,delay);
65 for(double d=0;d<2;d+=.001)
68 std::cout << d << ": ";
69 SimplePath<Graph> r = csp.larac(nodes[0],nodes[1],d,lo_bo);
70 if(r.empty()) std::cout << "INFEASIBLE\n";
71 else std::cout << "delay: " << csp.delay(r)
72 << " cost: " << csp.cost(r)
74 << " gap: " << csp.cost(r)-lo_bo
75 << " , " << (csp.cost(r)-lo_bo)/csp.cost(r)*100