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 (9)
- Free trade (1)
- AdaBoost in F# (2)

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

green coffee bean pure extract 800 mg wrote: Hello there I am so grateful I found your web site... [More]

buyinvestmentpropertyonline.com wrote: Howdy I am so thrilled I found your site, I really... [More]

Suggested Internet page wrote: I am now not certain where you are getting your in... [More]