Scheduling problem

The SchedulingProblem class is the container for all modeling objects, such as tasks, resources and constraints.

Time slots as integers

A SchedulingProblem instance holds a time interval: the lower bound of this interval (the initial time) is always 0, the upper bound (the final time) can be set by passing the horizon attribute to the __init__() method:

my_problem = SchedulingProblem('MySchedulingProblem', horizon=20)

The interval’s duration is subdivided into discrete units called periods, each with a fixed duration of 1. If \(horizon\) is set to a value, then the number of periods is equal to \(horizon\), and the number of points within the interval \([0;horizon]\) is \(horizon+1\).



ProcessScheduler handles variables using integer values.

A period represents the finest granularity level for defining the timeline, task durations, and the schedule itself. This timeline is dimensionless, allowing you to map a period to your desired duration, be it in seconds, minutes, hours, or any other unit. For instance:

  • If you aim to schedule tasks within a single day, say from 8 am to 6 pm (office hours), resulting in a 10-hour time interval, and you plan to schedule tasks in 1-hour intervals, then the horizon value should be set to 10 to achieve the desired number of periods:

\[horizon = \frac{18-8}{1}=10\]
  • If your task scheduling occurs in the morning, from 8 am to 12 pm, resulting in a 4-hour time interval, and you intend to schedule tasks in 1-minute intervals, then the horizon value must be 240:

\[horizon = \frac{12-8}{1/60}=240\]


The horizon attribute is optional. If it’s not explicitly provided during the __init__() method, the solver will determine an appropriate horizon value that complies with the defined constraints. In cases where the scheduling problem aims to optimize the horizon, such as achieving a specific makespan objective, manual setting of the horizon is not necessary.

Mapping integers to datetime objects

To enhance the readability of Gantt charts and make schedules more intuitive, ProcessScheduler allows you to represent time intervals in real dates and times rather than integers. You can explicitly set time values in seconds, minutes, hours, and more. The smallest time duration for a task, represented by the integer 1, can be mapped to a Python timedelta object. Similarly, any point in time can be mapped to a Python datetime object.

Creating Python timedelta objects can be achieved as follows:

from datetime import timedelta
delta = timedelta(days=50,

For Python datetime objects, you can create them like this:

from datetime import datetime
now =

These attribute values can be provided to the SchedulingProblem initialization method as follows:

problem = ps.SchedulingProblem('DateTimeBase',

Once the solver has completed its work and generated a solution, you can export the end times, start times, and durations to the Gantt chart or any other output format.


For more detailed information on Python’s datetime package documentation and its capabilities, please refer to the datetime Python package documentation. This documentation provides comprehensive guidance on working with date and time objects in Python.