Intelligent behovsprognostisering och personalschemaläggning med hjälp av Data Science

Intelligent forecasting and personnel scheduling with the help of Data Science

Many industries need reliable and efficient personnel scheduling services. For a personnel-intensive operation, staffing is the core of the operation. Optimal scheduling can therefore offer considerable productivity gains – partly thanks to more efficient resource utilisation, and partly owing to satisfied employees.

Having said that, personnel scheduling is an extremely complex process and when it is done using an Excel spreadsheet, there is a considerable risk that the result will be late evenings and costly errors. It is therefore hardly surprising that many companies have moved away from obsolete manual solutions. In a 2019 report Gartner predicted that 40 % of all large organisations with hourly paid staff and fluctuating staffing needs will have automated their scheduling decisions by 2025.

The scheduling process is divided into two main steps: (1) forecast staffing needs, and (2) optimise the personnel schedule. For forecasting of staffing needs, the most suitable methods are machine learning, while methods such as decision optimisation are suitable for optimisation of the personnel schedule. In the section below I will use two examples to explain how the scheduling process can be carried out.

Forecasting of staffing needs with the help of machine learning 

For an amusement park like Liseberg in Gothenburg, the ability to produce accurate forecasts of visitor numbers is absolutely vital. This kind of forecast is the basis for both staffing and purchasing. Advectas has helped Liseberg migrate from manual forecasts based on experience and gut feeling, to automated forecasts based on machine learning.

The number of visitors at Liseberg depends to a large extent on external factors such as the weather, other events in the city, the season, holidays, day of the week and a whole lot more. Internal factors such as historical visitor trends, opening hours, guest artistes, park themes and more also all play their part. The data sources used for the forecast were thus both external and internal. External sources that are used include the Swedish Meteorological and Hydrological Institute’s weather data, Last FM’s data on popular artistes, and the official City of Gothenburg events calendar. Information such as Liseberg’s own visitor history, opening hours and the park’s own events calendar are examples of internal data sources.

All these factors, both internal and external, were weighted together when the number of visitors per day was forecasted with the help of open-source tool Facebook Prophet, implemented in Python. The number of visitors was distributed on an hourly basis with the help of a complementary neural network. The result was a more accurate forecast, which could be updated as often as necessary (in this case every night), and a forecast that was no longer dependent on the experiences and limited time resources of a few individuals.

Optimal personnel scheduling with the help of decision optimisation
Now, let’s assume that we have a forecast of staffing needs that we can use when we want to optimise our personnel scheduling. This could be as in the case of the Liseberg example above, where we use machine learning to forecast a fluctuating staffing need – but we may also consider a fixed staffing level already from the outset. This is for instance often the case in the health and social care services, where different health care establishments and residential care facilities have a fixed number of beds. Advectas helped the social services department at Trelleborg municipality to optimise its personnel scheduling operations.  

The big challenge with personnel scheduling for an operation like that of Trelleborg municipality is to create a schedule that stays within specific constraints. The Swedish Working Hours Act is an example of such a constraint. The Working Hours Act stipulates for instance that the daily rest period between two shifts must be at least 11 hours and that the uninterrupted weekly rest period must be at least 36 hours. Other aspects that come into play include union agreements, such as the total number of hours worked per week or the maximum number of consecutive days worked without a free day in between.

Moreover, it is necessary to take account of what is known as objectives, that is to say those properties that you want the optimal schedule to have. This may for example relate to uniform allocation of shift types between the employees, or uniform distribution of any under-capacity or over-capacity throughout the schedule period.

Having so many constraints and objectives means they quickly become too many to manage properly. For the schedule planner who only has an Excel spreadsheet to use, it is impossible to see all the feasible schedule combinations. In order to gain an overview of the various choices it is not unusual to use a rolling basic schedule and to then make small adjustments to this basic schedule. This locks the planner to the basic schedule, and it may be difficult to get out of this rut. With decision optimisation, there is no risk of being locked to inefficient solutions; instead the scheduling problem is tackled in a scientific way.

For Trelleborg municipality we structured the optimisation solution with the help of the CPLEX optimisation engine, implemented in Python via the PuLP and DoCPLEX APIs. In recent years it has become increasingly popular to build optimisation solutions in what is known as a general purpose language such as Python, primarily thanks to the flexibility it offers compared to other Data Science solutions. When we talk about personnel scheduling, it is very clear why – you can forecast staffing needs and have your personnel schedule in one and the same solution.

Don’t hesitate to get in touch if there is anything you want to ask! Send an email to and we can discuss the issue further. 


Tilda Lundgren
My name is Tilda Lundgren and I work as a Data Scientist at Advectas. I have a master's degree in industrial engineering and management, specializing within applied mathematics and optimization. Here at Advectas, I'm working in various Data Science projects, often specializing in optimization or other types of prescriptive analysis. I'm a Gothenburg native, now living in Hammarbyhöjden just south of Stockholm.

All posts by Tilda Lundgren