-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathtetra.jl
105 lines (89 loc) · 3.19 KB
/
tetra.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Minimize the sum of the inverse weighted mean ratio of the elements in a fixed–boundary
# tetrahedral mesh by adjusting the locations of the free vertices.
# This is problem 19 in the COPS (Version 3) collection of
# E. Dolan and J. More
# see "Benchmarking Optimization Software with COPS"
# Argonne National Labs Technical Report ANL/MCS-246 (2004)
include("../../data/tetra.jl")
export tetra
function tetra(
x0 = xe_tetra,
TETS::Vector{Int64} = Tets_tetra,
Const::Vector{Int64} = Constants_tetra;
kwargs...,
)
τ = 0.0
n = length(x0)
N = round(Int, n / 3)
E = round(Int, length(TETS) / 4)
lvar = -Inf * ones(n)
lvar[Const] = x0[Const]
lvar[Const .+ N] = x0[Const .+ N]
lvar[Const .+ 2 * N] = x0[Const .+ 2 * N]
uvar = Inf * ones(n)
uvar[Const] = x0[Const]
uvar[Const .+ N] = x0[Const .+ N]
uvar[Const .+ 2 * N] = x0[Const .+ 2 * N]
nlp = Model()
@variable(nlp, lvar[i] <= x[i = 1:n] <= uvar[i], start = x0[i])
@NLobjective(
nlp,
Min,
sum(
(sum(
(1 * x[TETS[e + E] + N * i] - x[TETS[e] + N * i])^2 +
(2 * x[TETS[e + 2 * E] + N * i] - x[TETS[e + E] + N * i] - x[TETS[e] + N * i])^2 / 3 +
(
3 * x[TETS[e + 3 * E] + N * i] - x[TETS[e + 2 * E] + N * i] - x[TETS[e + E] + N * i] -
x[TETS[e] + N * i]
)^2 / 6 for i = 0:2
)) / (
3 *
(sum(
(x[TETS[e + E] + N * i] - x[TETS[e] + N * i]) *
(
(x[TETS[e + 2 * E] + N * mod(i + 1, 3)] - x[TETS[e] + N * mod(i + 1, 3)]) *
(x[TETS[e + 3 * E] + N * mod(i - 1, 3)] - x[TETS[e] + N * mod(i - 1, 3)]) -
(x[TETS[e + 2 * E] + N * mod(i - 1, 3)] - x[TETS[e] + N * mod(i - 1, 3)]) *
(x[TETS[e + 3 * E] + N * mod(i + 1, 3)] - x[TETS[e] + N * mod(i + 1, 3)])
) *
sqrt(2) for i = 0:2
))^(2 / 3)
) for e = 1:E
)
)
for e = 1:E
@NLconstraint(
nlp,
sum(
(x[TETS[e + E] + N * i] - x[TETS[e] + N * i]) *
(
(x[TETS[e + 2 * E] + N * mod(i + 1, 3)] - x[TETS[e] + N * mod(i + 1, 3)]) *
(x[TETS[e + 3 * E] + N * mod(i - 1, 3)] - x[TETS[e] + N * mod(i - 1, 3)]) -
(x[TETS[e + 2 * E] + N * mod(i - 1, 3)] - x[TETS[e] + N * mod(i - 1, 3)]) *
(x[TETS[e + 3 * E] + N * mod(i + 1, 3)] - x[TETS[e] + N * mod(i + 1, 3)])
) *
sqrt(2) for i = 0:2
) >= τ
)
end
return nlp
end
include("../../data/tetra_duct12.jl")
export tetra_duct12
tetra_duct12(; kwargs...) = tetra(xe_duct12, TETS_duct12, Const_duct12; kwargs...)
include("../../data/tetra_duct15.jl")
export tetra_duct15
tetra_duct15(; kwargs...) = tetra(xe_duct15, TETS_duct15, Const_duct15; kwargs...)
include("../../data/tetra_duct20.jl")
export tetra_duct20
tetra_duct20(; kwargs...) = tetra(xe_duct20, TETS_duct20, Const_duct20; kwargs...)
include("../../data/tetra_hook.jl")
export tetra_hook
tetra_hook(; kwargs...) = tetra(xe_hook, TETS_hook, Const_hook; kwargs...)
include("../../data/tetra_foam5.jl")
export tetra_foam5
tetra_foam5(; kwargs...) = tetra(xe_foam5, TETS_foam5, Const_foam5; kwargs...)
include("../../data/tetra_gear.jl")
export tetra_gear
tetra_gear(; kwargs...) = tetra(xe_gear, TETS_gear, Const_gear; kwargs...)