From: ptkwt@... (Phil Tomson) Date: 2005-09-07T15:56:32+09:00 Subject: Re: Particle Swarm Optimizer in Ruby?(and framework philosophy) In article <1126066993.277268.82250@g43g2000cwa.googlegroups.com>, wrote: >Yeah, the hard part of PSO and genetic algorithms is coming up with a >way to represent the problem with a vector of a predetermined length >(ok well with genetic algorithms there are ways around the set vector >length actually). In your case it looks pretty simple actually. I >assume that the number of atoms is constant (If not then it would take >a lot more thought). Just string out all of their positions together >into one long vector. When you calculate the fitness you just have to >know how to pull out the correct position of each individual atom from >the particle's position vector. (If they're not unique then I guess >this doesn't really matter.) I believe that this would work just fine. Yes, this is essentially what I'm doing. There are 7 atoms in a cluster and each atom has a location in 3D space. 7 atoms * 3 dimensions yields 21 parameters to adjust (or put another way, there are 21 dimensions in the problems space). I give the PSO a list of 3D points (7 points) and then that list gets represented by a Vector of 21 Floats. Pretty easy to translate between the two representations. Not quite done yet, but I hope to get to the point where I'm running it tomorrow. The Framework philosophy part: The only problem now is that the PSO code I've created is quite specific to this particular problem. I thought about how I could generalize it to make it useful for any kind of optimization problem, but after about an hour of thinking about that I went ahead and just started coding it up for this particular problem... so I'm not sure my PSO code will be very useful for anyone else. I created an Ant Colony Optimization framework which can be adapted to many different types of problems, but it's flexibility actually makes it quite unwieldly, so maybe I'm better off not making the PSO so flexible. So much for code reuse :-( Phil