Answered step by step
Verified Expert Solution
Link Copied!

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

2 Securing the companies
(10 marks, including 2 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 30 days numbered D0, D1,..., D29. Assume
that security officers are denoted by SO0, SO1,... SOn1 and the companies are represented
by C0, C1,... Cm1. There are three 8-hour shifts per day: S0(midnight-8am), S1(8am-4pm),
and S2(4pm-midnight). For each pair company/shift (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 (1) preferred shift. However, they cannot be allocated
to more than one (1) 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 2 integer parameters, 0<=min_shifts<=30
(minimum number of shifts) and 0<=max_shifts <=30(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 preferences[i][k], is a binary value (0 or 1), indicating
whether security officer SOi is interested in working on shift Sk in that month (1 indicates that
the officer is interested). officers_per_org is a list of lists, where officers_per_org[j][k]
is a non-negative 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 allocate(preferences, officers_per_org, min_shifts,
max_shifts) which returns:
None (i.e., Python NoneType), if no allocation satisfying all constraints exists.
Otherwise, it returns a list of lists allocation, where allocation[i][j][d][k] is equal
to 1 if security officer SOi is allocated to work for company Cj during shift Sk on day Dd.
Complexity requirement: The worst-case time complexity of your solution should be
O(m n n).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions