Skip to content

Instantly share code, notes, and snippets.

pkm@pkm:~/.julia/v0.6/RemPiO2$ julia6 -O3 test/runtests.jl
Testing speed and accuracy of rempio2 in [-pi*9/4, pi*9/4]
----------------------------------------------------------
Numbers below are elapsed time returned from @belapsed
Every number is checked between the two implementations
using a @test such that any difference results in termi-
nation of the program.
julia> Profile.print()
11 ./event.jl:68; (::Base.REPL.##3#4{Base.REPL.REPLBackend})()
11 ./REPL.jl:95; macro expansion
11 ./REPL.jl:64; eval_user_input(::Any, ::Base.REPL.REPLBackend)
11 ./boot.jl:234; eval(::Module, ::Any)
11 ./<missing>:?; anonymous
11 ./profile.jl:16; macro expansion;
11 /home/pkm/.julia/v0.5/MDPTools/src/solution/solve.jl:39; solve!;
11 /home/pkm/.julia/v0.5/MDPTools/src/solution/solve.jl:40; #solve!#58;
11 ./<missing>:0; (::MDPTools.#kw##solve!)(::Array{Any,1}, ::MDPTools.#solve!, ::MDPTools.LinearUtility{Float64}, ::MDP...
This file has been truncated, but you can view the full file.
intersect at /home/pkm/julia/julia/src/subtype.c:1628
intersect_ufirst at /home/pkm/julia/julia/src/subtype.c:1032 [inlined]
intersect_var at /home/pkm/julia/julia/src/subtype.c:1100
intersect at /home/pkm/julia/julia/src/subtype.c:1628
intersect_ufirst at /home/pkm/julia/julia/src/subtype.c:1032 [inlined]
intersect_var at /home/pkm/julia/julia/src/subtype.c:1100
intersect at /home/pkm/julia/julia/src/subtype.c:1628
intersect_ufirst at /home/pkm/julia/julia/src/subtype.c:1032 [inlined]
intersect_var at /home/pkm/julia/julia/src/subtype.c:1100
intersect at /home/pkm/julia/julia/src/subtype.c:1628
using Optim, Calculus
# Let's try with a polynomial. It has very simple Hessian, as there are no cross
# products, only quadratic terms. Hence the Hessian is a diagonal matrix where
# diag(H) = [2, 2, ..., 2]. Let's try to see if that's what we get!
function large_polynomial(x::Vector)
res = zero(x[1])
for i in 1:250
res += (i - x[i])^2
end
return res
using BenchmarkTools
K = 5
N = 3
z = [rand(20000, K) for i =1:N]
P = [rand(20000) for i = 1:N]
cache = zeros(20000, K)
function test1(P, z)
for i in eachindex(P)
cache .= P[i].*z[i]
K = 5
N = 3
z = [rand(20000, K) for i =1:N]
P = [rand(20000) for i = 1:N]
Pm = rand(20000, N)
Pv = [@view Pm[:, j] for j = 1:N]
cache = zeros(20000, K)
function test1(P, z)
for i in eachindex(P)
function LearnBase.learn!(solver::CrossEntropyMethod, env::AbstractEnvironment, doanim = false)
# !!! INIT:
# this is a mappable function of θ to reward
cem_episode = θ -> begin
π = cem_policy(env, θ)
R, T = episode!(env, π; maxiter = solver.options[:maxiter])
R
end
julia> using Optim
julia> function rosenbrock(x)
N = length(x)
fval = 0.0
for i in 1:div(N, 2)
fval += 100(x[2i-1]^2 - x[2i])^2 + (x[2i-1] - 1.0)^2
end
fval
end
using BenchmarkTools
A = rand(10000)
B = Vector[rand(10) for i = 1:1000]
C = rand(10,1000)
D = rand(10000)
E = Vector[rand(10) for i = 1:1000]
F = rand(10, 1000)
function fast!(a, c)