bpo.problems module

Classes:

ImbalancedProblem([spread])

A specific Problem with two resources that have different processing times for the same task.

MMcProblem()

A specific Problem that represents an M/M/c queue, i.e.: it has one task type, multiple resources and exponential arrival and processing times.

MinedProblem()

A specific Problem that represents process that is mined from a business process event log, using miners.mine_problem().

Problem()

Abstract class that all problems must implement.

SequentialProblem()

A specific Problem with two resources and two task types.

Task(task_id, case_id, task_type)

A task.

class bpo.problems.ImbalancedProblem(spread=1.0)[source]

Bases: bpo.problems.Problem

A specific Problem with two resources that have different processing times for the same task. The difference between the performance of the resources is indicated by the 0 <= spread < 2.0, where a higher spread means that the performance of the resources is more different. The resource that performs better on the task is indicated by the data[‘optimal_resource’] of that task.

Methods:

data_sample(task)

Randomly samples data for the task.

interarrival_time_sample()

Randomly samples the interarrival time of cases.

processing_time_sample(resource, task)

Randomly samples the duration of the simulation time it will take the resource to perform the task.

sample_initial_task_type()

Returns an element of Problem.task_types that is the first to execute in a case.

Attributes:

resources

task_types

data_sample(task)[source]

Randomly samples data for the task.

Parameters

task – the Task for which the data will be sampled.

Returns

a dictionary with additional data that can be stored in Task.data.

interarrival_time_sample()[source]

Randomly samples the interarrival time of cases.

Returns

a float representing a duration in simulation time.

processing_time_sample(resource, task)[source]

Randomly samples the duration of the simulation time it will take the resource to perform the task.

Parameters
  • resource – one of the Problem.resources of the problem.

  • task – a Task that should come from the problem.

Returns

a float representing a duration in simulation time.

resources = ['R1', 'R2']
sample_initial_task_type()[source]

Returns an element of Problem.task_types that is the first to execute in a case.

task_types = ['T']
class bpo.problems.MMcProblem[source]

Bases: bpo.problems.Problem

A specific Problem that represents an M/M/c queue, i.e.: it has one task type, multiple resources and exponential arrival and processing times. This problem can be simulated, but it also has a method Problem.waiting_time_analytical() to compute the waiting time analytically for comparison.

Methods:

interarrival_time_sample()

Randomly samples the interarrival time of cases.

processing_time_sample(resource, task)

Randomly samples the duration of the simulation time it will take the resource to perform the task.

sample_initial_task_type()

Returns an element of Problem.task_types that is the first to execute in a case.

waiting_time_analytical()

Attributes:

resources

task_types

interarrival_time_sample()[source]

Randomly samples the interarrival time of cases.

Returns

a float representing a duration in simulation time.

processing_time_sample(resource, task)[source]

Randomly samples the duration of the simulation time it will take the resource to perform the task.

Parameters
  • resource – one of the Problem.resources of the problem.

  • task – a Task that should come from the problem.

Returns

a float representing a duration in simulation time.

resources = ['R1', 'R2']
sample_initial_task_type()[source]

Returns an element of Problem.task_types that is the first to execute in a case.

task_types = ['T']
waiting_time_analytical()[source]
class bpo.problems.MinedProblem[source]

Bases: bpo.problems.Problem

A specific Problem that represents process that is mined from a business process event log, using miners.mine_problem(). The problem generates customer cases that have the same properties as the cases in the event log from which it originate in terms of: arrival rate, next-task probabilities, and performance of resources on task types in terms of processing time distribution.

Methods:

complete_task(task)

Adds the specified task to the case history.

data_sample(task)

Randomly samples data for the task.

interarrival_time_sample()

Randomly samples the interarrival time of cases.

next_case()

Returns the next case to arrive.

next_task_types_sample(task)

Randomly samples the task types that will be performed for the case of the specified task, when that task completes.

processing_time_sample(resource, task)

Randomly samples the duration of the simulation time it will take the resource to perform the task.

resource_pool(task_type)

Returns for each task_type the subset of resources that can perform tasks of that type.

restart()

Restarts this problem instance, i.e.: sets the next case to arrive to the first case.

sample_initial_task_type()

Returns an element of Problem.task_types that is the first to execute in a case.

Attributes:

initial_task_distribution

The next task type distribution per task type.

interarrival_time

The resource pool per task type.

next_task_distribution

The interarrival time distribution.

resource_pools

The data types.

resources

task_types

complete_task(task)[source]

Adds the specified task to the case history. Returns the list of next tasks that are enabled after the task with the specified task_id in the specified case_id is completed.

Parameters

task – the Task that completed.

Returns

a list of tasks

data_sample(task)[source]

Randomly samples data for the task.

Parameters

task – the Task for which the data will be sampled.

Returns

a dictionary with additional data that can be stored in Task.data.

initial_task_distribution

The next task type distribution per task type. Maps a task type to a list of probability/ task type tuples, where each pair is a next task type and the probability that that task type is the next task type. If a tuple is probability/ None, this represents the probability that there is no next task and the case completes.

interarrival_time

The resource pool per task type. Maps each task type to the list of resources that can execute tasks of that type.

interarrival_time_sample()[source]

Randomly samples the interarrival time of cases.

Returns

a float representing a duration in simulation time.

next_case()[source]

Returns the next case to arrive.

Returns

(arrival_time, initial_task), where arrival_time is the simulation time at which the case arrives, and initial_task is the first task to perform for the case.

next_task_distribution

The interarrival time distribution.

next_task_types_sample(task)[source]

Randomly samples the task types that will be performed for the case of the specified task, when that task completes.

Parameters

task – a Task of this problem.

Returns

a sublist of Problem.task_types.

processing_time_sample(resource, task)[source]

Randomly samples the duration of the simulation time it will take the resource to perform the task.

Parameters
  • resource – one of the Problem.resources of the problem.

  • task – a Task that should come from the problem.

Returns

a float representing a duration in simulation time.

resource_pool(task_type)[source]

Returns for each task_type the subset of resources that can perform tasks of that type.

Parameters

task_type – one of Problem.task_types

Returns

a list with elements of Problem.resources

resource_pools

The data types. Is a mapping of data type names to distributions from which the data will be sampled. In this class data is associated with a case. For each task in a case the same data will be returned.

resources = []
restart()[source]

Restarts this problem instance, i.e.: sets the next case to arrive to the first case.

sample_initial_task_type()[source]

Returns an element of Problem.task_types that is the first to execute in a case.

task_types = []
class bpo.problems.Problem[source]

Bases: abc.ABC

Abstract class that all problems must implement. An object of the class is an instance of the problem, which is equivalent to a business process case. An object has a next_case_id, which is the next case to arrive for the problem. case_id are sequential, starting at 0 for the first case to arrive, 1 for the next case to arrive, etc. An object also has a dictionary that maps case_id -> (arrival_time, initial_task), where arrival time is the simulation time at which the case will arrive and initial_task is the first Task that will be executed for the case.

A problem must define:

  • the resources that exist

  • the interarrival time distribution of cases

  • the types of tasks that can be performed for cases

  • rules for what the next task will be when a case first arrives or when a task is completed

  • the processing time distribution for each task

  • the data that is generated by a task

Methods:

complete_task(task)

Adds the specified task to the case history.

data_sample(task)

Randomly samples data for the task.

from_file(filename)

Instantiates the problem by reading it from file.

interarrival_time_sample()

Randomly samples the interarrival time of cases.

is_event(task_type)

Returns True if the task type is actually an event.

next_case()

Returns the next case to arrive.

next_task_types_sample(task)

Randomly samples the task types that will be performed for the case of the specified task, when that task completes.

nr_cases_generated()

Returns the number of cases that has been generated.

processing_time_sample(resource, task)

Randomly samples the duration of the simulation time it will take the resource to perform the task.

resource_pool(task_type)

Returns for each task_type the subset of resources that can perform tasks of that type.

restart()

Restarts this problem instance, i.e.: sets the next case to arrive to the first case.

sample_initial_task_type()

Returns an element of Problem.task_types that is the first to execute in a case.

save(filename)

Saves the problem to file.

Attributes:

resource_weights

A list of weights, in the same order as the list of resources.

resources

A list of identifiers (typically names) of resources.

schedule

A schedule that represents how many resources are available at a particular point in simulation time.

task_types

A list of identifiers (typically labels) of task types.

complete_task(task)[source]

Adds the specified task to the case history. Returns the list of next tasks that are enabled after the task with the specified task_id in the specified case_id is completed.

Parameters

task – the Task that completed.

Returns

a list of tasks

data_sample(task)[source]

Randomly samples data for the task.

Parameters

task – the Task for which the data will be sampled.

Returns

a dictionary with additional data that can be stored in Task.data.

classmethod from_file(filename)[source]

Instantiates the problem by reading it from file.

Parameters

filename – the name of the file from which to read the problem.

Returns

an instance of the Problem.

abstract interarrival_time_sample()[source]

Randomly samples the interarrival time of cases.

Returns

a float representing a duration in simulation time.

is_event(task_type)[source]

Returns True if the task type is actually an event. Events start immediately when they are activated. They do not require a resource.

Parameters

task_type – one of Problem.task_types

Returns

True or False, depending on whether the specified task type is an event or not

next_case()[source]

Returns the next case to arrive.

Returns

(arrival_time, initial_task), where arrival_time is the simulation time at which the case arrives, and initial_task is the first task to perform for the case.

next_task_types_sample(task)[source]

Randomly samples the task types that will be performed for the case of the specified task, when that task completes.

Parameters

task – a Task of this problem.

Returns

a sublist of Problem.task_types.

nr_cases_generated()[source]

Returns the number of cases that has been generated.

Returns

an integer number of cases that has been generated for the problem so far.

abstract processing_time_sample(resource, task)[source]

Randomly samples the duration of the simulation time it will take the resource to perform the task.

Parameters
  • resource – one of the Problem.resources of the problem.

  • task – a Task that should come from the problem.

Returns

a float representing a duration in simulation time.

resource_pool(task_type)[source]

Returns for each task_type the subset of resources that can perform tasks of that type.

Parameters

task_type – one of Problem.task_types

Returns

a list with elements of Problem.resources

property resource_weights

A list of weights, in the same order as the list of resources. resource_weights[i] represents how much resources[i] works compared to the other resources. A resource with a weight 2 is expected to work twice as much as a resource with weight 1. Using resource_weights, we can randomly select a resource using random.choices(resources, resource_weights)[0], to get a resource with the likelihood that that resource is indeed supposed to work. By default all resources have equal weight, i.e. are equally available.

abstract property resources

A list of identifiers (typically names) of resources.

restart()[source]

Restarts this problem instance, i.e.: sets the next case to arrive to the first case.

abstract sample_initial_task_type()[source]

Returns an element of Problem.task_types that is the first to execute in a case.

save(filename)[source]

Saves the problem to file.

Parameters

filename – the name of the file to save the problem to.

property schedule

A schedule that represents how many resources are available at a particular point in simulation time. The schedule is a list, where schedule[t % len(schedule)] represents the number of resources that are available during time interval t in simulation time. For example, if simulation time is measured in hours, schedule[3 % len(schedule)] represents the number of resources available during the third hour. By default all resources are always available.

abstract property task_types

A list of identifiers (typically labels) of task types.

class bpo.problems.SequentialProblem[source]

Bases: bpo.problems.Problem

A specific Problem with two resources and two task types. Each case starts with a task of type T1. After that is completed a task of type T2 must be processed. The resources have different processing times for the tasks. The resource that performs better on a task is indicated by the data[‘optimal_resource’] of that task. Resource R1 performs better on task T1 and resource R2 on task T2.

Methods:

data_sample(task)

Randomly samples data for the task.

interarrival_time_sample()

Randomly samples the interarrival time of cases.

next_task_types_sample(task)

Randomly samples the task types that will be performed for the case of the specified task, when that task completes.

processing_time_sample(resource, task)

Randomly samples the duration of the simulation time it will take the resource to perform the task.

sample_initial_task_type()

Returns an element of Problem.task_types that is the first to execute in a case.

Attributes:

resources

task_types

data_sample(task)[source]

Randomly samples data for the task.

Parameters

task – the Task for which the data will be sampled.

Returns

a dictionary with additional data that can be stored in Task.data.

interarrival_time_sample()[source]

Randomly samples the interarrival time of cases.

Returns

a float representing a duration in simulation time.

next_task_types_sample(task)[source]

Randomly samples the task types that will be performed for the case of the specified task, when that task completes.

Parameters

task – a Task of this problem.

Returns

a sublist of Problem.task_types.

processing_time_sample(resource, task)[source]

Randomly samples the duration of the simulation time it will take the resource to perform the task.

Parameters
  • resource – one of the Problem.resources of the problem.

  • task – a Task that should come from the problem.

Returns

a float representing a duration in simulation time.

resources = ['R1', 'R2']
sample_initial_task_type()[source]

Returns an element of Problem.task_types that is the first to execute in a case.

task_types = ['T1', 'T2']
class bpo.problems.Task(task_id, case_id, task_type)[source]

Bases: object

A task.

Parameters
  • task_id – the identifier of the task.

  • case_id – the identifier of the case to which the task belongs.

  • task_type – the type of the task, i.e. one of the Problem.task_types.

Attributes:

task_type

a dictionary with additional data that is the result of the task, each item is a label -> value pair.

task_type

a dictionary with additional data that is the result of the task, each item is a label -> value pair.