[julia-users] macro: with

2016-10-09 Thread Ben Lauwens
Hi Tom

I am interested. I am building a macro mimicking how iterator blocks are 
transformed in a state-machine in C# (as an alternative to Tasks) and this is 
one of the (many) thinks I have to solve. Can you point me to the source? Thanks

Ben

[julia-users] use of parse and eval to create programmatically anonymous function

2016-04-28 Thread Ben Lauwens
Hi

I like to create automatically functions that evaluates the total 
derivative of a function with respect to time, eg.
given f(t, x1, x2) = t^2+x1*x2, I want to obtain 
df/dt(t,x1,x2,dx1/dt,dx2/dt) = 2t+x1*dx2/dt+x2*dx1/dt, 
d2f/dt2(t,x1,x2,dx1/dt,dx2/dt,d2x1/dt2,d2x2/dt) = 
2+2dx1/dt*dx2/dt+x1*d2x2/dt2+x2*d2x1/dt2, and so on. 
The initial function is specified as a string as are the arguments.
The following code using the Calculus package works nicely:
using Calculus

function total_derivatives_with_respect_to_time(f::AbstractString, 
order::Int, names::AbstractString...)
  derivs = Array(Function, order)
  n = length(names)
  args = AbstractString["t", names...]
  derivs[1] = eval(parse("($(reduce((a,b)->"$a,$b",args)))->$f"))
  if order > 1
fun = f
for o = 2:order
  ∇fun = differentiate(fun, args)
  dfun = AbstractString["$(∇fun[1])"]
  for i = 1:n
push!(args, "d$(o-1)_$(names[i])")
  end
  for j = 2:(o-1)*n+1
push!(dfun, "($(∇fun[j])) * $(args[j+n])")
  end
  fun = reduce((a,b)->"$a + $b", dfun)
  derivs[o] = eval(parse("($(reduce((a,b)->"$a,$b",args)))->$fun"))
end
  end
  return derivs
end

derivs = total_derivatives_with_respect_to_time("t^2+x1*x2", 3, "x1", "x2")
println(derivs[1](1.0, 2.0, 3.0))
println(derivs[2](1.0, 2.0, 3.0, 4.0, 5.0))
println(derivs[3](1.0, 2.0, 3.0, 4.0, 5.0, -1.0, -2.0))
I have however the feeling that I am abusing the sequence of eval and parse 
to automatically generate anonymous function. Is there a way to do this 
more elegantly? Performance wise the code runs fine in Julia v0.5.

Ben


[julia-users] 2nd Julia Meetup Belgium

2016-03-14 Thread Ben Lauwens
You are cordially invited to attend the 2nd Julia Meetup in Belgium on 
Wednesday 13th of April 2016 at the Royal Military Academy in Brussels.
Programme:
1300 Welcome at the conference complex
1330 Tutorial sessions:
- Julia for novices
- Advanced Julia
1500 Coffee break
1530 Presentations by Julia package developers and/or users
1700 Reception
The entrance is free but registration by e-mail (ben.lauw...@rma.ac.be 
)
 
is mandatory to access the premises. License plate information is needed if 
you want to use the parking facilities.
Proposals for presentations are welcome and can be sent by e-mail before 
the 5th of April 2016. We are looking for talks about innovative packages 
or interesting use cases.
Location: Royal Military Academy, Hobbemastraat 8, 1000 Brussel
Kind regards

Ben


[julia-users] Re: Julia Meetup Ghent University, Sept 29

2015-09-30 Thread Ben Lauwens
Hi Ken

Thanks for the organisation of this very successful event!
My colleagues really appreciated the tutorial and I had no idea that Julia 
was already used in business.
I will do my best to organise a second Julia Meetup in Belgium at the end 
of January, starting of February.

Kind regards

Ben

On Friday, September 11, 2015 at 11:36:22 AM UTC+2, Ken B wrote:
>
> Hi all,
>
> I'm organising a first Julia meetup in Belgium. 
>
> We'll have 4 presentations by:
>
>- Jutho Haegeman (UGent) on his TensorOperations.jl 
><https://github.com/Jutho/TensorOperations.jl> package
>- Tim Besard (UGent) on compiling Julia on the GPU
>- Ben Lauwens (RMA Brussels) on his SimJulia.jl 
><https://github.com/BenLauwens/SimJulia.jl> package
>- Jan Dolinksy (Tangent Works <http://www.tangent.works/>) on using 
>Julia in Business Applications
>
> It will take place on 29/9 at 17h at the campus Tweekerken of Ghent 
> Unversity, building Hoveniersberg, room 0.2 Camiel De Pelsemaeker.
>
> You are all welcome, but please confirm your attendence (a maybe is fine) 
> by email to ken.bastiaensen (at) ugent.be.
>
> Before the meetup an introduction to Julia for newcomers will take place 
> at 14h (same location) and there will be some drinks after the meetup.
>
> Kind regards,
> Ken
>


[julia-users] ANN: SimJulia 0.3.4

2015-08-18 Thread Ben Lauwens
Hi

SimJulia, a (combined continuous time / ) discrete event process oriented 
simulation framework, has reached another milestone:

   - v0.3.4 synchronizes the API with SimPy v3 but using some specific 
   Julia semantics
   - It is a complete rewrite allowing a more powerful and unified discrete 
   event approach
   - 10 min tutorial is included to give users a taste of discrete event 
   simulation with (Sim)Julia
   - A detailed topical guide is also written

For the moment the continuous time part is not operational. A *quantized 
state system* (QSS) solver is being developed for continuous system 
simulation using the discrete event framework. Once this is done v0.4 will 
be tagged.
New ideas or interesting examples are always welcome and can be submitted 
as an issue or a pull request on GitHub.
Enjoy!

Ben


Re: [julia-users] ANN: SimJulia 0.3.4

2015-08-18 Thread Ben Lauwens
Tom

The event scheduling in SimJulia is based on the standard PriorityQueue* 
implementation of Julia and the overhead of SimJulia is really limited. If 
you throw away the process oriented way of defining a simulation model, you 
can do theoretically better, i.e. pure event simulation. This is certainly 
true for small models but for bigger ones you (I for sure) will end up 
developing a massive spaghetti code.
I have used the previous version of SimJulia in some large simulation 
models and compared to SimPy or commercial simulation software (ARENA) the 
speedup I measured was often more than two orders of magnitude. We are 
right now porting two large projects (HR planning and medical battlefield 
management) from ARENA to SimJulia. The benefits of Julia are enormous. No 
more mixed code (SIMAN and Visual Basic) and being able to troubleshoot the 
internals of the simulation are for me the most important advantages.

* The standard PriorityQueue is based on a binary heap and in my PhD I have 
shown that if you have no prior knowledge on the timing of the events, no 
event calendar (tree, heap, sorting, ...) can do better in a real 
implementation if you consider the extreme low overhead of its 
implementation (Vector based, no pointers and limited number of 
comparisons). I know that some other heap mechanisms (Binomial, Fibonacci, 
...) have better time complexities but I have never found one that 
performed as well on real use cases as as binary heap.

Most people are afraid of this process oriented programming. Programmers 
prefer the idea of sequential execution and the main philosophy of 
processes is asynchronous tasking. It takes my master students some weeks 
to get used to it but once they passed this difficulty, they are ready to 
tackle real world simulation problems. 

Often (almost always) we are doing Montecarlo simulations of 1000 or more 
repetitions and use the SimJulia framework in the inner loop. We are also 
working on simulation based optimization and the SimJulia framework is also 
used in the inner loop. To estimate the loss of speed compared to a more 
direct approach is very difficult to predict. One thing I am quite sure of 
is the ease of development when using process based simulations.

I hope that I somehow answered your question. Please feel free to contact 
me if you need some assistance with your SimJulia coding.

Ben

On Tuesday, August 18, 2015 at 9:52:21 PM UTC+2, Tom Breloff wrote:

 Thanks for the effort Ben.  I'm curious... do you have any performance 
 comparisons of SimJulia vs other (simpler) code designs?  How much speed 
 would I be giving up if I was using events in a tight inner loop?

 On Tue, Aug 18, 2015 at 1:25 PM, Ben Lauwens ben.l...@gmail.com 
 javascript: wrote:

 Hi

 SimJulia, a (combined continuous time / ) discrete event process 
 oriented simulation framework, has reached another milestone:

- v0.3.4 synchronizes the API with SimPy v3 but using some specific 
Julia semantics
- It is a complete rewrite allowing a more powerful and unified 
discrete event approach
- 10 min tutorial is included to give users a taste of discrete event 
simulation with (Sim)Julia
- A detailed topical guide is also written

 For the moment the continuous time part is not operational. A *quantized 
 state system* (QSS) solver is being developed for continuous system 
 simulation using the discrete event framework. Once this is done v0.4 
 will be tagged.
 New ideas or interesting examples are always welcome and can be submitted 
 as an issue or a pull request on GitHub.
 Enjoy!

 Ben