15,964,052 members
See more:
Hi ,
I am trying to solve the facility location problem and one of the methods to solve it is by using the genetic algorithm . I have a fair understanding of how the algorithm works but i am unable to put it into code form .

example problem

There are 3 levels and a total of 5 potential facility locations .

2 out of the 5 facilities are on level 1 and the rest of the 3 are on level 2 .

level 3 consists of 5 clients .

To reach any client on level 3 , one has to start at level 1 then move on to level 2 and then finally to a particular client .

There is a fixed cost associated with setting up a facility .

The distances between any 2 locations , i.e , facilities on level 1 to facilities on level 2 , facilities on level 2 to clients on level 3 is given . I need to minimise the cost .

cost = (cost of setting up warehouse) + (distance * cost per unit distance)

demand for each client has to be satisfied .

If someone could give me a rough idea of how to go about this using the Genetic Algorithm it would be of massive help .
Posted

## Solution 1

hi,
first of all the traversal paths need to be well defined. i.e. which all are the possible traversals.
example.
startPoint-->level1facility1-->level2facility1-->client1
startPoint-->level1facility1-->level2facility2-->client2
startPoint-->level1facility1-->level2facility3-->client3
--------------------------------------------------------
.................................etc.

Basically, what this algo solves is :
what is the minimal cost path to reach from say,level1facility1 to client3 ??

Now select a suitable data structure. A graph would be helpful in this case to represent the levels. Thinking in terms of a generic solution and not just limited to 3 levels.

hope this helps !!

OR
take a look at Genetic Algorithms and the Traveling Salesman Problem[
title="New Window">^
] and see how it suits your case.

v2

## Solution 2

Interesting . Yes it is something i can build upon . Finally i need to decide upon the ideal number of facilities to be set up among the potential facilities while minimizing the total cost . The hard constraint being that the demand at every client must be met .

Thanks a lot !