[Icfp04-discuss] Scheme, Ruby ?

Dmitri Kondratiev d_kondr at yahoo.com
Wed Jun 16 16:55:20 EDT 2004


I almost completed simulator / visualizer in NetLogo
before submission dead line. After that I decided to
reimplement simulator in Scheme and Ruby to compare
these languages for this kind of a task. That's why I
am interested in other simulator implementations in
Scheme. 
Now when I can acceess your repository, it would be
much easier to get your sources/submission as a single
 tar ball. Could you please put a single submission
tgz/zip file in your repository ?

It would be interesting to see how you optimized the
code replacing the numbers for states with their
actual closures to avoid a vector reference.

As for data structures, in my NetLogo simulator I
maintain ant ID in every cell object of the ant
occupying it (if any), as well as current cell coords
(x y) in every ant object. I also have a function
returning cell object for given (x y). 
All this is trivial but makes movement and other ant
operations more clean, I think. Don't know if you did
the same.

Best of luck,
Dima


--- Alejandro Forero Cuervo <bachue at bachue.com> wrote:
> > > It would be interesting to profile your
> simulator to find the
> > > code  consuming most  of  the time  in  a single
>  round. What
> > > structure you used to represent ant world in
> Scheme ?
> >
> > [...]  I might  apply some  of these  changes and 
> see if  they
> > actually  improve things.   I  know, I  should 
> use a  profiler
> > first.
> 
> Ok, I  optimized my simulator  and built it with 
> the appropriate
> compiler flags.
> 
> Before my  optimizations, I tested  it with two
> instances  of the
> sample.ant running for 100.000 rounds in the
> sample0.world world.
> I got the following times:
> 
> real    1m25.965s
> user    1m24.392s
> sys     0m0.388s
> 
> Sorry, that's 3 times my previous report of "around
> 30 seconds".
> 
> After my optimizations, the time went down 1/3:
> 
> real    0m30.629s
> user    0m29.653s
> sys     0m0.312s
> 
> Building it with the appropriate compiler flags
> (removing a lot of
> safety checks) the time went down another 1/3:
> 
> real    0m7.956s
> user    0m7.672s
> sys     0m0.081s                                    
>                                                     
>    
> 
> These times are  measured in a 2.8 Ghz Athlon  with
> plenty of RAM
> under Chicken 1.51 and GCC 3.3.3.
> 
> What  did  I  optimize?   I  made  the  simulator 
> make  as  many
> computations  as  it  can  as it  reads  the 
> instructions  (this
> accounts  for  about 3/4  of  the  new  savings). 
> Also,  in  the
> closures associated  with instructions  (states), I 
> replaced the
> numbers for states  with their actual closures to 
> avoid a vector
> reference (this accounts for 1/4 of the savings).
> 
> There are still  more optimizations that can be 
> tried.  Here are
> some ideas:
> 
> - Turn  the list  of  ants  into a  doubly  linked
> list.   Remove
>   resting ants from  it.  Rather than record the 
> number of turns
>   that an ant should rest, record  the number of the
> turn when it
>   will be  allowed to move again.   Keep resting
> ants in  a list,
>   sorted by the turn when they will be allowed to
> move again (and
>   keep a pointer to its  tail for fast insertion). 
> Assuming that
>   half the ants  are resting at any given time, 
> this could bring
>   the running time to a half.
> 
> - Optimize the movement and senses, as I explained
> in my previous
>   mail.  There are still some  computations that can
> be spared in
>   moves and senses.
> 
> Thanks.
> 
> Alejo.
> http://bachue.com/alejo
> 
> ---=(  Comunidad de Usuarios de Software Libre en
> Colombia  )=---                                     
>                         
> ---=(  http://bachue.com/colibri )=--=(
> colibri at bachue.com  )=---                           
>                                   
> 

> ATTACHMENT part 1.2 application/pgp-signature
name=signature.asc
> _______________________________________________
> Icfp04-discuss mailing list
> Icfp04-discuss at lists.seas.upenn.edu
>
http://lists.seas.upenn.edu/mailman/listinfo/icfp04-discuss
> 


=====
Dmitri Kondratiev,
d_kondr at yahoo.com
http://www.geocities.com/dkondr/

Principal Architect
R&D LUXOFT
IBS group of companies
dkondratiev at luxoft.com
http://www.luxoft.com


		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 


More information about the Icfp04-discuss mailing list