molfoundry.FlowSolution#

class molfoundry.FlowSolution(dg, flow, in_flow, out_flow, obj_value)#

A solved integer hyperflow over a derivation graph: how many times each reaction fires, plus the inflow / outflow on each boundary species.

The flow is an aggregate — it says how many times each reaction fires, not in what order. Whether some order actually realizes it is answered by is_realizable(); an explicit witness order is a FlowSolutionCertificate from enumerate_certificates().

It is produced by the FlowModel / FlowModelSMT solvers.

Parameters:
property dg: DG#
property obj_value: float#
property flow: List[Tuple[HyperEdge, int]]#

The firing reactions as (hyperedge, timesFired) pairs.

property in_flow: List[Tuple[Vertex, int]]#

The source species as (vertex, amount) pairs.

property out_flow: List[Tuple[Vertex, int]]#

The sink species as (vertex, amount) pairs.

is_realizable()#

Return True iff at least one firing order realizes the flow.

Delegates to the library-agnostic coverability search on the TS side (it needs only the flow itself, no ILP / SMT solver).

Return type:

bool

svg() → str#
svg(printer: DGPrinter | None = None) → str

Render the flow overlaid on its derivation graph and return the SVG string — the filtered flow drawing (only the flowing reactions / touched species, each reaction labeled with its firing count and each boundary species with its inflow / outflow).

Parameters:

printer (DGPrinter | None)

Return type:

str

print() → None#
print(printer: DGPrinter | None = None) → None

Emit the flow drawing (see svg()) as a summary card.

Parameters:

printer (DGPrinter | None)

Return type:

None

enumerate_certificates(limit=None)#

Enumerate valid firing orders (certificates) that realize the flow.

Each is a FlowSolutionCertificate: a concrete order in which to fire the reactions so no reactant is ever consumed before it exists. This search is library-specific (z3), so it stays on the Python side; it yields up to limit distinct orders (all of them when limit is None).

Parameters:

limit (int | None)

Return type:

Iterator[FlowSolutionCertificate]