Skip to content

Commit

Permalink
adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jumutc committed Sep 16, 2015
1 parent fa1ec46 commit b484780
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions wrappers/julia/test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Base.Test

include("optunity.jl")

result = minimize((x,y,z) -> (x-1)^2 + (y-2)^2 + (z+3)^4, num_evals=1000, x=[-5,5], y=[-5,5], z=[-5,5])
@test_approx_eq_eps result[1]["x"] 1.0 .2
@test_approx_eq_eps result[1]["y"] 2.0 .2
@test_approx_eq_eps result[1]["z"] -3.0 .2

result = maximize((x,y,z) -> -(x-1)^2 - (y-2)^2 - (z+3)^4, num_evals=10000, solver_name="grid search", x=[-5,5], y=[-5,5], z=[-5,5])
@test_approx_eq_eps result[1]["x"] 1.0 .05
@test_approx_eq_eps result[1]["y"] 2.0 .05
@test_approx_eq_eps result[1]["z"] -3.0 .05

function testit(d::Dict)
(d[:x]-1)^2 + (d[:y]-2)^2 + (d[:z]+3)^4
end

result = minimize(testit, num_evals=10000, x=[-5,5], y=[-5,5], z=[-5,5])
@test_approx_eq_eps result[1]["x"] 1.0 .05
@test_approx_eq_eps result[1]["y"] 2.0 .05
@test_approx_eq_eps result[1]["z"] -3.0 .05

0 comments on commit b484780

Please sign in to comment.