'How to generate initial population for class scheduling problem in this case?

We are trying to generate initial population. In such way that user inputs the teacher data as follows.
Teacher1 - Subject1 - periodsperweek Suppose

if periodsperweek=5 

It is divided as

[1,2],[3,4],[5] 

For teacher2

if periodsperweek=4 

then We divide it as

[6,7],[8,9]

And so on

There are altogether 8 periods in a day including break

Our code separated the double period lecture , lab class and single class as. '''

Double lecture=[[1,2],. 
[3,4],.......]
lab_class=[[34,35,36],.....]
single_lecture=[[16], [22]]

'''

This list contains all the teachers lectures in that particular semester.

Now we generate the initial population for week using certain functions which gives total of 6*8=48 lectures in week time

[[14, 15, 12, 13, 100, 8, 9, 33], 
[37, 38, 39, 100, 16, 17, 25, 26], 
[27, 28, 12, 13, 100, 34, 35, 36], 
[40, 41, 42, 100, 14, 15, 20, 21], 
[10, 11, 1, 2, 100, 8, 9, 33], 
[29, 30, 6, 7, 100, 3, 4, 5]]'''

Where 100 denoted the break time.

Is this the right approach to generate population? We have to solve it for 12 different semester?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source