Skip to content

Instantly share code, notes, and snippets.

%Do the simulation and compute a few things from the traces
Ten = 24;%entrainement period
Tin = 12;%intrinsic period
m = @(th,t) 2*pi/Tin + 0.2*sin(th) * (0.5*cos( 2*pi/Ten*t) + 0.5)^10;
Nt = 1e5;
dt = 1e-2;
T = linspace(0,Nt*dt,Nt)';
julia> function test()
string(myid()) * " : it works!"
end
test (generic function with 1 method)
julia> addprocs(1)
1-element Array{Int64,1}:
2
julia> remotecall_fetch(2,isdefined,:test)
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.5.0 (2016-09-19 18:14 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-w64-mingw32
julia> using Gtk
do_collect(ex::Expr) = any( ex.head .== [:call, :(=)])
dont_collect(ex::Expr) = any( ex.head .== [:line])
function get_vars2(ex::Expr,out,assigned)
ex.head == :(=) && push!(assigned,ex.args[1])
# println(ex)
if do_collect(ex)
for i = 2:length(ex.args)
get_vars2(ex.args[i],out,assigned)
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.6.0 (2017-06-19 13:05 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-apple-darwin13.4.0
julia> Pkg.status()
bielers-MacBook-Air:~ bieler$ /Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.6.0 (2017-06-19 13:05 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-apple-darwin13.4.0
## header to provide surface and context
using Cairo
c = CairoRGBSurface(256,256);
struct cairo_font_options_t end
options = ccall((:cairo_font_options_create,Cairo._jl_libcairo), Ptr{cairo_font_options_t}, ())
ccall((:cairo_font_options_set_antialias,Cairo._jl_libcairo), Void, (Ptr{cairo_font_options_t},Cint),options,Cairo.ANTIALIAS_SUBPIXEL)
set_font_options(cr,options) = ccall((:cairo_set_font_options,Cairo._jl_libcairo), Void,
(Ptr{Void},Ptr{cairo_font_options_t}),cr,options)
module A
using Optim
import Optim: FirstOrderOptimizer, initial_state, update_state!, trace!, assess_convergence, AbstractOptimizerState, update!, value
struct MinimalGradientDescent <: FirstOrderOptimizer
η::Float64
end
module CMAES
using Distributions
∑(x) = sum(x)
function init_constants(xinit,λ,w,μ)
D = length(xinit)
μ_w = 1.0 / sum(w.^2)
module A
using Optim
import Optim: ZerothOrderOptimizer, ZerothOrderState, initial_state, update_state!, trace!, assess_convergence, AbstractOptimizerState, update!, value
struct RandomSampler <: ZerothOrderOptimizer
σ::Float64
end
RandomSampler(; σ=1e-1) = RandomSampler(σ)