Commit 1fff6d4a authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

minor edits

parent 6e0967bf
...@@ -12,17 +12,18 @@ Tcutoff = 100 # temperature above which strain isn't happening ...@@ -12,17 +12,18 @@ Tcutoff = 100 # temperature above which strain isn't happening
[σ̄*0.375 σ̄*0.375 σ̄*0.75 ] [σ̄*0.375 σ̄*0.375 σ̄*0.75 ]
] ]
ABS = material(α_ABS, E_ABS, σ̄_ABS, Tcutoff) ABS = material(α_ABS, E_ABS, σ̄_ABS, Tcutoff)
td = tempdecay(215, 25, 0.04) # extrusion temp, room temp, decay rate tdmed = tempdecay(215, 25, 0.04) # extrusion temp, room temp, decay rate
tdslow = tempdecay(215, 25, 0.01) tdslow = tempdecay(215, 25, 0.01)
tdfast = tempdecay(215, 25, 0.08) tdfast = tempdecay(215, 25, 0.08)
# visualise_tempdecay(tdfast) visualise_tempdecay(tdslow)
td=tdmed
add = "/Users/jayant/phd/tempaware/models/" add = "/Users/jayant/phd/tempaware/models/"
### MAIN LOOP ### MAIN LOOP
results = JSON.parse(open(add * "results.json")) results = Dict()# JSON.parse(open(add * "results.json"))
n_local_searches = 100 n_local_searches = 100
max_iterations = 250 max_iterations = 250
k = 150 k = 150
...@@ -36,6 +37,7 @@ obj_add = add * obj ...@@ -36,6 +37,7 @@ obj_add = add * obj
contours = clean_contour.(contour.(JSON.parse(open(obj_add * "contours.json")))) contours = clean_contour.(contour.(JSON.parse(open(obj_add * "contours.json"))))
cdata = contourdata(contours, 40, 2) # contour data cdata = contourdata(contours, 40, 2) # contour data
@time vd = voxdata(obj_add * "_voxels.csv", cdata) @time vd = voxdata(obj_add * "_voxels.csv", cdata)
stress_multiplier!(vd.voxels,10)
println("Constructing Cost function...") println("Constructing Cost function...")
construct_cost(cdata, vd, ABS, td, f_name) construct_cost(cdata, vd, ABS, td, f_name)
construct_cost_hist(cdata, vd, ABS, td) construct_cost_hist(cdata, vd, ABS, td)
...@@ -57,15 +59,15 @@ plot(rl_g) ...@@ -57,15 +59,15 @@ plot(rl_g)
println("Doing local search " * string(n_local_searches) * " times") println("Doing local search " * string(n_local_searches) * " times")
#Threads.@threads #Threads.@threads
for i in 1:n_local_searches for i in 1:n_local_searches
rl = random_rollout(cdata) rl = greedish_rollout(cdata)
random_cost = cost_func(rl) # change to random random_cost = cost_func(rl) # change to random
println("RANDOM COST: " * string(random_cost)) # println("RANDOM COST: " * string(random_cost))
update_result(results, obj, rl, random_cost, :random) update_result(results, obj, rl, random_cost, :greedish)
local_cost = local_search!(rl, max_iterations) local_cost = local_search!(rl, max_iterations)
println("LOCAL COST: " * string(local_cost)) # println("LOCAL COST: " * string(local_cost))
update_result(results, obj, rl, local_cost, :local) update_result(results, obj, rl, local_cost, :local)
end end
results[obj] println(results[obj])
save_result(results, add * "results.json") save_result(results, add * "results.json")
...@@ -105,22 +107,22 @@ histogram( ...@@ -105,22 +107,22 @@ histogram(
bins=50, bins=50,
label="Default " * string(sum(c_d)), label="Default " * string(sum(c_d)),
title=obj, title=obj,
opacity=0.5, opacity=0.3,
c=:blue) c=:blue)
vline!([maximum(c_d)], c=:blue) vline!([maximum(c_d)], c=:blue, label="Max Default")
c_g = cost_hist(rl_g) c_g = cost_hist(rl_g)
histogram!( histogram!(
c_g, c_g,
bins=50, bins=50,
label="greedy " * string(sum(c_g)), label="greedy " * string(sum(c_g)),
opacity=0.5, opacity=0.3,
c=:orange) c=:orange)
vline!([maximum(c_g)], c=:orange) vline!([maximum(c_g)], c=:orange, label="Max Greedy")
c_l = cost_hist(rl_l) c_l = cost_hist(rl_l)
histogram!( histogram!(
c_l, c_l,
bins=50, bins=50,
label="local_search " * string(sum(c_l)), label="local_search " * string(sum(c_l)),
opacity=0.5, opacity=0.3,
c=:green) c=:green)
vline!([maximum(c_l)], c=:green) vline!([maximum(c_l)], c=:green, label="Max Local")
\ No newline at end of file \ No newline at end of file
...@@ -739,6 +739,7 @@ function construct_cost_hist(cdata::contourdata, vd::voxdata, mat::material, td: ...@@ -739,6 +739,7 @@ function construct_cost_hist(cdata::contourdata, vd::voxdata, mat::material, td:
println(size(rel_voxels)[1]) println(size(rel_voxels)[1])
relmaps = vd.maps relmaps = vd.maps
vox_area_scaling = min.(abs.(1 ./ rel_voxels.AreaRatio),1) vox_area_scaling = min.(abs.(1 ./ rel_voxels.AreaRatio),1)
#vox_area_scaling = ones(length(1 ./ rel_voxels.AreaRatio))
# voxtimes vectorize # voxtimes vectorize
max_contours_per_voxel = maximum([length(r.seglen) for r in relmaps]) max_contours_per_voxel = maximum([length(r.seglen) for r in relmaps])
......
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