Skip to content

danielsonchris/ABCNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ABCNet Build Status

An extensible Artificial Bee Colony .Net Library. Initial usage was for a distributed clustering solution. We effectively required this algorithm for spreading processes across a multitude of servers that may or may not have been available.

A parent process dynamically acted as the hive entity and from that vantage point healthy foraging resources were selected for processing long running scheduled items or event driven tasks.

Available from Nuget

Simple Example

using ABCNet;

public static double FitnessCheck(FoodSource foodSource, Bee bee) {
    //TODO return something meaningful
    return 1d;
}
//snip...
var random = new Random();
List<FoodSource> foodSources = new List<FoodSource>();
for (int i = 0; i < 10; i++)
    foodSources.Add(new FoodSource(FoodSourceLocation.GenerateRandom(random)));
Colony colony = new Colony(100, foodSources, FitnessCheck);
var fittestSources = colony.Run();

More Complete Example Usage

using System;
using System.Collections.Generic;
using ABCNet;

class Program
{
    private static Random random = new Random(Guid.NewGuid().GetHashCode());
    public static double FitnessCheck(FoodSource foodSource, Bee bee) {
        var geo = foodSource.Location.GeoCoordinate;
        //Console.WriteLine(string.Format("{0:0.##}, {1:0.##}", geo.Latitude, geo.Longitude));
        return random.NextDouble();
    }

    static void Main(string[] args)
    {
        List<FoodSource> foodSources = new List<FoodSource>();
        for (int i = 0; i < 10; i++) {
            foodSources.Add(new FoodSource(FoodSourceLocation.GenerateRandom(random)));
        }
        for (int i = 0; i < 50; i++)
        {
            Colony colony = new Colony(100, foodSources, FitnessCheck);

            var fittestSources = colony.Run();
            fittestSources.ForEach(x =>
            {
                Console.WriteLine(string.Format("{0:0.000} => {1}", x.FitnessValue, x.ToString()));
            });
            Console.WriteLine("==============================");
        }
        return;
    }
}

Troubleshooting Notes

  • If using dotnet core, make sure to apply a "dotnet restore" in order to reload the nuget dependencies.

About

Extensible Artificial Bee Colony .Net Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published