bpo.problems module¶
Classes:
|
A specific |
A specific |
|
A specific |
|
|
Abstract class that all problems must implement. |
A specific |
|
|
A task. |
- class bpo.problems.ImbalancedProblem(spread=1.0)[source]¶
Bases:
bpo.problems.ProblemA specific
Problemwith 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.
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.
Returns an element of
Problem.task_typesthat is the first to execute in a case.Attributes:
- data_sample(task)[source]¶
Randomly samples data for the task.
- Parameters
task – the
Taskfor 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.resourcesof the problem.task – a
Taskthat 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_typesthat is the first to execute in a case.
- task_types = ['T']¶
- class bpo.problems.MMcProblem[source]¶
Bases:
bpo.problems.ProblemA specific
Problemthat 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 methodProblem.waiting_time_analytical()to compute the waiting time analytically for comparison.Methods:
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.
Returns an element of
Problem.task_typesthat is the first to execute in a case.Attributes:
- 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.resourcesof the problem.task – a
Taskthat 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_typesthat is the first to execute in a case.
- task_types = ['T']¶
- class bpo.problems.MinedProblem[source]¶
Bases:
bpo.problems.ProblemA specific
Problemthat represents process that is mined from a business process event log, usingminers.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.
Randomly samples the interarrival time of cases.
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.
Returns an element of
Problem.task_typesthat is the first to execute in a case.Attributes:
The next task type distribution per task type.
The resource pool per task type.
The interarrival time distribution.
The data 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
Taskthat completed.- Returns
a list of tasks
- data_sample(task)[source]¶
Randomly samples data for the task.
- Parameters
task – the
Taskfor 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
Taskof 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.resourcesof the problem.task – a
Taskthat 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_typesthat is the first to execute in a case.
- task_types = []¶
- class bpo.problems.Problem[source]¶
Bases:
abc.ABCAbstract 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
Taskthat 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.
Randomly samples the interarrival time of cases.
is_event(task_type)Returns True if the task type is actually an event.
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.
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.
Returns an element of
Problem.task_typesthat is the first to execute in a case.save(filename)Saves the problem to file.
Attributes:
A list of weights, in the same order as the list of resources.
A list of identifiers (typically names) of resources.
A schedule that represents how many resources are available at a particular point in simulation time.
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
Taskthat completed.- Returns
a list of tasks
- data_sample(task)[source]¶
Randomly samples data for the task.
- Parameters
task – the
Taskfor 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
Taskof 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.resourcesof the problem.task – a
Taskthat 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_typesthat 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.ProblemA specific
Problemwith 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.
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.
Returns an element of
Problem.task_typesthat is the first to execute in a case.Attributes:
- data_sample(task)[source]¶
Randomly samples data for the task.
- Parameters
task – the
Taskfor 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
Taskof 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.resourcesof the problem.task – a
Taskthat 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_typesthat is the first to execute in a case.
- task_types = ['T1', 'T2']¶
- class bpo.problems.Task(task_id, case_id, task_type)[source]¶
Bases:
objectA 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:
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.