I am currently working on a project for driver scheduling and it's at the initial stage. I have decided to use GA to generate optimized schedule for a driver, and as most of GA project do, the population shall be represented in binary.
e.g. if a driver is assigned two hours of task and his working duration is 9 hours, the possible population for that specific day looks like 110000000, 011000000, 001100000 and so on.
As GA's initialization, I would like to produce possible gene like 000110000 dynamically with two parameters (working duration of driver, and duty duration).
I managed to get fully random binary code in boolean list (see below) but this is not what I want to represent as the initialization.
This is the partial code which generates random binary string (technically bunch of boolean values) in a list.
private Random Rnd = new Random();
//initial data
private List<bool[]> CreateInitialData()
{
//generate 4 random genes (might be more)
return Enumerable.Range(0, 1).Select(_ =>
{
var array = new bool[GeneLength];
for(int i = 0; i < GeneLength; i++)
{
array[i] = Rnd.Next(0, 2) == 1;
}
return array;
}).ToList();
}
How could I implement the initialization function to produce the binary code which meets the requirement (driver's working hours, estimated duty duration)? If there is a better way to represent it other than boolean list, please do suggest as well.