Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant Colony Optimization or Genetic Algorithm for percentage based problem

So I've recently become really fascinated with algorithms in general. And I recently implemented an ant colony optimization algorithm to solve the TSP (very fun obviously). Now I've been looking at other "problems" to solve. Now I wanted to implement an algorithm to solve a problem involving fulfilling a percentage requirement, and to be below an arbitrary limit.

For example:

User input:

1) limit -i.e. amount of energy available to spend.

2) "chromosome" types -i.e. blue(subtypes - indigo, etc), red(subtypes - maroon, etc), yellow(subtypes - light yellow, etc) -each primary attribute like blue has a "pool" to choose from which consist of different subtypes like indigo, light blue, sea blue whatever. -each sub type of color has a varying cost associated to it.

3) percentage of types required for the "ideal" solution (can introduce a +/- % to allow for more variety). -i.e. 10% red, 30% blue, 60% yellow.

Output:

1) possible final solutions which fulfill the two requirements, being below - but close to the - required cost and meeting the percentage requirements of supertypes.

So for example.

This is a super simple example, obviously it'd be more complex than this in reality.

User specifies cost should be as follows 95 <= cost <= 105.

User chooses 25% blue, 25% yellow, 50% red. with +/- 5% deviation

Available pools for each color

Blue: Indigo: cost = 25; Sea blue: cost = 30; Navy Blue: cost = 75;

Yellow: Light yellow: cost = 20; Dark yellow: cost = 30; Super dark yellow(lol): cost = 75;

Red: Maroon: cost = 20; Blood Red: cost = 45; Bright Red: cost = 55;

So the algorithm would run and return different combinations.

Combination 1: indigo, dark yellow, blood red: cost = 100: blue = 25%, yellow = 30%, red = 55%.

Combination 2: sea blue, light yellow, blood red: cost = 105: blue = ~30%, yellow = ~20%, red = ~50%

Combination 3: so on and so forth.

EDIT: Second edit

Output would consist of sets of different combinations.

For example, one solutions might consist of combinations like:

One solution would be represented by this:

Combination 1: Cost = 20; 50% blue, 25% yellow, 25% red;

Combination 2: Cost = 30; 10% blue, 50% yellow, 40% red;

Combination 3: Cost = 50; 25% blue, 25% yellow, 50% red;

Solution: = (combination 1, combination 2, combination 3) total cost = 100, and it consists of x% blue, y% yellow, z% red;

compare solution to requirements, if its close keep it, if not discard it.

END EDIT

So my question is. I know a genetic algorithm would work. But would an implementation of ACO work as well? For example, blue, yellow and red would equal "locations", then their subtypes would represent different "roads".

Just wondering what might be a more efficient solution or maybe some different algorithm entirely. I'm pretty new to this stuff and just started reading about it a little over a week ago.

EDIT: First edit

I want to specify that I want to have 5 good unique solutions (5 being an arbitrary number, could be 3, could be 20).

like image 502
Odnxe Avatar asked Aug 09 '11 14:08

Odnxe


2 Answers

Your color problem seems pretty trivial to me, even brute force would be fast, I guess.. so your ant colony most probably can solve it too :)

like image 80
duedl0r Avatar answered Sep 28 '22 01:09

duedl0r


If your graph satisfy the triangle inequality I suggest you to try a minimal spanning tree and a perfect-weight-non-bipartite matching algorithm. Christofides et al. guarantee you a solution within 3/2 of the optimum. An AOC can give you good and fast result, but you have to optimized it for many problems. I've wrote a Christofides algorithm in php (phpclasses.org). You are welcome to try it out. I'm not sure if it's working. It give sometimes strange results. It's maybe my implementation of the Fleury algorithm?

like image 31
Micromega Avatar answered Sep 27 '22 23:09

Micromega