Line data Source code
1 : #pragma once 2 : 3 : #include <memory> 4 : #include <unordered_set> 5 : 6 : #include "Static/supply/Network.hpp" 7 : 8 : namespace Static { 9 : class SolutionBase; 10 : 11 666 : class Solution { 12 : friend SolutionBase; 13 : 14 : public: 15 : typedef std::unordered_map<Network::Path, Flow> Routes; 16 : 17 : private: 18 189 : struct Internals { 19 : Routes paths; 20 : std::unordered_set<Network::Edge::ID> edges; 21 : std::vector<Flow> flows; 22 : 23 : std::shared_ptr<Internals> 24 : s1 = std::shared_ptr<Internals>(nullptr), 25 : s2 = std::shared_ptr<Internals>(nullptr); 26 : 27 : double alpha; 28 : 29 : void addToRoutes(Routes &routes) const; 30 : void addToRoutes(Routes &routes, double a) const; 31 : 32 : void materialize(); 33 : }; 34 : 35 : std::shared_ptr<Internals> 36 : s = std::shared_ptr<Internals>(new Internals()); 37 : 38 : public: 39 : Solution(); 40 : Solution(const Solution &sol); 41 : 42 : virtual std::unordered_set<Network::Edge::ID> getEdges() const; 43 : 44 : virtual Flow getFlowInEdge(Network::Edge::ID id) const; 45 : 46 : virtual Routes getRoutes() const; 47 : 48 : Solution &operator=(const Solution &sol); 49 : 50 : static Solution interpolate( 51 : const Solution &s1, 52 : const Solution &s2, 53 : Flow alpha 54 : ); 55 : 56 : void materialize(); 57 : 58 : double getTotalFlow() const; 59 : }; 60 : 61 70 : class SolutionBase: public Solution { 62 : public: 63 : void addPath(const Network::Path &path, Flow flow); 64 : }; 65 : 66 : } // namespace Static