-
Notifications
You must be signed in to change notification settings - Fork 48
/
clplatea.jl
53 lines (46 loc) · 1.58 KB
/
clplatea.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
# The clamped plate problem (Strang, Nocedal, Dax).
# The problem comes from the discretization the following problem
# in mechanics: a plate is clamped on one edge and loaded on the
# opposite side. The plate is the unit square.
#
# In this version of the problem, the weight wght is entirely put on the
# upper right corner of the plate.
#
# The plate is clamped on its lower edge, by fixing the
# corresponding variables to zero.
#
# Source:
# J. Nocedal,
# "Solving large nonlinear systems of equations arising in mechanics",
# Proceedings of the Cocoyoc Numerical Analysis Conference, Mexico,
# pp. 132-141, 1981.
#
# classification OXR2-MN-V-0
#
# p is the number of points in one side of the unit square
# The number of variables is p*p, of which (p-1)*(p-1) are free.
#
# Fixed variables have been eliminated from the objective function.
export clplatea
"The clamped plate problem (Strang, Nocedal, Dax)."
function clplatea(args...; n::Int = default_nvar, wght::Float64 = -0.1, kwargs...)
p = floor(Int, sqrt(n))
p * p != n && @warn("clplatea: number of variables adjusted from $n down to $(p*p)")
n = p * p
nlp = Model()
@variable(nlp, x[i = 1:p, j = 1:p], start = 0.0)
hp2 = 0.5 * p^2
@NLobjective(
nlp,
Min,
(wght * x[p, p]) +
sum(
sum(0.5 * (x[i, j] - x[i, j - 1])^2 + hp2 * (x[i, j] - x[i, j - 1])^4 for j = 2:p) for i = 2:p
) +
sum(0.5 * (x[2, j])^2 + hp2 * (x[2, j])^4 for j = 2:p) +
sum(
sum(0.5 * (x[i, j] - x[i - 1, j])^2 + hp2 * (x[i, j] - x[i - 1, j])^4 for j = 2:p) for i = 3:p
)
)
return nlp
end