# builders.domain.scheduling.conditional_tasks

Domain specification

Domain

# WithConditionalTasks

A domain must inherit this class if some tasks only need be executed under some conditions and that the condition model can be expressed with Distribution objects.

# add_to_current_conditions WithConditionalTasks

add_to_current_conditions(
  self,
task: int,
state
)

Samples completion conditions for a given task and add these conditions to the list of conditions in the given state. This function should be called when a task complete.

# get_all_condition_items WithConditionalTasks

get_all_condition_items(
  self
) -> Enum

Return an Enum with all the elements that can be used to define a condition.

Example: return ConditionElementsExample(Enum): OK = 0 NC_PART_1_OPERATION_1 = 1 NC_PART_1_OPERATION_2 = 2 NC_PART_2_OPERATION_1 = 3 NC_PART_2_OPERATION_2 = 4 HARDWARE_ISSUE_MACHINE_A = 5 HARDWARE_ISSUE_MACHINE_B = 6

# get_all_unconditional_tasks WithConditionalTasks

get_all_unconditional_tasks(
  self
) -> set[int]

Returns the set of all task ids for which there are no conditions. These tasks are to be considered at the start of a project (i.e. in the initial state).

# get_available_tasks WithConditionalTasks

get_available_tasks(
  self,
state
) -> set[int]

Returns the set of all task ids that can be considered under the conditions defined in the given state. Note that the set will contains all ids for all tasks in the domain that meet the conditions, that is tasks that are remaining, or that have been completed, paused or started / resumed.

# get_task_existence_conditions WithConditionalTasks

get_task_existence_conditions(
  self
) -> dict[int, list[int]]

Return a dictionary where the key is a task id and the value a list of conditions to be respected (True) for the task to be part of the schedule. If a task has no entry in the dictionary, there is no conditions for that task.

Example: return { 20: [get_all_condition_items().NC_PART_1_OPERATION_1], 21: [get_all_condition_items().HARDWARE_ISSUE_MACHINE_A] 22: [get_all_condition_items().NC_PART_1_OPERATION_1, get_all_condition_items().NC_PART_1_OPERATION_2] }e

# get_task_on_completion_added_conditions WithConditionalTasks

get_task_on_completion_added_conditions(
  self
) -> dict[int, list[Distribution]]

Return a dict of list. The key of the dict is the task id and each list is composed of a list of tuples. Each tuple contains the probability (first item in tuple) that the conditionElement (second item in tuple) is True. The probabilities in the inner list should sum up to 1. The dictionary should only contains the keys of tasks that can create conditions.

Example: return { 12: [ DiscreteDistribution([(ConditionElementsExample.NC_PART_1_OPERATION_1, 0.1), (ConditionElementsExample.OK, 0.9)]), DiscreteDistribution([(ConditionElementsExample.HARDWARE_ISSUE_MACHINE_A, 0.05), ('paper', 0.1), (ConditionElementsExample.OK, 0.95)]) ] }

# sample_completion_conditions WithConditionalTasks

sample_completion_conditions(
  self,
task: int
) -> list[int]

Samples the condition distributions associated with the given task and return a list of sampled conditions.

# _add_to_current_conditions WithConditionalTasks

_add_to_current_conditions(
  self,
task: int,
state
)

Samples completion conditions for a given task and add these conditions to the list of conditions in the given state. This function should be called when a task complete.

# _get_all_unconditional_tasks WithConditionalTasks

_get_all_unconditional_tasks(
  self
) -> set[int]

Returns the set of all task ids for which there are no conditions. These tasks are to be considered at the start of a project (i.e. in the initial state).

# _get_available_tasks WithConditionalTasks

_get_available_tasks(
  self,
state
) -> set[int]

Returns the set of all task ids that can be considered under the conditions defined in the given state. Note that the set will contains all ids for all tasks in the domain that meet the conditions, that is tasks that are remaining, or that have been completed, paused or started / resumed.

# _get_task_existence_conditions WithConditionalTasks

_get_task_existence_conditions(
  self
) -> dict[int, list[int]]

Return a dictionary where the key is a task id and the value a list of conditions to be respected (True) for the task to be part of the schedule. If a task has no entry in the dictionary, there is no conditions for that task.

Example: return { 20: [get_all_condition_items().NC_PART_1_OPERATION_1], 21: [get_all_condition_items().HARDWARE_ISSUE_MACHINE_A] 22: [get_all_condition_items().NC_PART_1_OPERATION_1, get_all_condition_items().NC_PART_1_OPERATION_2] }e

# _sample_completion_conditions WithConditionalTasks

_sample_completion_conditions(
  self,
task: int
) -> list[int]

Samples the condition distributions associated with the given task and return a list of sampled conditions.

# WithoutConditionalTasks

A domain must inherit this class if all tasks need be executed without conditions.

# add_to_current_conditions WithConditionalTasks

add_to_current_conditions(
  self,
task: int,
state
)

Samples completion conditions for a given task and add these conditions to the list of conditions in the given state. This function should be called when a task complete.

# get_all_condition_items WithConditionalTasks

get_all_condition_items(
  self
) -> Enum

Return an Enum with all the elements that can be used to define a condition.

Example: return ConditionElementsExample(Enum): OK = 0 NC_PART_1_OPERATION_1 = 1 NC_PART_1_OPERATION_2 = 2 NC_PART_2_OPERATION_1 = 3 NC_PART_2_OPERATION_2 = 4 HARDWARE_ISSUE_MACHINE_A = 5 HARDWARE_ISSUE_MACHINE_B = 6

# get_all_unconditional_tasks WithConditionalTasks

get_all_unconditional_tasks(
  self
) -> set[int]

Returns the set of all task ids for which there are no conditions. These tasks are to be considered at the start of a project (i.e. in the initial state).

# get_available_tasks WithConditionalTasks

get_available_tasks(
  self,
state
) -> set[int]

Returns the set of all task ids that can be considered under the conditions defined in the given state. Note that the set will contains all ids for all tasks in the domain that meet the conditions, that is tasks that are remaining, or that have been completed, paused or started / resumed.

# get_task_existence_conditions WithConditionalTasks

get_task_existence_conditions(
  self
) -> dict[int, list[int]]

Return a dictionary where the key is a task id and the value a list of conditions to be respected (True) for the task to be part of the schedule. If a task has no entry in the dictionary, there is no conditions for that task.

Example: return { 20: [get_all_condition_items().NC_PART_1_OPERATION_1], 21: [get_all_condition_items().HARDWARE_ISSUE_MACHINE_A] 22: [get_all_condition_items().NC_PART_1_OPERATION_1, get_all_condition_items().NC_PART_1_OPERATION_2] }e

# get_task_on_completion_added_conditions WithConditionalTasks

get_task_on_completion_added_conditions(
  self
) -> dict[int, list[Distribution]]

Return a dict of list. The key of the dict is the task id and each list is composed of a list of tuples. Each tuple contains the probability (first item in tuple) that the conditionElement (second item in tuple) is True. The probabilities in the inner list should sum up to 1. The dictionary should only contains the keys of tasks that can create conditions.

Example: return { 12: [ DiscreteDistribution([(ConditionElementsExample.NC_PART_1_OPERATION_1, 0.1), (ConditionElementsExample.OK, 0.9)]), DiscreteDistribution([(ConditionElementsExample.HARDWARE_ISSUE_MACHINE_A, 0.05), ('paper', 0.1), (ConditionElementsExample.OK, 0.95)]) ] }

# sample_completion_conditions WithConditionalTasks

sample_completion_conditions(
  self,
task: int
) -> list[int]

Samples the condition distributions associated with the given task and return a list of sampled conditions.

# _add_to_current_conditions WithConditionalTasks

_add_to_current_conditions(
  self,
task: int,
state
)

Samples completion conditions for a given task and add these conditions to the list of conditions in the given state. This function should be called when a task complete.

# _get_all_unconditional_tasks WithConditionalTasks

_get_all_unconditional_tasks(
  self
) -> set[int]

Returns the set of all task ids for which there are no conditions. These tasks are to be considered at the start of a project (i.e. in the initial state).

# _get_available_tasks WithConditionalTasks

_get_available_tasks(
  self,
state
) -> set[int]

Returns the set of all task ids that can be considered under the conditions defined in the given state. Note that the set will contains all ids for all tasks in the domain that meet the conditions, that is tasks that are remaining, or that have been completed, paused or started / resumed.

# _get_task_existence_conditions WithConditionalTasks

_get_task_existence_conditions(
  self
) -> dict[int, list[int]]

Return a dictionary where the key is a task id and the value a list of conditions to be respected (True) for the task to be part of the schedule. If a task has no entry in the dictionary, there is no conditions for that task.

Example: return { 20: [get_all_condition_items().NC_PART_1_OPERATION_1], 21: [get_all_condition_items().HARDWARE_ISSUE_MACHINE_A] 22: [get_all_condition_items().NC_PART_1_OPERATION_1, get_all_condition_items().NC_PART_1_OPERATION_2] }e

# _sample_completion_conditions WithConditionalTasks

_sample_completion_conditions(
  self,
task: int
) -> list[int]

Samples the condition distributions associated with the given task and return a list of sampled conditions.