Commit 74e410b1 authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

greedily weighted random rollout

parent 1bea8ed8
......@@ -51,7 +51,7 @@ for i in 1:n_models
println("Loading data...")
obj_add = add * obj
contours = clean_contour.(contour.(JSON.parse(open(obj_add * "contours.json"))))
cdata = contourdata(contours, 40, 5) # contour data
cdata = contourdata(contours, 40, 10) # contour data
println(string(length(cdata.contours)) * " contours")
vd = voxdata(obj_add * "_voxels.csv", cdata)
println("Constructing Cost function...")
......@@ -90,7 +90,7 @@ save_result(results, add * "results.json")
obj = "M1"
obj_add = add * obj
contours = clean_contour.(contour.(JSON.parse(open(obj_add * "contours.json"))))
cdata = contourdata(contours, 40, 5) # contour data
cdata = contourdata(contours, 40, 10) # contour data
vd = voxdata(obj_add * "_voxels.csv", cdata)
......
......@@ -468,6 +468,61 @@ function greedy_rollout(cdata::contourdata)
end
function greedish_rollout(cdata::contourdata)
done_contours = Set{Int}()
avail_contours = Set(cdata.layers[1])
todo_contours = Set(1:length(cdata.contours))
rollout = Vector{Int}()
contour_order = zeros(length(cdata.contours))
dep_times = zeros(length(cdata.contours))
while length(avail_contours) > 0
# get average times of dependency completion
for c in avail_contours
deps = inneighbors(cdata.G, c)
if length(deps) == 0
dep_times[c] = 1
continue
end
dep_times[c] = mean(contour_order[deps])
end
temp_avail_list = collect(avail_contours)
_,i = findmax(dep_times[temp_avail_list])
c = temp_avail_list[i] # contour with deps printed most recently
push!(rollout, c)
contour_order[c] = length(rollout)
# remove selected contour from todo and avail, add to done
delete!(avail_contours, c)
delete!(todo_contours, c)
push!(done_contours, c)
# update available contours
for i in todo_contours
if i in avail_contours
continue
elseif length(inneighbors(cdata.G, i)) == 0
push!(avail_contours, i)
continue
end
add = true
for j in inneighbors(cdata.G, i)
if !(j in done_contours)
add = false
break
end
end
if add
push!(avail_contours, i)
end
end
end
return rollout
end
function valid_swap(rollout::Vector{Int}, i::Int, j::Int, cdata::contourdata)
# would swapping indices i and j in rollout result in another valid rollout?
# NOTE THIS FUNCTION DOESNT WORK
......
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