January 2020
Intermediate to advanced
346 pages
9h 8m
English
To encapsulate the nurse scheduling problem we described at the beginning of this section, we created a Python class called NurseSchedulingProblem. This class is contained in the nurses.py file, which can be found at https://github.com/PacktPublishing/Hands-On-Genetic-Algorithms-with-Python/blob/master/Chapter05/nurses.py.
The class' constructor accepts the hardConstraintPenalty parameter, which represents the penalty factor for a hard constraint violation. Then, it continues to initialize the various parameters, describing the scheduling problem:
# list of nurses:self.nurses = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']# nurses' respective shift preferences - morning, evening, night:self.shiftPreference = [[1
Read now
Unlock full access