Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jayant Khatkar
tempaware
Commits
d89cf8dd
Commit
d89cf8dd
authored
Sep 28, 2021
by
Jayant Khatkar
Browse files
fix k bug and experiment with temp decay rates
parent
1b7d5fec
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.jl
View file @
d89cf8dd
...
...
@@ -483,12 +483,12 @@ end
T0
=
215
# extrusion temp
Tc
=
25
# room temp
Tcutoff
=
100
# temperature above which strain isn't happening
k
=
0.0
8
#value unknown
Temp
(
t
::
Number
)
=
Tc
+
(
T0
-
Tc
)
*
ℯ
^
(
-
k
*
t
)
k
_temp
=
0.0
1
#value unknown
Temp
(
t
::
Number
)
=
Tc
+
(
T0
-
Tc
)
*
ℯ
^
(
-
k
_temp
*
t
)
# see shape of temp function
#
x = 1:10
0
#
y = Temp.(x)
#
plot(x,y)
x
=
1
:
2
10
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment