Skip to content

Commit ed73230

Browse files
test deps
1 parent e86c650 commit ed73230

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

ext/OptimizationSymbolicAnalysisExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import SymbolicAnalysis.Symbolics: variable, Equation, Inequality, unwrap, @vari
77
function OptimizationBase.symify_cache(
88
f::OptimizationFunction{iip, AD, F, G, FG, H, FGH, HV, C, CJ, CJV, CVJ, CH, HP,
99
CJP, CHP, O, EX, CEX, SYS, LH, LHP, HCV, CJCV, CHCV, LHCV},
10-
prob, manifold) where {iip, AD, F, G, FG, H, FGH, HV, C, CJ, CJV, CVJ, CH, HP, CJP, CHP, O,
10+
prob, num_cons, manifold) where {iip, AD, F, G, FG, H, FGH, HV, C, CJ, CJV, CVJ, CH, HP, CJP, CHP, O,
1111
EX <: Nothing, CEX <: Nothing, SYS, LH, LHP, HCV, CJCV, CHCV, LHCV}
1212
obj_expr = f.expr
1313
cons_expr = f.cons_expr === nothing ? nothing : getfield.(f.cons_expr, Ref(:lhs))

src/cache.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function OptimizationCache(prob::SciMLBase.OptimizationProblem, opt;
5050
cons_vjp = SciMLBase.allowsconsjvp(opt), cons_jvp = SciMLBase.allowsconsjvp(opt), lag_h = SciMLBase.requireslagh(opt))
5151

5252
if structural_analysis
53-
obj_res, cons_res = symify_cache(f, prob, manifold)
53+
obj_res, cons_res = symify_cache(f, prob, num_cons, manifold)
5454
else
5555
obj_res = nothing
5656
cons_res = nothing

src/symify.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
function symify_cache(f::OptimizationFunction, prob, manifold)
1+
function symify_cache(f::OptimizationFunction, prob, num_cons, manifold)
22
throw("Structural analysis requires SymbolicAnalysis.jl to be loaded, either add `using SymbolicAnalysis` to your script or set `structural_analysis = false`.")
33
end

test/Project.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
99
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
1010
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1111
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
12+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1213
Lux = "b2108857-7c20-44ae-9111-449ecde12c47"
1314
MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54"
1415
Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
@@ -22,6 +23,8 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2223
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
2324
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
2425
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
26+
SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
27+
SymbolicAnalysis = "4297ee4d-0239-47d8-ba5d-195ecdf594fe"
2528
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
2629
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2730
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
@@ -39,4 +42,6 @@ Optim = ">= 1.4.1"
3942
Optimisers = ">= 0.2.5"
4043
Optimization = "4"
4144
OptimizationManopt = "0.0.4"
45+
SparseConnectivityTracer = "0.6"
46+
SymbolicAnalysis = "0.3.0"
4247
SafeTestsets = ">= 0.0.1"

test/cvxtest.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ optf = OptimizationFunction(rosenbrock, AutoZygote(), cons = con2_c)
2929
prob = OptimizationProblem(optf, x0, lcons = [1.0, -Inf], ucons = [1.0, 0.0],
3030
lb = [-1.0, -1.0], ub = [1.0, 1.0], structural_analysis = true)
3131
@time res = solve(prob, Optimization.LBFGS(), maxiters = 100)
32-
@test res.cache.analysis_results.objective.curvature == SymbolicAnalysis.Convex
32+
@test res.cache.analysis_results.objective.curvature == SymbolicAnalysis.UnknownCurvature
3333
@test res.cache.analysis_results.constraints[1].curvature == SymbolicAnalysis.Convex
3434
@test res.cache.analysis_results.constraints[2].curvature ==
3535
SymbolicAnalysis.UnknownCurvature
@@ -46,7 +46,7 @@ optf = OptimizationFunction(f, Optimization.AutoForwardDiff())
4646
prob = OptimizationProblem(optf, data2[1]; manifold = M, structural_analysis = true)
4747

4848
opt = OptimizationManopt.GradientDescentOptimizer()
49-
@time sol = solve(prob, Optimization.LBFGS(), maxiters = 100)
50-
@test sol.minimizer < 1e-1
49+
@time sol = solve(prob, opt, maxiters = 100)
50+
@test sol.minimum < 1e-1
5151
@test sol.cache.analysis_results.objective.curvature == SymbolicAnalysis.UnknownCurvature
5252
@test sol.cache.analysis_results.objective.gcurvature == SymbolicAnalysis.GConvex

test/matrixvalued.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ using Test, ReverseDiff
7878
Omega_mc = rand(4, 4) .> 0.5 # Mask for observed entries (boolean matrix)
7979
X_mc = rand(4, 4) # Matrix to be completed
8080
optf = OptimizationFunction{false}(
81-
matrix_completion_objective, adtype, cons = rank_constraint)
81+
matrix_completion_objective, adtype)
8282
optf = OptimizationBase.instantiate_function(
8383
optf, X_mc, adtype, (A_mc, Omega_mc), g = true, h = true)
8484
optf.grad(X_mc)

0 commit comments

Comments
 (0)