Dateien nach "mod/butadien" hochladen
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#config.ilp.solver="CPLEX"
|
config.ilp.solver="CPLEX"
|
||||||
#import mod
|
#import mod
|
||||||
#from mod import *
|
#from mod import *
|
||||||
import networkx as nx
|
import networkx as nx
|
||||||
@@ -6,6 +6,22 @@ import networkx as nx
|
|||||||
# import Graph class from graph.py
|
# import Graph class from graph.py
|
||||||
from graph import GraphObj
|
from graph import GraphObj
|
||||||
|
|
||||||
|
#ethylen = Graph.fromGMLString(
|
||||||
|
"""graph [
|
||||||
|
node [ id 0 label "H" ]
|
||||||
|
node [ id 1 label "H" ]
|
||||||
|
node [ id 2 label "C" ]
|
||||||
|
node [ id 3 label "C" ]
|
||||||
|
node [ id 4 label "H" ]
|
||||||
|
node [ id 5 label "H" ]
|
||||||
|
edge [ source 0 target 2 label "-" ]
|
||||||
|
edge [ source 1 target 2 label "-" ]
|
||||||
|
edge [ source 2 target 3 label "=" ]
|
||||||
|
edge [ source 3 target 4 label "-" ]
|
||||||
|
edge [ source 3 target 5 label "-" ]
|
||||||
|
]"""
|
||||||
|
#, name="Ethylen")
|
||||||
|
|
||||||
butadien = Graph.fromGMLString(
|
butadien = Graph.fromGMLString(
|
||||||
"""graph [
|
"""graph [
|
||||||
node [ id 0 label "C" ]
|
node [ id 0 label "C" ]
|
||||||
@@ -30,6 +46,37 @@ butadien = Graph.fromGMLString(
|
|||||||
]"""
|
]"""
|
||||||
, name="Butadien")
|
, name="Butadien")
|
||||||
|
|
||||||
|
#benzene = Graph.fromSMILES('c1=cc=cc=c1')
|
||||||
|
|
||||||
|
#benzene = Graph.fromGMLString(
|
||||||
|
"""graph [
|
||||||
|
node [ id 0 label "C" ]
|
||||||
|
node [ id 1 label "H" ]
|
||||||
|
node [ id 2 label "C" ]
|
||||||
|
node [ id 3 label "H" ]
|
||||||
|
node [ id 4 label "C" ]
|
||||||
|
node [ id 5 label "H" ]
|
||||||
|
node [ id 6 label "C" ]
|
||||||
|
node [ id 7 label "H" ]
|
||||||
|
node [ id 8 label "C" ]
|
||||||
|
node [ id 9 label "H" ]
|
||||||
|
node [ id 10 label "C" ]
|
||||||
|
node [ id 11 label "H" ]
|
||||||
|
edge [ source 0 target 1 label "-" ]
|
||||||
|
edge [ source 0 target 2 label "=" ]
|
||||||
|
edge [ source 2 target 3 label "-" ]
|
||||||
|
edge [ source 2 target 4 label "-" ]
|
||||||
|
edge [ source 4 target 5 label "-" ]
|
||||||
|
edge [ source 4 target 6 label "=" ]
|
||||||
|
edge [ source 6 target 7 label "-" ]
|
||||||
|
edge [ source 6 target 8 label "-" ]
|
||||||
|
edge [ source 8 target 9 label "-" ]
|
||||||
|
edge [ source 8 target 10 label "=" ]
|
||||||
|
edge [ source 10 target 11 label "-" ]
|
||||||
|
edge [ source 10 target 0 label "-" ]
|
||||||
|
]"""
|
||||||
|
#, name="Benzene")
|
||||||
|
|
||||||
|
|
||||||
#pentadien = Graph.fromGMLString(
|
#pentadien = Graph.fromGMLString(
|
||||||
"""graph
|
"""graph
|
||||||
@@ -113,10 +160,16 @@ dielsalder = Rule.fromGMLString(
|
|||||||
def cyclesizes(g):
|
def cyclesizes(g):
|
||||||
nxGraph = GraphObj(g).nx_graph
|
nxGraph = GraphObj(g).nx_graph
|
||||||
|
|
||||||
#Chein restrictions: (No steric reason)
|
#Restriction to E/Z? Benzen can't be created or consumed by the reaction due to steric difficulties
|
||||||
paths = sorted(list(nx.all_simple_paths(nxGraph)))
|
|
||||||
if max(paths > 12):
|
#Chain restrictions: (No steric reason)
|
||||||
return True
|
for nodestart in nxGraph.nodes:
|
||||||
|
for nodeend in nxGraph.nodes:
|
||||||
|
if nodeend != nodestart:
|
||||||
|
paths = sorted(list(nx.all_shortest_paths(nxGraph, nodestart, nodeend)))
|
||||||
|
for path in paths:
|
||||||
|
if len(path) > 10: #First node included in length
|
||||||
|
return True
|
||||||
|
|
||||||
#Cycle restrictions:
|
#Cycle restrictions:
|
||||||
cycles = sorted(list(nx.chordless_cycles(nxGraph)))
|
cycles = sorted(list(nx.chordless_cycles(nxGraph)))
|
||||||
@@ -137,7 +190,7 @@ def cyclesizes(g):
|
|||||||
if cycle != cycleref and len(list(set(cycle) & set(cycleref))) >= 3:
|
if cycle != cycleref and len(list(set(cycle) & set(cycleref))) >= 3:
|
||||||
return True
|
return True
|
||||||
#Only cordless cycles of length 5,6 and 7 are acceptable
|
#Only cordless cycles of length 5,6 and 7 are acceptable
|
||||||
if min(cycle_lengths) >= 5 and max(cycle_lengths) <=7:
|
if min(cycle_lengths) >= 6 and max(cycle_lengths) <=6:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -154,9 +207,6 @@ def doubledoublebond(g):
|
|||||||
|
|
||||||
|
|
||||||
def restriction(dg):
|
def restriction(dg):
|
||||||
#Only rings 5 to 7
|
|
||||||
#No neighbouring double bonds. Is this already in MOD? Can this even happen?
|
|
||||||
#No Carbon in 3 rings? Better 4?
|
|
||||||
for a in dg.right:
|
for a in dg.right:
|
||||||
if a.vLabelCount("C") > 10:
|
if a.vLabelCount("C") > 10:
|
||||||
return False
|
return False
|
||||||
@@ -176,7 +226,8 @@ postSection("Loaded Rules")
|
|||||||
for a in inputRules:
|
for a in inputRules:
|
||||||
a.print()
|
a.print()
|
||||||
|
|
||||||
|
ethylen = Graph.fromSMILES('C=C')
|
||||||
|
goal = Graph.fromSMILES('C1C=CC=CC=1')
|
||||||
dg = DG(graphDatabase=inputGraphs)
|
dg = DG(graphDatabase=inputGraphs)
|
||||||
dg.build().execute(
|
dg.build().execute(
|
||||||
addSubset(inputGraphs)
|
addSubset(inputGraphs)
|
||||||
@@ -185,18 +236,26 @@ dg.build().execute(
|
|||||||
](
|
](
|
||||||
repeat(revive(inputRules)) #Revive not necessary
|
repeat(revive(inputRules)) #Revive not necessary
|
||||||
)
|
)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
print([str(a.graph.name) for a in dg.vertices])
|
||||||
|
print([str(a.graph.smiles) for a in dg.vertices])
|
||||||
dg.print()
|
dg.print()
|
||||||
postSection("Product Graphs")
|
postSection("Product Graphs")
|
||||||
for a in dg.vertices:
|
for a in dg.vertices:
|
||||||
a.graph.print()
|
a.graph.print()
|
||||||
|
flow = Flow(dg)
|
||||||
|
flow.addSource(butadien)
|
||||||
|
|
||||||
#flow = Flow(dg)
|
flow.addSink(ethylen)
|
||||||
#flow.addSource(butadien)
|
flow.addSink(goal)
|
||||||
#flow.findSolutions()
|
flow.addConstraint(inFlow[butadien] >= 2)
|
||||||
#flow.solutions.list()
|
#flow.addConstraint(outFlow[ethylen] == 1)
|
||||||
#flow.solutions.print(flowPrinter)
|
flow.addConstraint(outFlow[goal] == 1)
|
||||||
|
flow.findSolutions(maxNumSolutions=3)
|
||||||
|
flow.solutions.list()
|
||||||
|
flow.solutions.print(flowPrinter)
|
||||||
|
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user