Re: fitness

2009-03-05 Thread Dan
On Thu, Mar 5, 2009 at 8:53 PM, Jason Wolfe wrote: > >> The mutation constructing function seems obvious in hindsight. I feel >> stupid now. > > You shouldn't :).  Immutability definitely takes some getting used to; > I know it's taking me quite some time to wrap my head around it. I'm actually

Re: fitness

2009-03-05 Thread Jason Wolfe
> The mutation constructing function seems obvious in hindsight. I feel > stupid now. You shouldn't :). Immutability definitely takes some getting used to; I know it's taking me quite some time to wrap my head around it. -Jason --~--~-~--~~~---~--~~ You receiv

Re: fitness

2009-03-05 Thread Dan
On Thu, Mar 5, 2009 at 8:11 PM, Matt Moriarity wrote: > > what about memoizing the fitness function? call fitness on your > structs, and if it's memoized, it will return the cached value as long > as the struct is the same value. if it's changed, then it will > recomput

Re: fitness

2009-03-05 Thread Jason Wolfe
utility function, which will make the change and also assoc on a new fitness delay. In the simplest case, this would just be the "constructor" for your individuals. (There's no reason to use metadata unless you care about the equality semantics of individuals.) This is the

Re: fitness

2009-03-05 Thread Matt Moriarity
what about memoizing the fitness function? call fitness on your structs, and if it's memoized, it will return the cached value as long as the struct is the same value. if it's changed, then it will recompute. somebody correct me if this doesn't account for something, but it sounds

Re: fitness

2009-03-05 Thread Dan
Thanks for the advice, I never noticed delay existed! It turns out I cannot put the fitness directly into the struct that contains individuals. It would mean that every mutating function would need to "reset" the fitness computation to avoid propagating a misleading fitness and that

Re: fitness

2009-03-05 Thread Meikel Brandmeyer
Hi, Am 05.03.2009 um 10:13 schrieb bOR_: Is there a reason why delay needs a force to be calculated? delay creates a Delay object (Promise in Scheme). This can be passed around like eg. a Vector. When you want to retrieve the value, you have to use force, like get for a map. The first time th

Re: fitness

2009-03-05 Thread bOR_
Didn't know of the existence of delay yet. Thanks for pointing that out :). Is there a reason why delay needs a force to be calculated? > > >    {:fitness (delay (compute-my-fitness))} > > > > And when you access the value use force. > > &g

Re: fitness

2009-03-04 Thread Jason Wolfe
blem; otherwise, probably not. user> (= (delay 2) (delay 2)) false If this is the case, you probably want to store the delayed fitness value as metadata on your individual: (with-meta individual {:fitness (delay ...)}) (force (:fitness ^individual)) If you don't like delay/force, a

Re: fitness

2009-03-04 Thread bOR_
If you use hash-maps, or a struct-map as the basis of your individual, you can just make a key 'fitness', and store the once-calculated fitness in there. I'm not sure how, but it might be possible that at the creation of your animals, you assign the key 'fitness' a basic

Re: fitness

2009-03-04 Thread Meikel Brandmeyer
Hi, Am 04.03.2009 um 18:21 schrieb Dan: How can I have my fitness computation be triggered on first access and reused afterward? Maybe you can use a Delay. {:fitness (delay (compute-my-fitness))} And when you access the value use force. (-> my-thing :fitness force) The first time

fitness

2009-03-04 Thread Dan
I am doing a genetic algorithm my individual have various immutable characteristics, one of them being their fitness. The problem I have with it is that fitness is somewhat expensive and can be requested zero (the individual will undergo some transformation and the fitness of the intermediary