Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: [email protected]
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Take our 85+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

Publication

Manager, use this to plan the smart working days for your team!
Latest

Manager, use this to plan the smart working days for your team!

Last Updated on December 23, 2021 by Editorial Team

Author(s): Alberto Prospero

Originally published on Towards AI the World’s Leading AI and Technology News and Media Company. If you are building an AI-related product or service, we invite you to consider becoming an AI sponsor. At Towards AI, we help scale AI and technology startups. Let us help you unleash your technology to the masses.

Optimization

A mathematical optimization tool to schedule smart working days and plan returns to theΒ office

Photo by Diggity Marketing onΒ Unsplash

Introduction

During covid-19 several teams were constrained to work from home entirely. Fortunately, the situation has partially improved during the last year and in many countries, teams are being allowed to partially return to the office. This project aims to provide a tool to all managers for better planning the return of employees to the office or the smart working days for the nextΒ weeks.

The article is organized as itΒ follows:

  • Motivation, expressing the reasons why an optimization algorithm can help in planning and scheduling.
  • Optimization algorithm, providing an introduction to the main objects of the mathematical optimization.
  • Modeling, detailing how part of the optimization modeling was performed. This is the most challenging section and can beΒ skipped.
  • Results, describing the results obtained from the algorithm.
  • Conclusion, wrappingΒ up.

In the article, I assume that you have some familiarity with concepts and ideas related to mathematical optimization. If this is not the case, I recommend having a look at this free course on Coursera. It is tough, but it is worthΒ it!

You can find all the details and the code on my GitHubΒ page.

Motivation

Planning the return of employees to the office can be a complicated task for humans. Choosing the best possible configuration can be incredibly challenging, especially if there are many constraints to take into account. For example, we might need to consider the return preferences of the employees, the available workstations, the maximum capacities of rooms, and social distances. Considering all of these at the same time might be hard for humans, especially if we are aiming to find the best possible configuration.

For these reasons, an optimization algorithm can help. It can take into account different factors, define hard constraints to prevent specified configurations, and mathematically be sure that the identified solution is the optimalΒ one.

Optimization parameters

The optimization model is composed of three main objects: the decision variables, the objective function, and the constraints. Any of these can be fully customized within theΒ code.

The decision variables
Each decision variable is a binary variable xα΅’β±Ό which represents whether the employee i comes back to the office on dayΒ j.

The objective function
The objective function is composed of different terms. Notice the weight assigned to each of these can be customized within the code so that terms can be excluded from the optimization process.

  • Consecutive days. For an employee might be easier to come back on consecutive weekdays, so whenever this occurs the objective function is increased.
  • Same team. Members of the same team prefer to come back on the same days, so whenever this occurs the objective function is increased.
  • Target presence. Every employee should come back a minimum number of days, encouraging some equity in the returns to the office. So, whenever an employee does not reach a provided mean presence across the planning period, a penalty is added to the objective function.
  • Single returns. Returns to the office should be encouraged, so whenever there is a presence in the office of any employee on any day the objective function is increased.

The constraints
We have two types of constraints:

  • Maximum and minimum number of employees. There is a maximum and a minimum number of employees who can return to the office per day. The optimization algorithm prevents finding solutions that exceed theseΒ values.
  • Preference days. The employees are allowed to choose what days they can and can not come back. The optimization algorithm finds solutions that agree with these preferences.

Modeling

To solve the optimization problem we need to express each element of the constraints and of the objective function in terms of the decision variables.

Since we are using binary variables, we are very flexible on what we can express. Assume we are trying to express the term consecutive days, which aims to promote the returns of employees on consecutive days.

Recall that each decision variable xα΅’β±Ό represents whether employee i comes to the office on day j. Now, let us focus on a single employee, and consider the related sequence x₁, xβ‚‚,Β .., xβ±Ό, …, xβ‚™ of decision variables, where n is the number of days in the planningΒ period.

If we considered n = 2 (i.e. we are planning for 2 days), then we would like to find a function 𝑓 of x₁, xβ‚‚ such that it is zero when x₁ = 0 or xβ‚‚ = 1 and one when x₁ = 1 and xβ‚‚ =Β 1:

In so doing, when the employee comes to the office both on day 1 and day 2 (i.e. when x₁ =1 and xβ‚‚= 1) the consecutive-days term is 1 and the objective function is increased by 1. Instead, when this is not true, the term is 0 and the objective function is not increased.

Such a function 𝑓 can be easily expressed as:

Now, assume n = 3 (i.e. planning for 3 days). Similarly, we would like to find a function 𝑓 of x₁, xβ‚‚, x₃ such that it is 2 when x₁ = 1, xβ‚‚ = 1 and x₃ = 1 (i.e. the employee comes back for all the three days), it is 1 when x₁ = 1 and xβ‚‚ = 1 or xβ‚‚ = 1 and x₃ = 1 (i.e. the employee comes back on the first day and on the second day or on the second day and on the third day), and it is 0 otherwise:

Such a function is an extension of the previous case, and can be expressed as:

You can see the pattern. In general, for n days, the consecutive-days term can be expressed as:

Linearization

There is one side note. You might have noticed that the derived term is not a linear term. When added to the objective function, it causes this to be non-linear, and in turn, this gives rise to some issues in finding the optimal solution. In fact, linear problems are guaranteed to mathematically find a unique and optimal solution. Also, almost all (free) solvers work just in the case of linear optimizations.

However, we can use an interesting strategy to make the terms linear, in the case of binary product decision variables. Specifically, for each binary product, we introduce a new binary variable z = xα΅’ * xβ±Ό (where in this case xα΅’ and xβ±Ό are two binary variables), and a set of constraints on z, which are givenΒ by:

The variable z behaves as the binary product. When xα΅’ = 0 or xβ±Ό = 0, z needs to be smaller than 0 and so it has to be zero. When xα΅’ = 1 or xβ±Ό = 1, z needs to be greater than 1 and so it has to be one. Hence, we can lead back to the linearΒ case.

Finally, notice that a similar process has to be repeated for each term of the objective function and of the constraints, in order to be able to specify the whole optimization problem.

Results

To run the code and get the results, we focused on a particular initial configuration, but it can be fully customized to adapt to your needs. In this scenario, we are going to assume the following setting:

  • The number of employees is 13 (named as Italian foodsΒ πŸ™‚Β )
  • There are 20 days (corresponding to 4 weeks, i.e. 1 month) toΒ plan
  • 4 minimum employees are allowed to return to the office on the same day. 6 maximum employees are allowed to return to the office on the sameΒ day.
  • 8 days during the planning period (i.e. 2 days per week) is the target presence that every employee should reach orΒ exceed.
  • There are 4 employee sub-teams, defined as follows:
    – Employees number 1,2 3
    – Employees number 4,5,6
    – Employees number 8, 9, 10
    – Employees number 11, 12
    Note that one employee might be part of more sub-teams.

Finally, the employee preferences are reported below. Cells in light green represent the days when employees can not come back to the office and have to be avoided in the optimization solution. Cells in dark green represent the days when employees can come back to theΒ office.

Employee preferences on n=20 days (image produced by theΒ author)

Now, it is time to run our Python notebook and get theΒ results:

Optimized solution (image produced by theΒ author)

As you can see, the algorithm made tremendous work! The clusters formed by employees of the same sub-teams are clear in the plot, and employees do tend to come to the office on consecutive days. Also, notice that the number of employees on each day does not exceed the prescribed limits, and every employee comes back at least 8 days during the plannedΒ period!

Wow! LovingΒ math!

Conclusions

In this article, we described a tool that allows identifying the best planning for teams returning to the office or in smart working. It is built using a mathematical algorithm taking into account different constraints and factors at the same time. We set up an initial configuration and showed the benefits of using such an algorithm.

Notice that there is a number of improvements that can be made to the algorithm, which ultimately depend on personal requirements and needs. For example, we might want that the presence of employees or teams would be more uniform across the planned period, or that some employees are not encouraged in returning on consecutive days.

Nevertheless, the use of such a tool can be extremely powerful in saving time and resources to managers needing to plan returns to offices or smart-working days for theirΒ teams.

Hope you enjoyed the post, please feel free to comment and give a thumbs up!
StayΒ gold!


Manager, use this to plan the smart working days for your team! was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

Join thousands of data leaders on the AI newsletter. It’s free, we don’t spam, and we never share your email address. Keep up to date with the latest work in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming aΒ sponsor.

Published via Towards AI

Feedback ↓