Commit 3ce8c051 authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

check validity function to double check a rollout

parent a7999e9f
...@@ -345,7 +345,6 @@ function valid_swap(rollout::Vector{Int}, i::Int, j::Int, prob::problem) ...@@ -345,7 +345,6 @@ function valid_swap(rollout::Vector{Int}, i::Int, j::Int, prob::problem)
c1_dependents = outneighbors(prob.G, c1) c1_dependents = outneighbors(prob.G, c1)
c_between = rollout[i+1:j-1] c_between = rollout[i+1:j-1]
# method 2
for c in c_between for c in c_between
if c in c1_dependents || c in c2_dependson if c in c1_dependents || c in c2_dependson
return false return false
...@@ -356,6 +355,23 @@ function valid_swap(rollout::Vector{Int}, i::Int, j::Int, prob::problem) ...@@ -356,6 +355,23 @@ function valid_swap(rollout::Vector{Int}, i::Int, j::Int, prob::problem)
end end
function check_validity(rollout::Vector{Int}, prob::problem)
# make sure a given rollout is valid
done_contours = Set{Int}()
for c in rollout
c_dependson = inneighbors(prob.G, c)
if !issubset(c_dependson, done_contours)
return false
end
push!(done_contours, c)
end
return true
end
#voxels = DataFrames.DataFrame(CSV.File("tensile-1-1.csv")) #voxels = DataFrames.DataFrame(CSV.File("tensile-1-1.csv"))
contours = contour.(JSON.parse(open("tensilecontours.json"))) contours = contour.(JSON.parse(open("tensilecontours.json")))
dt = problem(contours, 5, 5) dt = problem(contours, 5, 5)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment