Commit d89cf8dd authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

fix k bug and experiment with temp decay rates

parent 1b7d5fec
......@@ -483,12 +483,12 @@ end
T0 = 215 # extrusion temp
Tc = 25 # room temp
Tcutoff = 100 # temperature above which strain isn't happening
k = 0.08 #value unknown
Temp(t::Number) = Tc + (T0-Tc)*^(-k*t)
k_temp = 0.01 #value unknown
Temp(t::Number) = Tc + (T0-Tc)*^(-k_temp*t)
# see shape of temp function
#x = 1:100
#y = Temp.(x)
#plot(x,y)
x = 1:210
y = Temp.(x)
plot(x,y)
function clean_contour(c::contour)
......@@ -584,7 +584,7 @@ a = quote
Δt = voxtimes[considered_voxels] - voxtimes[relbelows]
#println("Temp diff") # 30k
ΔT = Tcutoff .- ($Tc .+ $(T0-Tc).*.^(-k.*Δt))
ΔT = Tcutoff .- ($Tc .+ $(T0-Tc).*.^(-$k_temp.*Δt))
# println("Temp diff clean") # 500k
replace!(x-> x<0 ? 0 : x, ΔT)
......@@ -596,15 +596,14 @@ a = quote
σ12 = rel_voxels.Txy
σ23 = rel_voxels.Tyz + $((cdata.layer_height/vd.width)*mat.E*mat.α)*ΔT
σ31 = rel_voxels.Txy + $((cdata.layer_height/vd.width)*mat.E*mat.α)*ΔT
cost = sum($F * (σ11 - σ22).^2 +
return sum($F * (σ11 - σ22).^2 +
$G * ((σ33 - σ11).^2 + (σ33 - σ22).^2) +
$(2 * L) * (σ12).^2 +
$(2 * M) * (σ23 + σ31).^2)
return cost
end
end
eval(a)
cost_f(rl)
c = cost_f(rl)
# local search loop
k = 5 # TODO k is hardcoded in function below (uses global variable)
......@@ -644,16 +643,26 @@ function local_search!(rl::Vector{Int}, max_iter::Int)
end
# single local search
rl = random_rollout(cdata)
@time local_search!(rl, 5)
cost_f(rl)
max_iterations = 10
@time local_search!(rl, max_iterations)
# run many times
n_starts=10
my_costs = zeros(n_starts)
opt_costs = zeros(n_starts)
start_costs = zeros(n_starts)
threads = zeros(n_starts)
@time Threads.@threads for i in 1:n_starts
my_costs[i] = local_search!(random_rollout(cdata), 5)
rl = random_rollout(cdata)
start_costs[i] = cost_f(rl)
opt_costs[i] = local_search!(rl, max_iterations)
threads[i] = Threads.threadid()
end # 12 seconds
end # 12 seconds for 10
# k_temp = 0.08 (215C -> 50C in 25s), average improvement=1.8%
# k_temp = 0.04 (215C -> 50C in 50s), average improvement=4.5%
# k_temp = 0.01 (215C -> 50C in 200s), average improvement=21.7%
@time for i in 1:n_starts
my_costs[i] = local_search!(random_rollout(cdata), 5)
......
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