11.5. Integer Hyperflows and Pathways¶
11.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.
1include("../020_dg/212_dgPredicate.py")
2# Use the derivation graph 'dg' already created:
3flow = hyperflow.Model(dg)
4# Specify which molecules can be fed into the network:
5flow.addSource(formaldehyde)
6flow.addSource(glycolaldehyde)
7# Specify which molecules that can remain in the network:
8flow.addSink(glycolaldehyde)
9# Specify restrictions on the amount of input/output molecules:
10flow.addConstraint(inFlow[formaldehyde] == 2)
11flow.addConstraint(inFlow[glycolaldehyde] == 1)
12flow.addConstraint(outFlow[glycolaldehyde] == 2)
13# Specify the minimization criteria:
14# number of unique reactions used
15flow.objectiveFunction = isEdgeUsed
16# Find a solution:
17flow.findSolutions()
18# Show solution information in the terminal:
19flow.solutions.list()
20# Print solutions:
21flow.solutions.print()
11.5.2. Extra Constraints¶
We can add many kinds of constraints. They do not need to be related to input/ouput.
1include("../020_dg/212_dgPredicate.py")
2# Use the derivation graph 'dg' already created:
3flow = hyperflow.Model(dg)
4# Specify which molecules can be fed into the network:
5flow.addSource(formaldehyde)
6flow.addSource(glycolaldehyde)
7# Specify which molecules that can remain in the network:
8flow.addSink(glycolaldehyde)
9# Specify restrictions on the amount of input/output molecules:
10flow.addConstraint(inFlow[formaldehyde] == 2)
11flow.addConstraint(inFlow[glycolaldehyde] == 1)
12flow.addConstraint(outFlow[glycolaldehyde] == 2)
13# Disable too large molecules:
14for v in dg.vertices:
15 if v.graph.vLabelCount("C") > 4:
16 flow.addConstraint(vertexFlow[v] == 0)
17# Disable "strange" misleading input/output flows:
18flow.allowIOReversal = False
19# Specify the minimization criteria:
20# number of unique reactions used
21flow.objectiveFunction = isEdgeUsed
22# Find a solution:
23flow.findSolutions()
24# Show solution information in the terminal:
25flow.solutions.list()
26# Print solutions:
27flow.solutions.print()
11.5.3. Multiple Solutions¶
It is often interesting to look for alternate solutions, possibly with a sub-optimal objective value.
1include("../020_dg/212_dgPredicate.py")
2# Use the derivation graph 'dg' already created:
3flow = hyperflow.Model(dg)
4# Specify which molecules can be fed into the network:
5flow.addSource(formaldehyde)
6flow.addSource(glycolaldehyde)
7# Specify which molecules that can remain in the network:
8flow.addSink(glycolaldehyde)
9# Specify restrictions on the amount of input/output molecules:
10flow.addConstraint(inFlow[formaldehyde] == 2)
11flow.addConstraint(inFlow[glycolaldehyde] == 1)
12flow.addConstraint(outFlow[glycolaldehyde] == 2)
13# Disable "strange" misleading input/output flows:
14flow.allowIOReversal = False
15# Specify the minimization criteria:
16# number of reactions
17flow.objectiveFunction = edgeFlow
18# Find solutions:
19# at most 10 solutions, any quality
20flow.findSolutions(maxNumSolutions=10)
21# Show solution information in the terminal:
22flow.solutions.list()
23# Print solutions:
24flow.solutions.print()
11.5.4. Finding Autocatalytic Cycles¶
Some pathways have a specific higher-order structure, e.g., autocatalysis.
1include("../020_dg/212_dgPredicate.py")
2# Use the derivation graph 'dg' already created:
3flow = hyperflow.Model(dg)
4# Specify which molecules can be fed into the network:
5flow.addSource(formaldehyde)
6flow.addSource(glycolaldehyde)
7# Specify which molecules that can remain in the network:
8flow.addSink(glycolaldehyde)
9# Enable constraints for autocatalysis:
10flow.overallAutocatalysis.enable()
11# Specify the minimization criteria:
12# number of unique reactions used
13flow.objectiveFunction = isEdgeUsed
14# Find a solution:
15flow.findSolutions()
16# Show solution information in the terminal:
17flow.solutions.list()
18# Print solutions:
19flow.solutions.print()