improve performance and finish generate_options()

This commit is contained in:
2023-06-13 13:48:23 +02:00
parent dd36d6ef7a
commit e3e9ad3a0e
7 changed files with 154 additions and 108 deletions

View File

@ -1,5 +1,6 @@
# functions for importing DAGs from a file
using Printf
# functions for importing DAGs from a file
regex_a = r"^[A-C]\d+$" # Regex for the initial particles
regex_c = r"^[A-C]\(([^']*),([^']*)\)$" # Regex for the combinations of 2 particles
regex_m = r"^M\(([^']*),([^']*),([^']*)\)$" # Regex for the combinations of 3 particles
@ -22,10 +23,12 @@ end
function importTxt(filename::String)
file = open(filename, "r")
println("Opened file")
nodes_string = readline(file)
nodes = parse_nodes(nodes_string)
close(file)
println("Read file")
graph = DAG()
@ -36,7 +39,15 @@ function importTxt(filename::String)
# remember the data out nodes for connection
dataOutNodes = Dict()
for node in nodes
println("Building graph")
noNodes = 0
nodesToRead = length(nodes)
while !isempty(nodes)
node = popfirst!(nodes)
noNodes += 1
if (noNodes % 100 == 0)
@printf "\rReading Nodes... %.2f%%" (100. * noNodes / nodesToRead)
end
if occursin(regex_a, node)
# add nodes and edges for the state reading to u(P(Particle))
data_in = insert_node(graph, make_node(DataTask(4))) # read particle data node
@ -116,7 +127,7 @@ function importTxt(filename::String)
insert_edge(graph, make_edge(data_out, sum_node))
elseif occursin(regex_plus, node)
println("Found sum node, end")
println("\rReading Nodes Complete ")
else
error("Unknown node '", node, "' while reading from file ", filename)
end