Skip to content

Commit

Permalink
fixed some of the webfront bugs so we can start experimenting more wi…
Browse files Browse the repository at this point in the history
…th escher front end
  • Loading branch information
robertfeldt committed Jul 24, 2015
1 parent ff46999 commit 8b77c68
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions spikes/webfront/escher_webfront.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,51 @@ end

function rand_walk!(rw::RandWalker)
while true
println("New RW iteration")
print("."); flush(STDOUT);
step!(rw)
sleep(0.5 * rand())
sleep(1.0 * rand())
end
end

history = Input( (Int, Float64)[] )
fitness_history = Input( (Int, Float64)[] )

function report_new_min(i::Int, newmin::Float64)
push!(history, push!(value(history), (i, newmin)))
push!(fitness_history, push!(value(fitness_history), (i, newmin)))
end

rw = RandWalker(report_new_min)
t = @async rand_walk!(rw)

using Gadfly

function fitness_plot(iterations, fitnesses)
plot(x = iterations, y = fitnesses,
Geom.point, Geom.line,
Guide.xlabel("Iteration"), Guide.ylabel("Fitness")
) |> drawing(10inch, 6inch)
end

function main(window)
push!(window.assets, "widgets")
local content

lift(history) do hist
xvals = map(first, hist)
yvals = map(t -> t[2], hist)

println("Changed!, hist = ", hist)
lift(fitness_history) do hist
println("Changed! len = ", length(hist))
if length(hist) >= 1
its = map(first, hist)
fits = map(t -> t[2], hist)
content = vbox(
hbox("Best fitness: ", hskip(1em), @sprintf("%.3e", fits[end]) |> emph),
hbox("Found at iteration: ", hskip(1em), string(its[end]) |> emph),
fitness_plot(its, fits),
)
else
content = hbox("No min found yet...")
end

vbox(
h1("Fitness progress") |> emph,
hbox("Best fitness: ", hskip(1em), @sprintf("%.3e", yvals[end]) |> emph),
hbox("Found at iteration: ", hskip(1em), string(xvals[end]) |> emph),
# Scale.x_log10, Stat.step
plot(x = xvals, y = yvals, Geom.point, Geom.line) |> drawing(8inch, 6inch)
) |> packacross(center)
vbox(
h1("Fitness progress") |> emph,
content
) |> packacross(center)
end
end

0 comments on commit 8b77c68

Please sign in to comment.