Commit 6e0967bf authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

square to make high cost voxels more expensive

parent 6f4c52dd
......@@ -56,8 +56,8 @@ plot(rl_g)
# local search
println("Doing local search " * string(n_local_searches) * " times")
#Threads.@threads
for i in 1:1#n_local_searches
rl = greedy_rollout(cdata)
for i in 1:n_local_searches
rl = random_rollout(cdata)
random_cost = cost_func(rl) # change to random
println("RANDOM COST: " * string(random_cost))
update_result(results, obj, rl, random_cost, :random)
......@@ -65,6 +65,7 @@ for i in 1:1#n_local_searches
println("LOCAL COST: " * string(local_cost))
update_result(results, obj, rl, local_cost, :local)
end
results[obj]
save_result(results, add * "results.json")
......@@ -77,7 +78,7 @@ histogram(data) # vast majority of voxels near 0 stress - can ignore
histogram!(sort(data, rev=true)[1:1000]) # vast majority of voxels near 0 stress - can ignore
# voxmap sanity check
plot(vd, 1000, cdata)
# plot(vd, 1000, cdata)
# rollouts
rl_d = Vector(1:length(cdata.contours))
......@@ -98,19 +99,28 @@ plot(rl_l, cdata)
plot(results)
# plot before and after histograms
c_d = cost_hist(rl_d)
histogram(
cost_hist(rl_d),
c_d,
bins=50,
label="Default " * string(sum(cost_hist(rl_d))),
label="Default " * string(sum(c_d)),
title=obj,
opacity=0.5)
opacity=0.5,
c=:blue)
vline!([maximum(c_d)], c=:blue)
c_g = cost_hist(rl_g)
histogram!(
cost_hist(rl_g),
c_g,
bins=50,
label="greedy " * string(sum(cost_hist(rl_g))),
opacity=0.5)
label="greedy " * string(sum(c_g)),
opacity=0.5,
c=:orange)
vline!([maximum(c_g)], c=:orange)
c_l = cost_hist(rl_l)
histogram!(
cost_hist(rl_l),
c_l,
bins=50,
label="local_search " * string(sum(cost_hist(rl_l))),
opacity=0.5)
\ No newline at end of file
label="local_search " * string(sum(c_l)),
opacity=0.5,
c=:green)
vline!([maximum(c_l)], c=:green)
\ No newline at end of file
......@@ -710,10 +710,10 @@ function construct_cost(cdata::contourdata, vd::voxdata, mat::material, td::temp
σ12 = rel_v.Txy
σ23 = rel_v.Tyz + $((cdata.layer_height/vd.width)*mat.E*mat.α)*ΔT
σ31 = rel_v.Txy + $((cdata.layer_height/vd.width)*mat.E*mat.α)*ΔT
return sum($vox_area_scaling .* ($F * (σ11 - σ22).^2 +
return sum(($vox_area_scaling .* ($F * (σ11 - σ22).^2 +
$G * ((σ33 - σ11).^2 + (σ33 - σ22).^2) +
$(2 * L) * (σ12).^2 +
$(2 * M) * (σ23 + σ31).^2))
$(2 * M) * (σ23 + σ31).^2)).^2)
end
end
return eval(a)
......@@ -729,7 +729,7 @@ function construct_cost_hist(cdata::contourdata, vd::voxdata, mat::material, td:
not_empty_voxels = length.([m.seglen for m in vd.maps]) .>0
valid_voxels = (1:length(vd.below))[(vd.below.!=0) .& not_empty_voxels]
valid_voxels = valid_voxels[not_empty_voxels[vd.below[valid_voxels]]]
println("n empty voxels:")
println("n non-empty voxels:")
println(sum(not_empty_voxels))
considered_voxels = valid_voxels
......@@ -738,6 +738,7 @@ function construct_cost_hist(cdata::contourdata, vd::voxdata, mat::material, td:
println("n valid voxels:")
println(size(rel_voxels)[1])
relmaps = vd.maps
vox_area_scaling = min.(abs.(1 ./ rel_voxels.AreaRatio),1)
# voxtimes vectorize
max_contours_per_voxel = maximum([length(r.seglen) for r in relmaps])
......@@ -776,10 +777,10 @@ function construct_cost_hist(cdata::contourdata, vd::voxdata, mat::material, td:
σ12 = rel_v.Txy
σ23 = rel_v.Tyz + $((cdata.layer_height/vd.width)*mat.E*mat.α)*ΔT
σ31 = rel_v.Txy + $((cdata.layer_height/vd.width)*mat.E*mat.α)*ΔT
return $F * (σ11 - σ22).^2 +
return ($vox_area_scaling .* ($F * (σ11 - σ22).^2 +
$G * ((σ33 - σ11).^2 + (σ33 - σ22).^2) +
$(2 * L) * (σ12).^2 +
$(2 * M) * (σ23 + σ31).^2
$(2 * M) * (σ23 + σ31).^2)).^2
end
end
return eval(a)
......
Supports Markdown
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