Skip to content

Commit 36d8941

Browse files
tmigotfrapac
andauthored
Update JuMP syntax to use the new nonlinear interface (new) (#339)
* update JuMP syntax to use the new nonlinear interface --------- Co-authored-by: fpacaud <[email protected]>
1 parent e77ef90 commit 36d8941

File tree

446 files changed

+1774
-1862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

446 files changed

+1774
-1862
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
1414
[compat]
1515
DataFrames = "1"
1616
JLD2 = "0.4"
17-
JuMP = "~0.19, ~0.20, ~0.21, ~0.22, 0.23, 1"
17+
JuMP = "^1.15"
1818
Requires = "1"
1919
SpecialFunctions = "2"
2020
julia = "~1"

src/ADNLPProblems/allinit.jl

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,27 @@ function allinit(; n::Int = default_nvar, type::Type{T} = Float64, kwargs...) wh
1414
lvar = -T(Inf) * ones(T, 4)
1515
uvar = T(Inf) * ones(T, 4)
1616

17-
function c!(cx, x)
18-
cx[1] = x[2] - 1
19-
cx[2] = x[3]
20-
cx[3] = x[4] - 2
21-
return cx
22-
end
17+
#function c!(cx, x)
18+
# cx[3] = x[4]
19+
# cx[1] = x[2]
20+
# cx[2] = x[3]
21+
# return cx
22+
#end
23+
A = T[
24+
0 0 0 1;
25+
0 1 0 0;
26+
0 0 1 0
27+
]
2328

2429
return ADNLPModels.ADNLPModel!(
2530
f,
2631
x0,
2732
lvar,
2833
uvar,
29-
c!,
30-
T[0, -1e+10, 0],
31-
T[Inf, 1, 0],
34+
findnz(sparse(A))...,
35+
(cx, x) -> cx,
36+
T[2, 1, -1e+10],
37+
T[2, Inf, 1],
3238
name = "allinit",
3339
minimize = true;
3440
kwargs...,

src/ADNLPProblems/allinitc.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,24 @@ function allinitc(; n::Int = default_nvar, type::Type{T} = Float64, kwargs...) w
1515
uvar = T(Inf) * ones(T, 4)
1616

1717
function c!(cx, x)
18-
cx[1] = x[2] - 1
19-
cx[2] = x[3]
20-
cx[3] = x[4] - 2
21-
cx[4] = x[1]^2 + x[2]^2 - 1
18+
cx[1] = x[1]^2 + x[2]^2
2219
return cx
2320
end
21+
A = T[
22+
0 0 0 1;
23+
0 1 0 0;
24+
0 0 1 0
25+
]
2426

2527
return ADNLPModels.ADNLPModel!(
2628
f,
2729
x0,
2830
lvar,
2931
uvar,
32+
sparse(A),
3033
c!,
31-
T[0, -1e+10, 0, -Inf],
32-
T[Inf, 1, 0, 0],
34+
T[2, 1, -1e+10, -Inf],
35+
T[2, Inf, 1, 1],
3336
name = "allinitc",
3437
minimize = true;
3538
kwargs...,

src/ADNLPProblems/alsotame.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,22 @@ function alsotame(; n::Int = default_nvar, type::Type{T} = Float64, kwargs...) w
1212
function c!(cx, x)
1313
x, y = x[1], x[2]
1414
cx[1] = sin(-x + y - 1)
15-
cx[2] = x
16-
cx[3] = y
1715
return cx
1816
end
17+
A = T[
18+
1 0 0;
19+
0 1 0
20+
]
1921

2022
return ADNLPModels.ADNLPModel!(
2123
f,
2224
x0,
2325
lvar,
2426
uvar,
27+
findnz(sparse(A))...,
2528
c!,
26-
T[0, -2, -1.5],
27-
T[0, 2, 1.5],
29+
T[-2, -1.5, 0],
30+
T[2, 1.5, 0],
2831
name = "alsotame",
2932
minimize = true;
3033
kwargs...,

src/ADNLPProblems/avion2.jl

Lines changed: 5 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -179,123 +179,13 @@ function avion2(::Val{:nlp}; n::Int = default_nvar, type::Type{T} = Float64, kwa
179179
1,
180180
1,
181181
]
182+
A = sparse([1, 2, 3, 2, 4, 3, 1, 4, 4, 4, 4, 5, 5, 7, 10, 14, 6, 8, 14, 14, 6, 13, 15, 7, 7, 8, 15, 9, 15, 10, 15, 11, 15, 12, 15, 13, 15, 9, 14, 11, 14, 12, 14], [1, 1, 2, 5, 5, 6, 7, 7, 8, 9, 10, 10,
183+
19, 20, 20, 20, 22, 22, 22, 23, 24, 26, 31, 33, 34, 35, 35, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 47, 47, 48, 48, 49, 49], T[-0.13, -0.7, -1.0, 1.0, -2.0, 1.0, 1.0, -2.0, -2.0, -1.0, 1.0, -20.0, 1.0, -1.0, -0.043, 0.5, -2.0, -0.137, -1.0, 1.0, 1.0, -300.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -35.0, 660.0, -200.0, 95.0, -120.0, 70.0], 15, 49)
182184
function c!(cx, x)
183-
SR,
184-
LR,
185-
PK,
186-
EF,
187-
SX,
188-
LX,
189-
SD,
190-
SK,
191-
ST,
192-
SF,
193-
LF,
194-
AM,
195-
CA,
196-
CB,
197-
SO,
198-
SS,
199-
IMPDER,
200-
IMPK,
201-
IMPFUS,
202-
QI,
203-
PT,
204-
MV,
205-
MC,
206-
MD,
207-
PD,
208-
NS,
209-
VS,
210-
CR,
211-
PM,
212-
DV,
213-
MZ,
214-
VN,
215-
QV,
216-
QF,
217-
IMPTRAIN,
218-
IMPMOT,
219-
IMPNMOT,
220-
IMPPET,
221-
IMPPIL,
222-
IMPCAN,
223-
IMPSNA,
224-
MS,
225-
EL,
226-
DE,
227-
DS,
228-
IMPVOIL,
229-
NM,
230-
NP,
231-
NG = x[1],
232-
x[2],
233-
x[3],
234-
x[4],
235-
x[5],
236-
x[6],
237-
x[7],
238-
x[8],
239-
x[9],
240-
x[10],
241-
x[11],
242-
x[12],
243-
x[13],
244-
x[14],
245-
x[15],
246-
x[16],
247-
x[17],
248-
x[18],
249-
x[19],
250-
x[20],
251-
x[21],
252-
x[22],
253-
x[23],
254-
x[24],
255-
x[25],
256-
x[26],
257-
x[27],
258-
x[28],
259-
x[29],
260-
x[30],
261-
x[31],
262-
x[32],
263-
x[33],
264-
x[34],
265-
x[35],
266-
x[36],
267-
x[37],
268-
x[38],
269-
x[39],
270-
x[40],
271-
x[41],
272-
x[42],
273-
x[43],
274-
x[44],
275-
x[45],
276-
x[46],
277-
x[47],
278-
x[48],
279-
x[49]
280-
cx[1] = SD - (13 // 100) * SR
281-
cx[2] = SX - (7 // 10) * SR
282-
cx[3] = LX - LR
283-
cx[4] = SF - ST - 2 * SD - 2 * SX - 2 * SK
284-
cx[5] = IMPFUS - 20 * SF
285-
cx[6] = MD - 2 * MV
286-
cx[7] = QF - QI - QV
287-
cx[8] = IMPTRAIN - (137 // 1000) * MV
288-
cx[9] = IMPNMOT - 35 * NM
289-
cx[10] = IMPPET - (43 // 1000) * QI
290-
cx[11] = IMPPIL - 200 * NP
291-
cx[12] = IMPCAN - 120 * NG
292-
cx[13] = IMPSNA - 300 * NS - 400
293-
cx[14] = MC - MV + 95 * NP + 70 * NG + 660 * NM + (1 // 2) * QI - 380
294-
cx[15] = MZ - IMPTRAIN + IMPNMOT + IMPPET + IMPPIL + IMPCAN + IMPSNA + 290
295185
return cx
296186
end
297-
lcon = zeros(T, 15)
298-
ucon = zeros(T, 15)
187+
lcon = vcat(zeros(T, 12), 400, 380, -290)
188+
ucon = vcat(zeros(T, 12), 400, 380, -290)
299189
lvar = T[
300190
10,
301191
0,
@@ -399,7 +289,7 @@ function avion2(::Val{:nlp}; n::Int = default_nvar, type::Type{T} = Float64, kwa
399289
2,
400290
]
401291

402-
return ADNLPModels.ADNLPModel!(f, x0, lvar, uvar, c!, lcon, ucon, name = "avion2"; kwargs...)
292+
return ADNLPModels.ADNLPModel!(f, x0, lvar, uvar, findnz(A)..., c!, lcon, ucon, name = "avion2"; kwargs...)
403293
end
404294

405295
function avion2(::Val{:nls}; n::Int = default_nvar, type::Type{T} = Float64, kwargs...) where {T}

src/ADNLPProblems/booth.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@ function booth(; n::Int = default_nvar, type::Type{T} = Float64, kwargs...) wher
66
end
77
x0 = zeros(T, 2)
88

9+
A = T[
10+
1 2;
11+
2 1
12+
]
913
function c!(cx, x)
10-
cx[1] = x[1] + 2 * x[2] - 7
11-
cx[2] = 2 * x[1] + x[2] - 5
1214
return cx
1315
end
1416
return ADNLPModels.ADNLPModel!(
1517
f,
1618
x0,
19+
findnz(sparse(A))...,
1720
c!,
18-
zeros(T, 2),
19-
zeros(T, 2),
21+
T[7, 5],
22+
T[7, 5],
2023
minimize = true,
2124
name = "booth";
2225
kwargs...,

src/ADNLPProblems/bqp1var.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ function bqp1var(; n::Int = default_nvar, type::Type{T} = Float64, kwargs...) wh
66
end
77
x0 = T[0.25,]
88
function c!(cx, x)
9-
cx[1] = x[1]
109
return cx
1110
end
1211
lcon = T[0.0,]
@@ -15,6 +14,7 @@ function bqp1var(; n::Int = default_nvar, type::Type{T} = Float64, kwargs...) wh
1514
return ADNLPModels.ADNLPModel!(
1615
f,
1716
x0,
17+
findnz(sparse(ones(T, 1, 1)))...,
1818
c!,
1919
lcon,
2020
ucon,

0 commit comments

Comments
 (0)