Skip to content

Commit

Permalink
Update runtests.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelArutjunjan committed Jul 11, 2024
1 parent 7567543 commit d9c6c7f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ end
@test DataModel(Data(DM), OptimizeModel(Predictor(dm); inplace=false)...) isa AbstractDataModel

@test curve_fit(Data(DM), Predictor(DM), rand(pdim(DM))).param curve_fit(Data(DM), Predictor(DM), dPredictor(DM), rand(pdim(DM))).param
@test minimize(Data(DM), Predictor(DM), rand(pdim(DM))) minimize(Data(DM), Predictor(DM), dPredictor(DM), rand(pdim(DM)))
# import InformationGeometry.minimize
# @test minimize(Data(DM), Predictor(DM), rand(pdim(DM))) ≈ minimize(Data(DM), Predictor(DM), dPredictor(DM), rand(pdim(DM)))
end

@safetestset "Inputting Datasets of various shapes" begin
Expand Down Expand Up @@ -441,21 +442,26 @@ end

@safetestset "Optimization Functions" begin
using InformationGeometry, Test, BenchmarkTools, LinearAlgebra, Optim
import InformationGeometry.minimize

# Test optimizers:
F(x) = x[1]^2 + 0.5x[2]^4; initial = 10ones(2) + rand(2); Cube = HyperCube(-2ones(2), 18ones(2))

@test norm(InformationGeometry.minimize(F, initial, Cube; tol=1e-5, meth=NelderMead())) < 5e-1
@test norm(InformationGeometry.minimize(F, initial, Cube; tol=1e-5, meth=LBFGS())) < 5e-2
@test norm(InformationGeometry.minimize(F, initial, Cube; tol=1e-5, meth=Newton())) < 5e-2
@test norm(minimize(F, initial, Cube; tol=1e-5, meth=NelderMead())) < 5e-1
@test norm(minimize(F, initial, Cube; tol=1e-5, meth=LBFGS())) < 5e-2
@test norm(minimize(F, initial, Cube; tol=1e-5, meth=Newton())) < 5e-2

@test norm(InformationGeometry.minimize(F, initial; tol=1e-5, meth=NelderMead())) < 5e-1
@test norm(InformationGeometry.minimize(F, initial; tol=1e-5, meth=LBFGS())) < 5e-2
@test norm(InformationGeometry.minimize(F, initial; tol=1e-5, meth=Newton())) < 5e-2
@test norm(minimize(F, initial; tol=1e-5, meth=NelderMead())) < 5e-1
@test norm(minimize(F, initial; tol=1e-5, meth=LBFGS())) < 5e-2
@test norm(minimize(F, initial; tol=1e-5, meth=Newton())) < 5e-2

# Check optimization with non-linear constraints and box constraints

# Check in-place and out-of-place optimization

# Check type stability of optimization
using ComponentArrays
@test InformationGeometry.minimize(X->X.A[1]^2 + 0.5X.B[1]^4, ComponentVector(A=[initial[1]], B=[initial[1]]); tol=1e-5, meth=Newton()) isa ComponentVector
@test minimize(X->X.A[1]^2 + 0.5X.B[1]^4, ComponentVector(A=[initial[1]], B=[initial[1]]); tol=1e-5, meth=Newton()) isa ComponentVector
end


Expand Down

0 comments on commit d9c6c7f

Please sign in to comment.