This is a continuation of my previous question that was how to represent a single chromosome, I found a way how, but I have a problem with how to represent this in memory.
I am writing a Project Scheduling Optimization library, a special kind of a Job Shop scheduling problem. To keep it simple, so far my algorithm will only work with workers being the only resource for the project (later I should be able to add more resources), and there are only 2 types of constraints (later there will be more constraints too) so far:
1) Every worker has a constraint on what projects he can work on. Only some workers are skilled to work on the same project (for example: W1, W3, W7 worker can work on project P2; W2, W3, W5 can work on project P3; etc), but same worker can be skilled to work on multiple projects, and is allowed to work on multiple projects at different times (for example: W1 works on P1 5 days [or even hours] in a row, then he switches to P2 for 4 days, then he comes back to P1, etc)
2) Every worker has a constraint on how many hours he can work each day -- this should represent a worker's efficiency
To start with, I created a simple timetable consisting of only 4 projects and 4 workers.
PROJECTS:
- P1; starting: May, the 1st; deadline: 30 days; work hours needed: 300
- P2; starting: July, the 1st; deadline: 60 days; work hours needed: 150
- P3; starting: May, the 15th; deadline: 45 days; work hours needed: 50
- P4; starting: April, the 20th; deadline: 20 days; work hours needed: 150
WORKERS:
- W1; efficiency: 10h/day; available for projects: P1, P2, P3, P4
- W2; efficiency: 5h/day; available for projects: P1, P3
- W3; efficiency: 8h/day; available for projects: P1, P4
- W4; efficiency: 6h/day; available for projects: P2, P4
With a problem being setup like this, I found a single chromosome (single schedule) should represent which worker works on which project for every single hour until the last project is finished.
In this example, the timetable should go from April, the 20th until July the 1st + 60 days. So that is 130 days in total x 12 hours = 1560 hour slots. In each slot there should be a worker with the assigned project for that hour slot.
What would be the correct data structure to use for the slot (it seems inefficient to allocate new Worker object for every slot?), and that is capable for crossover and mutation?