@@ -5,125 +5,125 @@ using LinearAlgebra, Printf, SparseArrays, Test
5
5
using ADNLPModels,
6
6
LinearOperators, NLPModels, NLPModelsModifiers, NLPModelsTest, QPSReader, QuadraticModels
7
7
8
- # @testset "test utils" begin
9
- # A = rand(10, 10)
10
- # @test nnz(A) == 100
11
- # @test nnz(Diagonal(A)) == 10
12
- # @test nnz(Symmetric(A)) == 55
13
- # v1, v2 = rand(10), rand(9)
14
- # @test nnz(SymTridiagonal(v1, v2)) == 19
15
- # end
8
+ @testset " test utils" begin
9
+ A = rand (10 , 10 )
10
+ @test nnz (A) == 100
11
+ @test nnz (Diagonal (A)) == 10
12
+ @test nnz (Symmetric (A)) == 55
13
+ v1, v2 = rand (10 ), rand (9 )
14
+ @test nnz (SymTridiagonal (v1, v2)) == 19
15
+ end
16
16
17
- # # Definition of quadratic problems
18
- # qp_problems_Matrix = ["bndqp", "eqconqp"]
19
- # qp_problems_COO = ["uncqp", "ineqconqp"]
20
- # for qp in [qp_problems_Matrix; qp_problems_COO]
21
- # include(joinpath("problems", "$qp.jl"))
22
- # end
17
+ # Definition of quadratic problems
18
+ qp_problems_Matrix = [" bndqp" , " eqconqp" ]
19
+ qp_problems_COO = [" uncqp" , " ineqconqp" ]
20
+ for qp in [qp_problems_Matrix; qp_problems_COO]
21
+ include (joinpath (" problems" , " $qp .jl" ))
22
+ end
23
23
24
- # include("test_consistency.jl")
24
+ include (" test_consistency.jl" )
25
25
26
- # function testSM(sm) # test function for a specific problem
27
- # @test (sm.meta.ncon == 2 && sm.meta.nvar == 5)
28
- # @test sm.meta.lcon == sm.meta.ucon
29
- # lvar_sm_true = [0.0; 0.0; 0.0; -4.0; -3.0]
30
- # uvar_sm_true = [Inf; Inf; Inf; Inf; -2.0]
31
- # H_sm_true = sparse(
32
- # [
33
- # 6.0 0.0 0.0 0.0 0.0
34
- # 2.0 5.0 0.0 0.0 0.0
35
- # 1.0 2.0 4.0 0.0 0.0
36
- # 0.0 0.0 0.0 0.0 0.0
37
- # 0.0 0.0 0.0 0.0 0.0
38
- # ],
39
- # )
40
- # A_sm_true = sparse([
41
- # 1.0 0.0 1.0 0.0 -1.0
42
- # 0.0 2.0 1.0 -1.0 0.0
43
- # ])
26
+ function testSM (sm) # test function for a specific problem
27
+ @test (sm. meta. ncon == 2 && sm. meta. nvar == 5 )
28
+ @test sm. meta. lcon == sm. meta. ucon
29
+ lvar_sm_true = [0.0 ; 0.0 ; 0.0 ; - 4.0 ; - 3.0 ]
30
+ uvar_sm_true = [Inf ; Inf ; Inf ; Inf ; - 2.0 ]
31
+ H_sm_true = sparse (
32
+ [
33
+ 6.0 0.0 0.0 0.0 0.0
34
+ 2.0 5.0 0.0 0.0 0.0
35
+ 1.0 2.0 4.0 0.0 0.0
36
+ 0.0 0.0 0.0 0.0 0.0
37
+ 0.0 0.0 0.0 0.0 0.0
38
+ ],
39
+ )
40
+ A_sm_true = sparse ([
41
+ 1.0 0.0 1.0 0.0 - 1.0
42
+ 0.0 2.0 1.0 - 1.0 0.0
43
+ ])
44
44
45
- # @test all(lvar_sm_true .== sm.meta.lvar)
46
- # @test all(uvar_sm_true .== sm.meta.uvar)
47
- # @test all(sparse(sm.data.Arows, sm.data.Acols, sm.data.Avals, 2, 5) .== A_sm_true)
48
- # @test all(sparse(sm.data.Hrows, sm.data.Hcols, sm.data.Hvals, 5, 5) .== H_sm_true)
49
- # end
45
+ @test all (lvar_sm_true .== sm. meta. lvar)
46
+ @test all (uvar_sm_true .== sm. meta. uvar)
47
+ @test all (sparse (sm. data. Arows, sm. data. Acols, sm. data. Avals, 2 , 5 ) .== A_sm_true)
48
+ @test all (sparse (sm. data. Hrows, sm. data. Hcols, sm. data. Hvals, 5 , 5 ) .== H_sm_true)
49
+ end
50
50
51
- # @testset "SlackModel" begin
52
- # H = [
53
- # 6.0 2.0 1.0
54
- # 2.0 5.0 2.0
55
- # 1.0 2.0 4.0
56
- # ]
57
- # c = [-8.0; -3; -3]
58
- # A = [
59
- # 1.0 0.0 1.0
60
- # 0.0 2.0 1.0
61
- # ]
62
- # b = [0.0; 3]
63
- # l = [0.0; 0; 0]
64
- # u = [Inf; Inf; Inf]
65
- # T = eltype(c)
66
- # qp = QuadraticModel(
67
- # c,
68
- # sparse(H),
69
- # A = A,
70
- # lcon = [-3.0; -4.0],
71
- # ucon = [-2.0; Inf],
72
- # lvar = l,
73
- # uvar = u,
74
- # c0 = 0.0,
75
- # name = "QM1",
76
- # )
77
- # sm = SlackModel(qp)
78
- # testSM(sm)
51
+ @testset " SlackModel" begin
52
+ H = [
53
+ 6.0 2.0 1.0
54
+ 2.0 5.0 2.0
55
+ 1.0 2.0 4.0
56
+ ]
57
+ c = [- 8.0 ; - 3 ; - 3 ]
58
+ A = [
59
+ 1.0 0.0 1.0
60
+ 0.0 2.0 1.0
61
+ ]
62
+ b = [0.0 ; 3 ]
63
+ l = [0.0 ; 0 ; 0 ]
64
+ u = [Inf ; Inf ; Inf ]
65
+ T = eltype (c)
66
+ qp = QuadraticModel (
67
+ c,
68
+ sparse (H),
69
+ A = A,
70
+ lcon = [- 3.0 ; - 4.0 ],
71
+ ucon = [- 2.0 ; Inf ],
72
+ lvar = l,
73
+ uvar = u,
74
+ c0 = 0.0 ,
75
+ name = " QM1" ,
76
+ )
77
+ sm = SlackModel (qp)
78
+ testSM (sm)
79
79
80
- # SlackModel!(qp)
81
- # testSM(qp)
80
+ SlackModel! (qp)
81
+ testSM (qp)
82
82
83
- # qpdense = QuadraticModel(
84
- # c,
85
- # H,
86
- # A = A,
87
- # lcon = [-3.0; -4.0],
88
- # ucon = [-2.0; Inf],
89
- # lvar = l,
90
- # uvar = u,
91
- # c0 = 0.0,
92
- # name = "QM1",
93
- # )
94
- # smdense = SlackModel(qpdense)
95
- # testSM(smdense)
96
- # end
83
+ qpdense = QuadraticModel (
84
+ c,
85
+ H,
86
+ A = A,
87
+ lcon = [- 3.0 ; - 4.0 ],
88
+ ucon = [- 2.0 ; Inf ],
89
+ lvar = l,
90
+ uvar = u,
91
+ c0 = 0.0 ,
92
+ name = " QM1" ,
93
+ )
94
+ smdense = SlackModel (qpdense)
95
+ testSM (smdense)
96
+ end
97
97
98
- # @testset "sort cols COO" begin
99
- # Hrows = [1; 2; 1; 3]
100
- # Hcols = [2; 1; 4; 4]
101
- # Hvals = [1.0; 2.0; 3.0; 4.0]
102
- # Arows = [2; 2; 1; 4]
103
- # Acols = [4; 3; 1; 2]
104
- # Avals = [-1.0; -2.0; -3.0; -4.0]
105
- # c = [-8.0; -3; -3; 2.0]
106
- # l = [0.0; 0; 0; 0]
107
- # u = [Inf; Inf; Inf; Inf]
108
- # qp = QuadraticModel(
109
- # c,
110
- # Hrows,
111
- # Hcols,
112
- # Hvals,
113
- # Arows = Arows,
114
- # Acols = Acols,
115
- # Avals = Avals,
116
- # lcon = [-3.0; -4.0; 2.0; 1.0],
117
- # ucon = [-2.0; Inf; Inf; Inf],
118
- # lvar = l,
119
- # uvar = u,
120
- # c0 = 0.0,
121
- # name = "QM1",
122
- # sortcols = true,
123
- # )
124
- # @test issorted(Hcols)
125
- # @test issorted(Acols)
126
- # end
98
+ @testset " sort cols COO" begin
99
+ Hrows = [1 ; 2 ; 1 ; 3 ]
100
+ Hcols = [2 ; 1 ; 4 ; 4 ]
101
+ Hvals = [1.0 ; 2.0 ; 3.0 ; 4.0 ]
102
+ Arows = [2 ; 2 ; 1 ; 4 ]
103
+ Acols = [4 ; 3 ; 1 ; 2 ]
104
+ Avals = [- 1.0 ; - 2.0 ; - 3.0 ; - 4.0 ]
105
+ c = [- 8.0 ; - 3 ; - 3 ; 2.0 ]
106
+ l = [0.0 ; 0 ; 0 ; 0 ]
107
+ u = [Inf ; Inf ; Inf ; Inf ]
108
+ qp = QuadraticModel (
109
+ c,
110
+ Hrows,
111
+ Hcols,
112
+ Hvals,
113
+ Arows = Arows,
114
+ Acols = Acols,
115
+ Avals = Avals,
116
+ lcon = [- 3.0 ; - 4.0 ; 2.0 ; 1.0 ],
117
+ ucon = [- 2.0 ; Inf ; Inf ; Inf ],
118
+ lvar = l,
119
+ uvar = u,
120
+ c0 = 0.0 ,
121
+ name = " QM1" ,
122
+ sortcols = true ,
123
+ )
124
+ @test issorted (Hcols)
125
+ @test issorted (Acols)
126
+ end
127
127
128
128
@testset " LinearOperators" begin
129
129
nvar, ncon = 10 , 7
0 commit comments