In our previous installments, we laid the groundwork of our Bee Colony Algorithm implementation. Today, it’s time to put the bees to work, searching for an acceptable solution to the Traveling Salesman problem.

We will approach the search as a Sequence: starting from an initial hive and solution, we will unfold it, updating the state of the hive and the current best solution at each step. Let’s start with the hive initialization. Starting from an initial route, we need to create a pre-defined number of each Bee type, and provide them with an initial destination:

let Initialize nScouts nActives nInactives cities (rng : Random) = [ for i in 1 .. nScouts do let solution = Evaluate(Shuffle rng cities) yield Scout(solution) for i in 1 .. nActives do let solution = Evaluate(Shuffle rng cities) yield Active(solution, 0) for i in 1 .. nActives do let solution = Evaluate(Shuffle rng cities) yield Inactive(solution) ]

There is probably a more elegant way to do this, but this is good enough: we use a simple List comprehension to generate a list on the fly, yielding the appropriate number of each type of bees, and assigning them a shuffled version of the starting route.

## Comments

- It takes one to know one (3)
- Create optimization programs dynamically with C# and the Microsoft Solver Foundation (8)
- Management, the Gordon Ramsay way (4)
- VSTO add-in with multiple assemblies (5)

Comment RSSRon wrote: Statistics are used much like a drunk uses a lampp... [More]

Ron wrote: I just started tinkering with Solver the other day... [More]

bryan tyler nelson wrote: I do not even understand how I stopped up right he... [More]

prestamo wrote: What i do not realize is in truth how you are now ... [More]