Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2 Securing the companies ( 1 0 marks, including 2 marks for documentation ) Assume that you are the manager of a security company tasked
Securing the companies
marks, including marks for documentation
Assume that you are the manager of a security company tasked with assigning security officers
n to a group of companies m in a certain month with days numbered D D D Assume
that security officers are denoted by SO SO SOn and the companies are represented
by C C Cm There are three hour shifts per day: Smidnightam Sampm
and Spmmidnight For each pair companyshift Cj Sk the company Cj has a different
number of security officers required for the shift Sk however, this is constant for each day of
the month.
The security officers specify the shifts they are interested in working on and they have the
opportunity to indicate more than one preferred shift. However, they cannot be allocated
to more than one shift per day. Further, the shift preference of each security officer should
be the same for all the days of the month and therefore specified only once per security officer
Your task is to provide a plan for assigning officers to the companies for the coming month
according to the requirement of the number of security officers per shift by each company. For
each day of the month, and for each shift, each company should be allocated exactly the same
number of security officers it requests. There are integer parameters, minshifts
minimum number of shifts and maxshifts maximum number of shifts and the
total number of shifts allocated to each security officer in a month should be within these two
integer parameters closed interval
As long as you comply with the constraints above, you are free to allocate the security officers
any way you want.
The input to your function allocate consists of a list of preferred shifts provided by each
security officer and the number of security officers requested by the companies for each shift:
preferences is a list of lists, where preferencesik is a binary value or indicating
whether security officer SOi is interested in working on shift Sk in that month indicates that
the officer is interested officersperorg is a list of lists, where officersperorgjk
is a nonnegative number that specifies how many security officers company Cj needs for shift
Sk on each day of that month.
Your task is to implement a function allocatepreferences officersperorg, minshifts,
maxshifts which returns:
None ie Python NoneType if no allocation satisfying all constraints exists.
Otherwise, it returns a list of lists allocation, where allocationijdk is equal
to if security officer SOi is allocated to work for company Cj during shift Sk on day Dd
Complexity requirement: The worstcase time complexity of your solution should be
Om n n
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started