2.2.11.5. flow/Solution.hpp¶
2.2.11.5.1. Class flow::SolutionRange
¶
-
class
flow
::
SolutionRange
¶ A range of solutions for a flow model.
2.2.11.5.1.1. Synopsis¶
struct MOD_DECL SolutionRange {
struct const_iterator {
using difference_type = int;
using value_type = Solution;
using reference = Solution;
using iterator_category = std::random_access_iterator_tag;
using pointer = void;
public:
const_iterator() = default;
private:
friend class SolutionRange;
const_iterator(std::shared_ptr<Flow> flow_, int i);
public:
MOD_DECL friend bool operator==(const const_iterator &a, const const_iterator &b);
MOD_DECL friend bool operator!=(const const_iterator &a, const const_iterator &b);
const_iterator &operator++();
const_iterator operator++(int);
MOD_DECL friend const_iterator operator+(const const_iterator &a, int i);
Solution operator*() const;
Solution operator[](int i) const;
private:
std::shared_ptr<Flow> flow_;
int i = 0;
};
using iterator = const_iterator;
private:
friend class Flow;
SolutionRange(std::shared_ptr<Flow> flow_, int first, int last);
public:
std::shared_ptr<Flow> getFlow() const;
MOD_DECL friend std::ostream &operator<<(std::ostream &s, const SolutionRange &r);
int size() const;
const_iterator begin() const;
const_iterator end() const;
Solution operator[](int i) const;
public:
void list() const;
void print() const;
void print(const dg::PrintData &data, const Printer &printer) const;
private:
std::shared_ptr<Flow> flow_;
int first = 0, last = 0;
};
2.2.11.5.1.2. Details¶
-
friend std::ostream &
operator<<
(std::ostream &s, const SolutionRange &r)¶
-
int
size
() const¶ - Returns
the number of solutions in the range.
-
const_iterator
begin
() const¶ -
const_iterator
end
() const¶ - Returns
the begin and end iterators for the range.
-
Solution
operator[]
(int i) const¶ - Returns
the
i
th solution in the range.- Throws
LogicError
if the index is out of bounds.
-
void
list
() const¶ List overall information about each solution.
-
void
print
() const¶ -
void
print
(const dg::PrintData &data, const Printer &printer) const¶ Print solutions using the settings in the given printer and the structure information in the data object.
The
data
defaults todg::PrintData(getFlow()->getDG())
andprinter
defaults toPrinter()
.- Throws
LogicError
if the given print data does not belong to the underlying derivation graph.
2.2.11.5.2. Class flow::Solution
¶
-
class
flow
::
Solution
¶ A solution for a flow model.
2.2.11.5.2.1. Synopsis¶
class MOD_DECL Solution {
friend class SolutionRange::const_iterator;
Solution(std::shared_ptr<Flow> flow_, int i);
public:
std::shared_ptr<Flow> getFlow() const;
int getId() const;
MOD_DECL friend std::ostream &operator<<(std::ostream &s, const Solution &sol);
MOD_DECL friend bool operator==(const Solution &a, const Solution &b);
MOD_DECL friend bool operator!=(const Solution &a, const Solution &b);
public:
boost::variant<int, double> eval(const LinExp &exp) const;
void list() const;
std::pair<boost::optional<std::string>, boost::optional<std::string>>
print() const;
std::pair<boost::optional<std::string>, boost::optional<std::string>>
print(const dg::PrintData &data, const Printer &printer) const;
private:
std::shared_ptr<Flow> flow_;
int i;
};
2.2.11.5.2.2. Details¶
-
int
getId
() const¶ - Returns
an ID for the solution which is unique among all solutions from the parent
Flow
object.
-
boost::variant<int, double>
eval
(const LinExp &exp) const¶ - Returns
the value of the given linear expression evaluated on the solution.
-
void
list
() const¶ List overall information about the solution.
-
std::pair<boost::optional<std::string>, boost::optional<std::string>>
print
() const¶ -
std::pair<boost::optional<std::string>, boost::optional<std::string>>
print
(const dg::PrintData &data, const Printer &printer) const¶ Print the solution using the settings in the given printer and the structure information in the data object.
The
data
defaults todg::PrintData(getFlow()->getDG())
andprinter
defaults toPrinter()
.- Returns
the name of the PDF-files that will be compiled in post-processing for respectively the filtered and unfiltered depictions. If either is not requested by the given
printer
the corresponding entry has no string.- Throws
LogicError
if the given print data does not belong to the underlying derivation graph.
2.2.11.5.3. Class flow::SolutionOld
¶
-
class
flow
::
SolutionOld
¶ An object of this class represents a solution for a specific flow model.
2.2.11.5.3.1. Synopsis¶
class MOD_DECL SolutionOld {
friend class SolutionSet;
SolutionOld(std::shared_ptr<Flow> dgFlow, unsigned int id);
public:
lib::Flow::Solution makeSolution() const;
public:
unsigned int getId() const;
std::shared_ptr<Flow> getFlow() const;
double eval(const LinExp &exp) const;
std::string print(const dg::PrintData &data, const Printer &printer) const;
void haxListDerivations() const;
// :throws: :class:`LogicError` if at least one graph in the query does not represent a vertex in the underlying derivation graph.
bool hasSequence(const causality::FlowQuery &query) const;
// :throws: :class:`LogicError` if at least one graph in the query does not represent a vertex in the underlying derivation graph.
// :throws: :class:`LogicError` if the sequence does not exist.
DGTransition::Sequence getSequence(const causality::FlowQuery &query) const;
// :throws: :class:`LogicError` if the two solutions are not on the same derivation graph.
bool equal(const SolutionOld &other, const LinExp &vars) const;
// object equality, not the same as equal
MOD_DECL friend bool operator==(const SolutionOld &lhs, const SolutionOld &rhs);
private:
std::shared_ptr<Flow> dgFlow;
unsigned int id;
};
2.2.11.5.3.2. Details¶
-
unsigned int
getId
() const¶ - Returns
an id for the solution which is unique among all solutions from the parent
Flow
object.
-
double
eval
(const LinExp &exp) const¶ - Returns
the value of the given linear expression evaluated on the solution.
-
void
print
(const dg::PrintData &data, const Printer &printer) const¶ Print the solution using the settings in the given printer.
- Returns
the name of the PDF-file that will be compiled in post-processing for the filtered graph.
- Throws
LogicError
if the given print data does not belong to the underlying derivation graph.
-
void
haxListDerivations
() const¶ List the solution in more human readable form. Don’t expect this function to stay in this form.
2.2.11.5.4. Class flow::SolutionSet
¶
-
class
flow
::
SolutionSet
¶ An object of this class represents the solutions for a specific flow model.
2.2.11.5.4.1. Synopsis¶
struct MOD_DECL SolutionSet {
struct const_iterator {
using difference_type = std::size_t;
using value_type = SolutionOld;
using reference = SolutionOld;
using iterator_category = std::forward_iterator_tag;
using pointer = void;
private:
friend class SolutionSet;
const_iterator(const SolutionSet &set, unsigned int id);
public:
bool operator!=(const_iterator other) const;
bool operator==(const_iterator other) const;
const_iterator operator++();
const_iterator operator++(int);
SolutionOld operator*() const;
private:
const SolutionSet &set;
unsigned int id;
};
using iterator = const_iterator;
public:
SolutionSet(std::shared_ptr<Flow> dgFlow);
std::shared_ptr<Flow> getFlow() const;
MOD_DECL friend std::ostream &operator<<(std::ostream &s, const SolutionSet &set);
void list() const;
unsigned int size() const;
void print(const dg::PrintData &data, const Printer &printer) const;
const_iterator begin() const;
const_iterator end() const;
SolutionOld operator[](unsigned int i) const;
private:
SolutionOld makeSolution(unsigned int id) const;
private:
std::shared_ptr<Flow> dgFlow;
unsigned int numSolutions;
};
2.2.11.5.4.2. Details¶
Construct a representation of the solutions for the given flow model.
-
void
list
() const¶ List overall information about each solution.
-
unsigned int
size
() const¶ - Returns
the number of solutions in the flow model.
-
void
print
(const dg::PrintData &data, const Printer &printer) const¶ Print all solutions using the given flow printer.
-
const_iterator
begin
() const¶ - Returns
an iterator to the first solution.
-
const_iterator
end
() const¶ - Returns
an iterator to after the last solution.
-
Solution
operator[]
(unsigned int i) const¶ - Returns
the solution at the given index.
- Throws
LogicError
if the index is out of bounds.