Skip to content

Commit 3196516

Browse files
committed
Merge branch 'feat/slurm-scripts'
2 parents 26e1825 + 567d8f4 commit 3196516

15 files changed

+577
-2
lines changed

experiments/SynthBN/Manifest.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.10.2"
44
manifest_format = "2.0"
5-
project_hash = "fd9224065ab8021d5bbf7e628f90127acd4a668b"
5+
project_hash = "7f5a84f27789614a8f5a49e495609da6e55f2159"
66

77
[[deps.ADTypes]]
88
git-tree-sha1 = "eea5d80188827b35333801ef97a40c2ed653b081"
@@ -164,6 +164,12 @@ version = "1.1.0"
164164
[[deps.Base64]]
165165
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
166166

167+
[[deps.BenchmarkTools]]
168+
deps = ["JSON", "Logging", "Printf", "Profile", "Statistics", "UUIDs"]
169+
git-tree-sha1 = "f1dff6729bc61f4d49e140da1af55dcd1ac97b2f"
170+
uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
171+
version = "1.5.0"
172+
167173
[[deps.BitFlags]]
168174
git-tree-sha1 = "0691e34b3bb8be9307330f88d1a3c3f25466c24d"
169175
uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35"
@@ -1935,6 +1941,10 @@ version = "2.4.0"
19351941
deps = ["Unicode"]
19361942
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
19371943

1944+
[[deps.Profile]]
1945+
deps = ["Printf"]
1946+
uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
1947+
19381948
[[deps.ProgressBars]]
19391949
deps = ["Printf"]
19401950
git-tree-sha1 = "b437cdb0385ed38312d91d9c00c20f3798b30256"

experiments/SynthBN/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name = "SynthBN"
22

33
[deps]
44
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
5+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
56
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
67
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
78
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
@@ -19,6 +20,7 @@ HerbSearch = "3008d8e8-f9aa-438a-92ed-26e9c7b4829f"
1920
HerbSpecification = "6d54aada-062f-46d8-85cf-a1ceaf058a06"
2021
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
2122
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
23+
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
2224
MetaGraphsNext = "fa8bd995-216d-47f1-8a91-f3b68fbeb377"
2325
ParserCombinator = "fae87a5f-d1ad-5cf0-8f61-c941e1580b46"
2426
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a"
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
### A Pluto.jl notebook ###
2+
# v0.20.1
3+
4+
using Markdown
5+
using InteractiveUtils
6+
7+
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
8+
macro bind(def, element)
9+
quote
10+
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
11+
local el = $(esc(element))
12+
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el)
13+
el
14+
end
15+
end
16+
17+
# ╔═╡ 172d1c64-9528-11ef-1455-69f3dc33e1c4
18+
using DrWatson
19+
20+
# ╔═╡ 49710c05-a20a-473f-9569-0579a35b8093
21+
@quickactivate
22+
23+
# ╔═╡ 1d98adb9-5beb-476c-84db-5e6ccaf8841b
24+
using DataFrames
25+
26+
# ╔═╡ a65b8474-8d7c-423a-9700-fda5a13e3622
27+
using JLD2
28+
29+
# ╔═╡ 15b53ea1-57cb-45a6-9f15-e18bd9b8df29
30+
using DynamicalSystems
31+
32+
# ╔═╡ 7f760eb1-a3ab-4599-8d24-58696e67c36d
33+
using Plots
34+
35+
# ╔═╡ 77d6b0bc-cd28-46ed-b2f5-56eb94efc659
36+
using PlutoUI
37+
38+
# ╔═╡ 6b843080-264a-4e30-a1fb-d05fb77ae526
39+
function split_state_space(trajectory::StateSpaceSet)
40+
# split into pairs of input (all values) and output (changed value)
41+
input_output_pairs_per_node = Dict{Int,Set{Tuple{Vector{Int},Int}}}()
42+
for i = 1:length(trajectory)-1
43+
changed = findfirst(trajectory[i+1] .!= trajectory[i])
44+
# only proceed if there was a change
45+
if !isnothing(changed)
46+
47+
# in real data we don't know the direction of the transition
48+
# was it from i -> i+1 or i+1 -> i, we only know that two
49+
# states are adjacent, so for gathering data, we add both
50+
# directions as IO pairs
51+
# 1. state `i` and the new value of the single variable in
52+
# the state that changed
53+
# 2. state `i+1` and the previous value of the single variable
54+
# in the state that changed
55+
56+
new_value = trajectory[i+1][changed]
57+
old_value = trajectory[i][changed]
58+
existing_pairs =
59+
get(input_output_pairs_per_node, changed, Set{Tuple{Vector{Int},Int}}())
60+
push!(
61+
existing_pairs,
62+
(trajectory[i], new_value), # 1
63+
(trajectory[i+1], old_value), # 2
64+
)
65+
input_output_pairs_per_node[changed] = existing_pairs
66+
end
67+
end
68+
69+
return input_output_pairs_per_node
70+
end
71+
72+
# ╔═╡ 85379de4-3258-4471-b43c-75c65aea0b10
73+
fname = "id=189_iterations=1000_n_trajectories=1000.jld2"
74+
75+
# ╔═╡ f2c8a3fa-61b5-4f39-b5f6-3329eba23ede
76+
pname = joinpath(datadir("sims", "biodivine_trajectories"), fname)
77+
78+
# ╔═╡ 59dafbbe-086d-4fe6-b01c-e13ab8dc7d80
79+
res = load(pname)
80+
81+
# ╔═╡ 1ce04619-14b1-4a4b-bc65-40dfdcae2c74
82+
anim = @animate for i in eachindex(res["trajectories"])
83+
heatmap(Matrix(res["trajectories"][i]))
84+
end
85+
86+
# ╔═╡ b36271d5-f908-4e65-b0fa-9175e8c2416c
87+
# gif(anim)
88+
89+
# ╔═╡ 436fc3d5-fbf5-46b4-a6fd-3f8c97a00a47
90+
traj = res["trajectories"]
91+
92+
# ╔═╡ 25966e19-4f35-4b3e-b60a-238cc182fbc9
93+
@bind ind Slider(1:1000)
94+
95+
# ╔═╡ de871eaa-0991-4b3d-8c81-fd8afb284df7
96+
heatmap(Matrix(res["trajectories"][ind]))
97+
98+
# ╔═╡ fe295564-151a-4325-9c4a-f47963ede398
99+
split_applied = [split_state_space(t) for t in traj]
100+
101+
# ╔═╡ 17f352fc-6f4e-4d7d-ad7a-d6d2ac049ada
102+
begin
103+
name = tempname()
104+
name *= ".jld2"
105+
save(name, @strdict split_applied)
106+
end
107+
108+
# ╔═╡ 947a965d-54f5-40e3-b703-4a18bf671d9c
109+
filesize(name) * 1e-6
110+
111+
# ╔═╡ 3c443200-79f9-4288-8989-6c06408240d5
112+
filesize(pname) * 1e-6
113+
114+
# ╔═╡ 5ca0375d-d325-4831-85c4-17e871dc5a8b
115+
name
116+
117+
# ╔═╡ Cell order:
118+
# ╠═172d1c64-9528-11ef-1455-69f3dc33e1c4
119+
# ╠═49710c05-a20a-473f-9569-0579a35b8093
120+
# ╠═1d98adb9-5beb-476c-84db-5e6ccaf8841b
121+
# ╠═a65b8474-8d7c-423a-9700-fda5a13e3622
122+
# ╠═15b53ea1-57cb-45a6-9f15-e18bd9b8df29
123+
# ╠═7f760eb1-a3ab-4599-8d24-58696e67c36d
124+
# ╠═6b843080-264a-4e30-a1fb-d05fb77ae526
125+
# ╠═85379de4-3258-4471-b43c-75c65aea0b10
126+
# ╠═f2c8a3fa-61b5-4f39-b5f6-3329eba23ede
127+
# ╠═59dafbbe-086d-4fe6-b01c-e13ab8dc7d80
128+
# ╠═1ce04619-14b1-4a4b-bc65-40dfdcae2c74
129+
# ╠═b36271d5-f908-4e65-b0fa-9175e8c2416c
130+
# ╠═436fc3d5-fbf5-46b4-a6fd-3f8c97a00a47
131+
# ╠═77d6b0bc-cd28-46ed-b2f5-56eb94efc659
132+
# ╠═25966e19-4f35-4b3e-b60a-238cc182fbc9
133+
# ╠═de871eaa-0991-4b3d-8c81-fd8afb284df7
134+
# ╠═fe295564-151a-4325-9c4a-f47963ede398
135+
# ╠═17f352fc-6f4e-4d7d-ad7a-d6d2ac049ada
136+
# ╠═947a965d-54f5-40e3-b703-4a18bf671d9c
137+
# ╠═3c443200-79f9-4288-8989-6c06408240d5
138+
# ╠═5ca0375d-d325-4831-85c4-17e871dc5a8b
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using DrWatson
2+
3+
@quickactivate :SynthBN
4+
5+
using BenchmarkTools
6+
using SoleLogics
7+
using MLStyle
8+
9+
import SoleLogics.interpret
10+
11+
function interpret::Expr, i::SoleLogics.AbstractInterpretation, args...; kwargs...)
12+
syntax_branch = @match φ begin
13+
Expr(:call, :Atom, val) => interpret(Atom(val), i, args...; kwargs...)
14+
Expr(:call, :, children...) => interpret(
15+
SyntaxBranch(, [interpret(ch, i, args...; kwargs...) for ch in children]...),
16+
i,
17+
args...;
18+
kwargs...,
19+
)
20+
Expr(:call, :, children...) => interpret(
21+
SyntaxBranch(, [interpret(ch, i, args...; kwargs...) for ch in children]...),
22+
i,
23+
args...;
24+
kwargs...,
25+
)
26+
Expr(:call, :¬, child) => interpret(
27+
SyntaxBranch(¬, interpret(child, i, args...; kwargs...)),
28+
i,
29+
args...;
30+
kwargs...,
31+
)
32+
_ => error("missing a match for ")
33+
end
34+
35+
return interpret(syntax_branch, i, args...; kwargs...)
36+
end
37+
38+
function benchmark()
39+
exprs = [
40+
:(
41+
Atom(0) Atom(1) Atom(1) Atom(1) Atom(1) Atom(1) Atom(1) Atom(1) Atom(1) Atom(1)
42+
),
43+
:(Atom("a") Atom("b")),
44+
:(
45+
(¬Atom("v_cGSH_GSSG_b1") Atom("v_cGR_b1"))
46+
(Atom("v_cGSH_GSSG_b1") ¬Atom("v_cGSH_GSSG_b2") Atom("v_cGR_b1"))
47+
(Atom("v_cGSH_GSSG_b1") Atom("v_cGSH_GSSG_b2"))
48+
),
49+
:((¬Atom(1) Atom(2)) (Atom(3) ¬Atom(4) Atom(5)) (Atom(6) Atom(7))),
50+
]
51+
52+
for expr in exprs
53+
syntax_branch = eval(expr)
54+
55+
td = TruthDict([0 => ⊤, 1 => ⊤])
56+
57+
eval_version = @benchmarkable interpret(eval($expr), $td)
58+
custom_eval_version = @benchmarkable interpret($expr, $td)
59+
no_eval_version = @benchmarkable interpret($syntax_branch, $td)
60+
61+
@info "Tuning"
62+
tune!(eval_version)
63+
tune!(custom_eval_version)
64+
tune!(no_eval_version)
65+
66+
@info "Running"
67+
m_eval = median(run(eval_version))
68+
m_custom_eval = median(run(custom_eval_version))
69+
m_no_eval = median(run(no_eval_version))
70+
71+
@info "Normal Eval vs. No Eval at all"
72+
@info judge(m_eval, m_no_eval)
73+
74+
@info "Custom interpret without eval vs normal interpret without eval"
75+
@info judge(m_custom_eval, m_no_eval)
76+
77+
@info "Custom interpret vs. just eval"
78+
@info judge(m_custom_eval, m_eval)
79+
end
80+
81+
end
82+
83+
benchmark()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
#SBATCH --job-name=makezip
4+
#SBATCH --partition=compute
5+
#SBATCH --time=02:00:00
6+
#SBATCH --ntasks=1
7+
#SBATCH --cpus-per-task=1
8+
#SBATCH --mem-per-cpu=4G
9+
#SBATCH --account=innovation
10+
11+
# Load modules:
12+
module load 2024r1
13+
14+
zip -r /scratch/rjgardosreid/traj_backup.zip data/sims/biodivine_trajectories/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
#SBATCH --job-name=makezipall
4+
#SBATCH --partition=compute
5+
#SBATCH --time=02:00:00
6+
#SBATCH --ntasks=1
7+
#SBATCH --cpus-per-task=1
8+
#SBATCH --mem-per-cpu=4G
9+
#SBATCH --account=innovation
10+
11+
# Load modules:
12+
module load 2024r1
13+
14+
zip -r /scratch/rjgardosreid/synthbn_backup.zip data/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
#SBATCH --job-name=makezip
4+
#SBATCH --partition=compute
5+
#SBATCH --time=01:00:00
6+
#SBATCH --ntasks=1
7+
#SBATCH --cpus-per-task=1
8+
#SBATCH --mem-per-cpu=4G
9+
#SBATCH --account=innovation
10+
11+
# Load modules:
12+
module load 2024r1
13+
14+
zip -r /scratch/rjgardosreid/synth_results.zip data/exp_raw/biodivine_search/
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
#SBATCH --job-name=pluto
4+
#SBATCH --partition=compute
5+
#SBATCH --time=02:00:00
6+
#SBATCH --ntasks=1
7+
#SBATCH --cpus-per-task=4
8+
#SBATCH --mem-per-cpu=1G
9+
#SBATCH --account=innovation
10+
11+
# Load modules:
12+
module load 2024r1
13+
module load julia
14+
15+
echo Starting Pluto 🎈
16+
17+
srun julia --project=. -e 'using Pluto; Pluto.run(host="0.0.0.0", port=1234, launch_browser=false)' > pluto_output.txt

0 commit comments

Comments
 (0)