2.2.9.2. causality/Flow.hpp

2.2.9.2.1. Class causality::FlowQuery

class causality::FlowQuery

Representation of a query for a DAG that can be folded back into a given flow. The query is based on a derivation graph and can thus be used for any flow solution from a model based on that derivation graph.

2.2.9.2.1.1. Synopsis

struct MOD_DECL FlowQuery {
    explicit FlowQuery(std::shared_ptr<dg::DG> dg_);
    MOD_DECL friend std::ostream &operator<<(std::ostream &s, const FlowQuery &q);
    std::shared_ptr<dg::DG> getDG() const;
    void setMultiplicity(int multiplicity);
    int getMultiplicity() const;
    void setBorrow(dg::DG::Vertex v, int count);
    int getBorrow(dg::DG::Vertex v) const;
    void setBorrow(std::shared_ptr<graph::Graph> g, int count);
    int getBorrow(std::shared_ptr<graph::Graph> g) const;
    void setConstrainRouting(bool v);
    bool getConstrainRouting() const;
public:
    boost::optional<DAG> findDAG(const flow::Solution &s) const;
    boost::optional<DAG> findDAG(const flow::SolutionOld &s) const;
public:
    // TODO: remove once the old flow solutions are gone
    lib::causality::FlowQuery getQuery() const;
private:
    std::shared_ptr<dg::DG> dg_;
    int multiplicity = 1;
    std::map<dg::DG::Vertex, int> borrow;
    bool constrainRouting = true;
};

2.2.9.2.1.2. Details

explicit FlowQuery(std::shared_ptr<dg::DG> dg_)

Construct a query with multiplicity 1 and no borrowing.

Throws

LogicError if dg_ is null.

std::shared_ptr<dg::DG> getDG() const
Returns

the underlying derivation graph.

void setMultiplicity(int multiplicity)
int getMultiplicity() const

Set/get the multiplicity of the query. It must be at least 1.

Throws

(set) LogicError if multiplicity < 1.

void setBorrow(dg::DG::Vertex v, int count)
int getBorrow(dg::DG::Vertex v) const

Set/get the amount of flow allowed to be borrowed at the vertex represented by the graph.

Throws

LogicError if !v.

Throws

LogicError if v.getDG() != getDG().

Throws

(set) LogicError if count < 0.

void setBorrow(std::shared_ptr<graph::Graph> g, int count)
int getBorrow(std::shared_ptr<graph::Graph> g) const

Calls the corresponding functions with the result of getDG()->findVertex(g).

void setConstrainRouting(bool v)
bool getConstrainRouting() const

Set/get whether transit edges must conform to the routing expressed by the flow. Setting this to false may give sequences violating flow constraints.

boost::optional<DAG> findDAG(const flow::Solution &s) const
Returns

a causality DAG that can be folded back into the given flow solution, using the query settings in this object, if one can be found.

Throws

LogicError if any graph g given to setBorrow() with non-zero count is not a vertex in the underlying derivation graph of the given flow solution, i.e., if s.getFlow()->getDG()->findVertex(g) returns a null vertex.