10.5. Integer Hyperflows and Pathways¶
10.5.1. A Specific Pathway¶
A Pathway is an integer hyper-flow: each reaction is assigned a non-negative interger, specifying the number of times the reaction is used. Virtual input and output reactions are added to each molecule.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | include("0212_dgPredicate.py")
# Use the derivation graph 'dg' already created:
flow = Flow(dg)
# Specify which molecules can be fed into the network:
flow.addSource(formaldehyde)
flow.addSource(glycolaldehyde)
# Specify which molecules that can remain in the network:
flow.addSink(glycolaldehyde)
# Specify restrictions on the amount of input/output molecules:
flow.addConstraint(inFlow[formaldehyde] == 2)
flow.addConstraint(inFlow[glycolaldehyde] == 1)
flow.addConstraint(outFlow[glycolaldehyde] == 2)
# Specify the minimization criteria:
# number of unique reactions used
flow.objectiveFunction = isEdgeUsed
# Find a solution:
flow.findSolutions()
# Show solution information in the terminal:
flow.solutions.list()
# Print solutions:
flow.solutions.print()
|
10.5.2. Extra Constraints¶
We can add many kinds of constraints. They do not need to be related to input/ouput.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | include("0212_dgPredicate.py")
# Use the derivation graph 'dg' already created:
flow = Flow(dg)
# Specify which molecules can be fed into the network:
flow.addSource(formaldehyde)
flow.addSource(glycolaldehyde)
# Specify which molecules that can remain in the network:
flow.addSink(glycolaldehyde)
# Specify restrictions on the amount of input/output molecules:
flow.addConstraint(inFlow[formaldehyde] == 2)
flow.addConstraint(inFlow[glycolaldehyde] == 1)
flow.addConstraint(outFlow[glycolaldehyde] == 2)
# Disable too large molecules:
for v in dg.vertices:
if v.graph.vLabelCount("C") > 4:
flow.addConstraint(vertex[v] == 0)
# Disable "strange" misleading input/output flows:
flow.allowIOReversal = False
# Specify the minimization criteria:
# number of unique reactions used
flow.objectiveFunction = isEdgeUsed
# Find a solution:
flow.findSolutions()
# Show solution information in the terminal:
flow.solutions.list()
# Print solutions:
flow.solutions.print()
|
10.5.3. Multiple Solutions¶
It is often interesting to look for alternate solutions, possibly with a sub-optimal objective value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | include("0212_dgPredicate.py")
# Use the derivation graph 'dg' already created:
flow = Flow(dg)
# Specify which molecules can be fed into the network:
flow.addSource(formaldehyde)
flow.addSource(glycolaldehyde)
# Specify which molecules that can remain in the network:
flow.addSink(glycolaldehyde)
# Specify restrictions on the amount of input/output molecules:
flow.addConstraint(inFlow[formaldehyde] == 2)
flow.addConstraint(inFlow[glycolaldehyde] == 1)
flow.addConstraint(outFlow[glycolaldehyde] == 2)
# Disable "strange" misleading input/output flows:
flow.allowIOReversal = False
# Specify the minimization criteria:
# number of reactions
flow.objectiveFunction = edge
# Find solutions:
# at most 10 solutions, any quality
flow.findSolutions(maxNumSolutions=10)
# Show solution information in the terminal:
flow.solutions.list()
# Print solutions:
flow.solutions.print()
|
10.5.4. Finding Autocatalytic Cycles¶
Some pathways have a specific higher-order structure, e.g., autocatalysis.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | include("0212_dgPredicate.py")
# Use the derivation graph 'dg' already created:
flow = Flow(dg)
# Specify which molecules can be fed into the network:
flow.addSource(formaldehyde)
flow.addSource(glycolaldehyde)
# Specify which molecules that can remain in the network:
flow.addSink(glycolaldehyde)
# Enable constraints for autocatalysis:
flow.overallAutocatalysis.enable()
# Specify the minimization criteria:
# number of unique reactions used
flow.objectiveFunction = isEdgeUsed
# Find a solution:
flow.findSolutions()
# Show solution information in the terminal:
flow.solutions.list()
# Print solutions:
flow.solutions.print()
|