Commit 5d54b998 authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

bug fixes to laod in data

parent 11f088d1
......@@ -8,7 +8,7 @@ using BenchmarkTools
using Plots
struct contour
mutable struct contour
pos
time
end
......@@ -162,6 +162,10 @@ function voxmap(vox::Vector{Float64}, vox_d::Number, cdata::contourdata)
seglen_sofar = 0
t_start = 0
if l > length(cdata.layers)
return voxmap(seglen, segoffset, segcontours)
end
for cid in cdata.layers[l]
c = cdata.contours[cid]
......@@ -324,6 +328,7 @@ end
function voxdata(fname::String, cdata::contourdata)
voxels = DataFrames.DataFrame(CSV.File(fname))
w = dist(Vector(voxels[1, ["x","y","z"]]), Vector(voxels[2, ["x","y","z"]]))
println("Assumed width ", w)
vpos = [[v.x, v.y, v.z] for v in eachrow(voxels)]
voxms = [voxmap(v, w, cdata) for v in vpos]
below = indexin([v - [0,0,cdata.layer_height] for v in vpos], vpos)
......@@ -507,9 +512,19 @@ function construct_cost(cdata::contourdata)
return eval(ex2) # return the contructed function
end
function clean_contour(c::contour)
# remove first element of array if second element is the same
while c.pos[1,:] == c.pos[2,:]
c.pos = c.pos[2:end, :]
end
return c
end
contours = contour.(JSON.parse(open("tensilecontours.json")))
obj = "/Users/jayant/phd/tempaware/" * "M1"
contours = clean_contour.(contour.(JSON.parse(open(obj * "contours.json"))))
cdata = contourdata(contours, 5, 5) # contour data
vd = voxdata("tensile-1-1.csv", cdata)
@benchmark random_rollout(cdata)
vd = voxdata(obj * "_voxels.csv", cdata) # TODO Need to debug
@benchmark rl = random_rollout(cdata) # 20/second
@benchmark valid_swap(rl, rand(1:length(contours)), rand(1:length(contours)), cdata) # 1mil/second
rl = random_rollout(cdata)
\ No newline at end of file
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