pDESy.model package
Submodules
pDESy.model.base_component module
base_component.
- class pDESy.model.base_component.BaseComponent(name=None, ID=None, child_component_id_set=None, targeted_task_id_set=None, space_size=None, parent_product_id=None, state=BaseComponentState.NONE, state_record_list=None, placed_workplace_id=None, placed_workplace_id_record_list=None, error_tolerance=None, error=None)[source]
Bases:
object
BaseComponent.
BaseComponent class for expressing target product. This class can be used as template.
- add_child_component(child_component: BaseComponent) None [source]
Add child component to child_component_id_set.
- Parameters:
child_component (BaseComponent) – BaseComponent which is child of this component.
- add_targeted_task(targeted_task: BaseTask) None [source]
Add targeted task to targeted_task_list.
- Parameters:
targeted_task (BaseTask) – Targeted task of this component.
- append_child_component(child_component: BaseComponent) None [source]
Append child component to child_component_id_set.
Deprecated since version Use: add_child_component instead.
- Parameters:
child_component (BaseComponent) – BaseComponent which is child of this component.
- append_targeted_task(targeted_task: BaseTask) None [source]
Append targeted task to targeted_task_list.
Deprecated since version Use: add_targeted_task instead.
- Parameters:
targeted_task (BaseTask) – Targeted task of this component.
- create_task(name=None, ID=None, default_work_amount=None, work_amount_progress_of_unit_step_time=None, input_task_id_dependency_set=None, allocated_team_id_set=None, allocated_workplace_id_set=None, parent_workflow_id=None, workplace_priority_rule=WorkplacePriorityRuleMode.FSS, worker_priority_rule=ResourcePriorityRuleMode.MW, facility_priority_rule=ResourcePriorityRuleMode.SSP, need_facility=False, default_progress=None, due_time=None, auto_task=False, fixing_allocating_worker_id_set=None, fixing_allocating_facility_id_set=None, est=0.0, eft=0.0, lst=-1.0, lft=-1.0, remaining_work_amount=None, remaining_work_amount_record_list=None, state=BaseTaskState.NONE, state_record_list=None, allocated_worker_facility_id_tuple_set=None, allocated_worker_facility_id_tuple_set_record_list=None, additional_work_amount=None, additional_task_flag=False, actual_work_amount=None)[source]
Create a new BaseTask instance and add it to the targeted tasks.
- Parameters:
name (str, optional) – Name of this task. Defaults to None -> “New Task”.
ID (str, optional) – ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
default_work_amount (float, optional) – Default workamount of this BaseTask. Defaults to None -> 10.0.
work_amount_progress_of_unit_step_time (float, optional) – Baseline of work amount progress of unit step time. Default to None -> 1.0.
input_task_id_dependency_set (set(tuple(str, BaseTaskDependency)), optional) – Set of input BaseTask id and type of dependency(FS, SS, SF, F/F) tuple. Defaults to None -> set().
allocated_team_id_set (set[str], optional) – Set of allocated BaseTeam id. Defaults to None -> set().
allocated_workplace_id_set (set[str], optional) – Set of allocated BaseWorkplace id. Defaults to None -> set().
parent_workflow_id (str, optional) – Parent workflow id. Defaults to None.
workplace_priority_rule (WorkplacePriorityRuleMode, optional) – Workplace priority rule for simulation. Defaults to WorkplacePriorityRuleMode.FSS.
worker_priority_rule (ResourcePriorityRule, optional) – Worker priority rule for simulation. Defaults to ResourcePriorityRule.SSP.
facility_priority_rule (ResourcePriorityRule, optional) – Task priority rule for simulation. Defaults to TaskPriorityRule.TSLACK.
need_facility (bool, optional) – Whether one facility is needed for performing this task or not. Defaults to False.
default_progress (float, optional) – Progress before starting simulation (0.0 ~ 1.0). Defaults to None -> 0.0.
due_time (int, optional) – Defaults to None -> int(-1).
auto_task (bool, optional) – If True, this task is performed automatically even if there are no allocated workers. Defaults to False.
fixing_allocating_worker_id_set (set[str], optional) – Allocating worker ID set for fixing allocation in simulation. Defaults to None.
fixing_allocating_facility_id_set (set[str], optional) – Allocating facility ID set for fixing allocation in simulation. Defaults to None.
est (float, optional) – Earliest start time of CPM. This will be updated step by step. Defaults to 0.0.
eft (float, optional) – Earliest finish time of CPM. This will be updated step by step. Defaults to 0.0.
lst (float, optional) – Latest start time of CPM. This will be updated step by step. Defaults to -1.0.
lft (float, optional) – Latest finish time of CPM. This will be updated step by step. Defaults to -1.0.
remaining_work_amount (float, optional) – Remaining workamount in simulation. Defaults to None -> default_work_amount * (1.0 - default_progress).
remaining_work_amount_record_list (List[float], optional) – Record of remaining workamount in simulation. Defaults to None -> [].
state (BaseTaskState, optional) – State of this task in simulation. Defaults to BaseTaskState.NONE.
state_record_list (List[BaseTaskState], optional) – Record list of state. Defaults to None -> [].
allocated_worker_facility_id_tuple_set (set(tuple(str, str)), optional) – State of allocating worker and facility id tuple set in simulation. Defaults to None -> set().
allocated_worker_facility_id_tuple_set_record_list (List[set[tuple(str, str)]], optional) – State of allocating worker and facility id tuple set in simulation. Defaults to None -> [].
additional_work_amount (float, optional) – Advanced parameter. Defaults to None.
additional_task_flag (bool, optional) – Advanced variable. Defaults to False.
actual_work_amount (float, optional) – Advanced variable. Default to None -> default_work_amount*(1.0-default_progress)
- Returns:
Created BaseTask instance.
- Return type:
- export_dict_json_data()[source]
Export the information of this component to JSON data.
- Returns:
JSON format data.
- Return type:
dict
- extend_child_component_list(child_component_list: list[BaseComponent]) None [source]
Extend the list of child components.
Deprecated since version Use: update_child_component_set instead.
- Parameters:
child_component_list (List[BaseComponent]) – List of BaseComponents which are children of this component.
- extend_targeted_task_list(targeted_task_list: list[BaseTask]) None [source]
Extend the list of targeted tasks to targeted_task_list.
Deprecated since version Use: update_targeted_task_set instead.
- Parameters:
targeted_task_list (List[BaseTask]) – List of targeted tasks.
- get_gantt_mermaid_data(range_time: tuple[int, int] = (0, 9223372036854775807), view_ready: bool = False, detailed_info: bool = False, id_name_dict: dict[str, str] = None) list[str] [source]
Get gantt mermaid data of this component.
- Parameters:
range_time (tuple[int, int], optional) – Range time of gantt chart. Defaults to (0, sys.maxsize).
view_ready (bool, optional) – If True, ready tasks are included in gantt chart. Defaults to False.
detailed_info (bool, optional) – If True, detailed information is included in gantt chart. Defaults to False.
id_name_dict (dict[str, str], optional) – Dictionary of ID and name for detailed information. Defaults to None.
- Returns:
List of lines for gantt mermaid diagram.
- Return type:
list[str]
- get_mermaid_diagram(shape: str = 'odd', subgraph: bool = False, subgraph_name: str = 'Component', subgraph_direction: str = 'LR') list[str] [source]
Get mermaid diagram of this component.
- Parameters:
shape (str, optional) – Shape of mermaid diagram. Defaults to “odd”.
subgraph (bool, optional) – Subgraph or not. Defaults to False.
subgraph_name (str, optional) – Subgraph name. Defaults to “Component”.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- Returns:
List of lines for mermaid diagram.
- Return type:
list[str]
- get_time_list_for_gantt_chart(finish_margin: float = 1.0) tuple[list[tuple[int, int]], list[tuple[int, int]]] [source]
Get ready/working time_list for drawing Gantt chart.
- Parameters:
finish_margin (float, optional) – Margin of finish time in Gantt chart. Defaults to 1.0.
- Returns:
- (ready_time_list, working_time_list)
ready_time_list (List[tuple(int, int)]): ready_time_list including start_time, length
working_time_list (List[tuple(int, int)]): working_time_list including start_time, length
- Return type:
tuple
- initialize(state_info: bool = True, log_info: bool = True) None [source]
Initialize the following changeable basic variables of BaseComponent.
- If state_info is True, the following attributes are initialized:
state
placed_workplace
error
- If log_info is True, the following attributes are initialized:
state_record_list
placed_workplace_id_record_list
- Parameters:
state_info (bool, optional) – State information are initialized or not. Defaults to True.
log_info (bool, optional) – Log information are initialized or not. Defaults to True.
- insert_absence_time_list(absence_time_list: list[int]) None [source]
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- print_all_log_in_chronological_order(backward: bool = False) None [source]
Print all log in chronological order.
- Parameters:
backward (bool, optional) – If True, print in reverse order. Defaults to False.
- print_log(target_step_time: int) None [source]
Print log in target_step_time.
- Prints:
ID
name
state_record_list[target_step_time]
placed_workplace_id_record_list[target_step_time]
- Parameters:
target_step_time (int) – Target step time of printing log.
- print_mermaid_diagram(orientations: str = 'LR', shape: str = 'odd', subgraph: bool = False, subgraph_name: str = 'Component', subgraph_direction: str = 'LR') None [source]
Print mermaid diagram of this component.
- Parameters:
orientations (str, optional) – Orientation of mermaid diagram. See: https://mermaid.js.org/syntax/flowchart.html#direction. Defaults to “LR”.
shape (str, optional) – Shape of mermaid diagram. Defaults to “odd”.
subgraph (bool, optional) – Subgraph or not. Defaults to False.
subgraph_name (str, optional) – Subgraph name. Defaults to “Component”.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- record_placed_workplace_id() None [source]
Record workplace id in this time to placed_workplace_id_record_list.
- record_state(working: bool = True) None [source]
Record current state in state_record_list.
- Parameters:
working (bool, optional) – If False and state is WORKING, record READY instead. Defaults to True.
- remove_absence_time_list(absence_time_list: list[int]) None [source]
Remove record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- update_child_component_set(child_component_set: set[BaseComponent]) None [source]
Update the set of child components.
- Parameters:
child_component_set (set[BaseComponent]) – Set of BaseComponents which are children of this component.
- update_error_value(no_error_prob: float, error_increment: float, seed=None) None [source]
Update error value randomly.
If no_error_prob >=1.0, error = error + error_increment.
- Parameters:
no_error_prob (float) – Probability of no error (0.0~1.0).
error_increment (float) – Increment of error variables if error has occurred.
seed (int, optional) – Seed of creating random.rand(). Defaults to None.
Note
This method is developed for customized simulation.
- class pDESy.model.base_component.BaseComponentState(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
BaseComponentState.
- NONE
No state.
- Type:
int
- READY
Ready state.
- Type:
int
- WORKING
Working state.
- Type:
int
- FINISHED
Finished state.
- Type:
int
- REMOVED
Removed state.
- Type:
int
- FINISHED = -1
- NONE = 0
- READY = 1
- REMOVED = -2
- WORKING = 2
pDESy.model.base_facility module
pDESy.model.base_priority_rule module
base_priority_rule.
This module defines enums and functions for sorting workplaces, workers, facilities, and tasks according to various priority rules.
- class pDESy.model.base_priority_rule.ResourcePriorityRuleMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Enum for resource (worker/facility) priority rule modes.
- MW
A worker whose main workplace is equal to target has high priority.
- Type:
int
- SSP
A worker/facility with lower skill point sum has high priority.
- Type:
int
- VC
A worker/facility with lower cost has high priority.
- Type:
int
- HSV
A worker/facility with higher target skill point has high priority.
- Type:
int
- HSV = 2
- MW = -1
- SSP = 0
- VC = 1
- class pDESy.model.base_priority_rule.TaskPriorityRuleMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Enum for task priority rule modes.
- TSLACK
Task with lower slack time has high priority.
- Type:
int
- EST
Earliest Start Time.
- Type:
int
- SPT
Shortest Processing Time.
- Type:
int
- LPT
Longest Processing Time.
- Type:
int
- FIFO
First in First Out.
- Type:
int
- LRPT
Longest Remaining Process Time.
- Type:
int
- SRPT
Shortest Remaining Process Time.
- Type:
int
- EST = 1
- FIFO = 4
- LPT = 3
- LRPT = 5
- SPT = 2
- SRPT = 6
- TSLACK = 0
- class pDESy.model.base_priority_rule.WorkplacePriorityRuleMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Enum for workplace priority rule modes.
- FSS
Free Space Size.
- Type:
int
- SSP
Sum Skill Points of targeted task.
- Type:
int
- FSS = 0
- SSP = 1
- pDESy.model.base_priority_rule.sort_facility_list(facility_list: list, priority_rule_mode=ResourcePriorityRuleMode.SSP, **kwargs)[source]
Sort facility_list as priority_rule_mode.
- Parameters:
facility_list (List[BaseFacility]) – Target facility list of sorting.
priority_rule_mode (ResourcePriorityRuleMode, optional) – Mode of priority rule for sorting. Defaults to ResourcePriorityRuleMode.SSP.
**kwargs – Other information of each rule.
- Returns:
facility_list after sorted.
- Return type:
List[BaseFacility]
- pDESy.model.base_priority_rule.sort_task_list(task_list: list, priority_rule_mode=TaskPriorityRuleMode.TSLACK)[source]
Sort task_list as priority_rule_mode.
- Parameters:
task_list (List[BaseTask]) – Target task list of sorting.
priority_rule_mode (TaskPriorityRuleMode, optional) – Mode of priority rule for sorting. Defaults to TaskPriorityRuleMode.TSLACK.
- Returns:
task_list after sorted.
- Return type:
List[BaseTask]
- pDESy.model.base_priority_rule.sort_worker_list(worker_list: list, priority_rule_mode=ResourcePriorityRuleMode.SSP, **kwargs)[source]
Sort worker_list as priority_rule_mode.
- Parameters:
worker_list (List[BaseWorker]) – Target worker list of sorting.
priority_rule_mode (ResourcePriorityRuleMode, optional) – Mode of priority rule for sorting. Defaults to ResourcePriorityRuleMode.SSP.
**kwargs – Other information of each rule.
- Returns:
worker_list after sorted.
- Return type:
List[BaseWorker]
- pDESy.model.base_priority_rule.sort_workplace_list(workplace_list: list, priority_rule_mode=WorkplacePriorityRuleMode.FSS, **kwargs)[source]
Sort workplace_list as priority_rule_mode.
- Parameters:
workplace_list (List[BaseWorkplace]) – Target workplace list of sorting.
priority_rule_mode (WorkplacePriorityRuleMode, optional) – Mode of priority rule for sorting. Defaults to WorkplacePriorityRuleMode.FSS.
**kwargs – Other information of each rule.
- Returns:
workplace_list after sorted.
- Return type:
List[BaseWorkplace]
pDESy.model.base_product module
base_product.
- class pDESy.model.base_product.BaseProduct(name: str = None, ID: str = None, component_set: set[BaseComponent] = None)[source]
Bases:
object
BaseProduct.
BaseProduct class for expressing target product in a project. BaseProduct consists of multiple BaseComponents. This class will be used as a template.
- Parameters:
name (str, optional) – Name of this product. Defaults to None -> “Product”.
ID (str, optional) – ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
component_set (set[BaseComponent], optional) – Set of BaseComponents.
- add_component(component: BaseComponent)[source]
Add target component to this workflow.
- Parameters:
component (BaseComponent) – Target component.
- append_component(component: BaseComponent)[source]
Append target component to this workflow.
Deprecated since version Use: add_component instead.
- Parameters:
component (BaseComponent) – Target component.
- create_component(name: str = None, ID: str = None, child_component_id_set: set[str] = None, targeted_task_id_set: set[str] = None, space_size: float = None, state: BaseComponentState = BaseComponentState.NONE, state_record_list: list[BaseComponentState] = None, placed_workplace_id: str = None, placed_workplace_id_record_list: list[str] = None, error_tolerance: float = None, error: float = None)[source]
Create BaseComponent instance and add it to this product.
- Parameters:
name (str, optional) – Name of this component. Defaults to None -> “New Component”.
ID (str, optional) – ID will be defined automatically.
child_component_id_set (set[str], optional) – Child BaseComponents id set. Defaults to None -> set().
targeted_task_id_set (set[str], optional) – Targeted tasks id set. Defaults to None -> set().
space_size (float, optional) – Space size related to base_workplace’s max_space_size. Default to None -> 1.0.
state (BaseComponentState, optional) – State of this task in simulation. Defaults to BaseComponentState.NONE.
state_record_list (List[BaseComponentState], optional) – Record list of state. Defaults to None -> [].
placed_workplace_id (str, optional) – A workplace which this component is placed in simulation. Defaults to None.
placed_workplace_id_record_list (List[str], optional) – Record of placed workplace ID in simulation. Defaults to None -> [].
error_tolerance (float, optional) – Advanced parameter.
error (float, optional) – Advanced variables.
- Returns:
The created component.
- Return type:
- create_data_for_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, target_id_order_list: list[str] = None, finish_margin: float = 1.0, print_product_name: bool = True, view_ready: bool = False)[source]
Create data for gantt plotly from component_set.
- Parameters:
init_datetime (datetime.datetime) – Start datetime of project.
unit_timedelta (datetime.timedelta) – Unit time of simulation.
target_id_order_list (list[str], optional) – Target ID order list. Defaults to None.
finish_margin (float, optional) – Margin of finish time in Gantt chart. Defaults to 1.0.
print_product_name (bool, optional) – Print product name or not. Defaults to True.
view_ready (bool, optional) – View READY time or not. Defaults to False.
- Returns:
Gantt plotly information of this BaseProduct.
- Return type:
List[dict]
- create_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, target_id_order_list: list[str] = None, title: str = 'Gantt Chart', colors: dict[str, str] = None, index_col: str = None, showgrid_x: bool = True, showgrid_y: bool = True, group_tasks: bool = True, show_colorbar: bool = True, finish_margin: float = 1.0, print_product_name: bool = True, view_ready: bool = False, save_fig_path: str = None)[source]
Create Gantt chart by plotly.
This method will be used after simulation.
- Parameters:
init_datetime (datetime.datetime) – Start datetime of project.
unit_timedelta (datetime.timedelta) – Unit time of simulation.
target_id_order_list (list[str], optional) – Target ID order list. Defaults to None.
title (str, optional) – Title of Gantt chart. Defaults to “Gantt Chart”.
colors (Dict[str, str], optional) – Color setting of plotly Gantt chart. Defaults to None -> dict(Component=”rgb(246, 37, 105)”, READY=”rgb(107, 127, 135)”).
index_col (str, optional) – index_col of plotly Gantt chart. Defaults to None -> “State”.
showgrid_x (bool, optional) – showgrid_x of plotly Gantt chart. Defaults to True.
showgrid_y (bool, optional) – showgrid_y of plotly Gantt chart. Defaults to True.
group_tasks (bool, optional) – group_tasks of plotly Gantt chart. Defaults to True.
show_colorbar (bool, optional) – show_colorbar of plotly Gantt chart. Defaults to True.
finish_margin (float, optional) – Margin of finish time in Gantt chart. Defaults to 1.0.
print_product_name (bool, optional) – Print product name or not. Defaults to True.
view_ready (bool, optional) – View READY time or not. Defaults to False.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure for a gantt chart.
- Return type:
figure
- create_simple_gantt(target_id_order_list: list[str] = None, finish_margin: float = 1.0, print_product_name: bool = True, view_ready: bool = True, component_color: str = '#FF6600', ready_color: str = '#C0C0C0', figsize: tuple[float, float] = None, dpi: float = 100.0, save_fig_path: str = None)[source]
Create Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
target_id_order_list (list[str], optional) – Target ID order list. Defaults to None.
finish_margin (float, optional) – Margin of finish time in Gantt chart. Defaults to 1.0.
view_ready (bool, optional) – View READY time or not. Defaults to True.
print_product_name (bool, optional) – Print product name or not. Defaults to True.
component_color (str, optional) – Component color setting information. Defaults to “#FF6600”.
ready_color (str, optional) – Ready color setting information. Defaults to “#C0C0C0”.
figsize ((float, float), optional) – Width, height in inches. Default to None -> [6.4, 4.8].
dpi (float, optional) – The resolution of the figure in dots-per-inch. Default to 100.0.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure in plt.subplots(). gnt: Axes in plt.subplots().
- Return type:
fig
- draw_networkx(g: DiGraph = None, pos: dict = None, arrows: bool = True, component_node_color: str = '#FF6600', figsize: tuple[float, float] = None, dpi: float = 100.0, save_fig_path: str = None, **kwargs)[source]
Draw networkx.
- Parameters:
g (networkx.Digraph, optional) – The information of networkx graph. Defaults to None -> self.get_networkx_graph().
pos (networkx.layout, optional) – Layout of networkx. Defaults to None -> networkx.spring_layout(g).
arrows (bool, optional) – Digraph or Graph(no arrows). Defaults to True.
component_node_color (str, optional) – Node color setting information. Defaults to “#FF6600”.
figsize ((float, float), optional) – Width, height in inches. Default to None -> [6.4, 4.8].
dpi (float, optional) – The resolution of the figure in dots-per-inch. Default to 100.0.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
**kwargs – Other networkx settings.
- Returns:
Figure for a network.
- Return type:
figure
- draw_plotly_network(g: DiGraph = None, pos: dict = None, title: str = 'Product', node_size: int = 20, component_node_color: str = '#FF6600', save_fig_path: str = None)[source]
Draw plotly network.
- Parameters:
g (networkx.Digraph, optional) – The information of networkx graph. Defaults to None -> self.get_networkx_graph().
pos (networkx.layout, optional) – Layout of networkx. Defaults to None -> networkx.spring_layout(g).
title (str, optional) – Figure title of this network. Defaults to “Product”.
node_size (int, optional) – Node size setting information. Defaults to 20.
component_node_color (str, optional) – Node color setting information. Defaults to “#FF6600”.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure for a network.
- Return type:
figure
- export_dict_json_data()[source]
Export the information of this product to JSON data.
- Returns:
JSON format data.
- Return type:
dict
- extend_component_list(component_set: set[BaseComponent])[source]
Extend target component_set to this product.
Deprecated since version Use: update_component_set instead.
- Parameters:
component_set (set[BaseComponent]) – Target component set.
- extract_finished_component_set(target_time_list: list[int])[source]
Extract FINISHED component set from simulation result.
- Parameters:
target_time_list (List[int]) – Target time list. If you want to extract finished component from time 2 to time 4, you must set [2, 3, 4] to this argument.
- Returns:
List of BaseComponent.
- Return type:
List[BaseComponent]
- extract_none_component_set(target_time_list: list[int])[source]
Extract NONE component set from simulation result.
- Parameters:
target_time_list (List[int]) – Target time list. If you want to extract none component from time 2 to time 4, you must set [2, 3, 4] to this argument.
- Returns:
List of BaseComponent.
- Return type:
List[BaseComponent]
- extract_ready_component_set(target_time_list: list[int])[source]
Extract READY component set from simulation result.
- Parameters:
target_time_list (List[int]) – Target time list. If you want to extract ready component from time 2 to time 4, you must set [2, 3, 4] to this argument.
- Returns:
List of BaseComponent.
- Return type:
List[BaseComponent]
- extract_working_component_set(target_time_list: list[int])[source]
Extract WORKING component set from simulation result.
- Parameters:
target_time_list (List[int]) – Target time list. If you want to extract working component from time 2 to time 4, you must set [2, 3, 4] to this argument.
- Returns:
List of BaseComponent.
- Return type:
List[BaseComponent]
- get_gantt_mermaid(target_id_order_list: list[str] = None, section: bool = True, range_time: tuple[int, int] = (0, 9223372036854775807), view_ready: bool = False, detailed_info: bool = False, id_name_dict: dict[str, str] = None)[source]
Get mermaid diagram of Gantt chart.
- Parameters:
target_id_order_list (list[str], optional) – Target ID order list. Defaults to None.
section (bool, optional) – Section or not. Defaults to True.
range_time (tuple[int, int], optional) – Range of Gantt chart. Defaults to (0, sys.maxsize).
view_ready (bool, optional) – If True, ready tasks are included in gantt chart. Defaults to False.
detailed_info (bool, optional) – If True, detailed information is included in gantt chart. Defaults to False.
id_name_dict (dict[str, str], optional) – Dictionary of ID and name for detailed information. Defaults to None.
- Returns:
List of lines for mermaid diagram.
- Return type:
list[str]
- get_mermaid_diagram(shape_component: str = 'odd', link_type_str: str = '-->', subgraph: bool = True, subgraph_direction: str = 'LR')[source]
Get mermaid diagram of this product.
- Parameters:
shape_component (str, optional) – Shape of mermaid diagram. Defaults to “odd”.
link_type_str (str, optional) – Link type of mermaid diagram. Defaults to “–>”.
subgraph (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- Returns:
List of lines for mermaid diagram.
- Return type:
list[str]
- get_networkx_graph()[source]
Get the information of networkx graph.
- Returns:
Directed graph of the product.
- Return type:
networkx.DiGraph
- get_node_and_edge_trace_for_plotly_network(g: DiGraph = None, pos: dict = None, node_size: int = 20, component_node_color: str = '#FF6600')[source]
Get nodes and edges information of plotly network.
- Parameters:
g (networkx.Digraph, optional) – The information of networkx graph. Defaults to None -> self.get_networkx_graph().
pos (networkx.layout, optional) – Layout of networkx. Defaults to None -> networkx.spring_layout(g).
node_size (int, optional) – Node size setting information. Defaults to 20.
component_node_color (str, optional) – Node color setting information. Defaults to “#FF6600”.
- Returns:
Node information of plotly network. edge_trace: Edge information of plotly network.
- Return type:
node_trace
- get_target_component_mermaid_diagram(target_component_set: set[BaseComponent], shape_component: str = 'odd', link_type_str: str = '-->', subgraph: bool = True, subgraph_direction: str = 'LR')[source]
Get mermaid diagram of target component.
- Parameters:
target_component_set (set[BaseComponent]) – Target component set.
shape_component (str, optional) – Shape of mermaid diagram. Defaults to “odd”.
link_type_str (str, optional) – Link type of mermaid diagram. Defaults to “–>”.
subgraph (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- Returns:
List of lines for mermaid diagram.
- Return type:
list[str]
- initialize(state_info: bool = True, log_info: bool = True)[source]
Initialize the changeable variables of BaseProduct.
BaseComponent in component_set are also initialized by this function.
- Parameters:
state_info (bool, optional) – Whether to initialize state information. Defaults to True.
log_info (bool, optional) – Whether to initialize log information. Defaults to True.
- insert_absence_time_list(absence_time_list: list[int])[source]
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- plot_simple_gantt(target_id_order_list: list[str] = None, finish_margin: float = 1.0, print_product_name: bool = True, view_ready: bool = True, component_color: str = '#FF6600', ready_color: str = '#C0C0C0', figsize: tuple[float, float] = None, dpi: float = 100.0, save_fig_path: str = None)[source]
Plot Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
target_id_order_list (list[str], optional) – Target ID order list. Defaults to None.
finish_margin (float, optional) – Margin of finish time in Gantt chart. Defaults to 1.0.
print_product_name (bool, optional) – Print product name or not. Defaults to True.
view_ready (bool, optional) – View READY time or not. Defaults to True.
component_color (str, optional) – Component color setting information. Defaults to “#FF6600”.
ready_color (str, optional) – Ready color setting information. Defaults to “#C0C0C0”.
figsize ((float, float), optional) – Width, height in inches. Default to None -> [6.4, 4.8].
dpi (float, optional) – The resolution of the figure in dots-per-inch. Default to 100.0.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure in plt.subplots().
- Return type:
fig
- print_all_log_in_chronological_order(backward: bool = False)[source]
Print all log in chronological order.
- Parameters:
backward (bool, optional) – If True, print logs in reverse order. Defaults to False.
- print_gantt_mermaid(target_id_order_list: list[str] = None, date_format: str = 'X', axis_format: str = '%s', section: bool = True, range_time: tuple[int, int] = (0, 9223372036854775807), view_ready: bool = False, detailed_info: bool = False, id_name_dict: dict[str, str] = None)[source]
Print mermaid diagram of Gantt chart.
- Parameters:
target_id_order_list (list[str], optional) – Target ID order list. Defaults to None.
date_format (str, optional) – Date format of mermaid diagram. Defaults to “X”.
axis_format (str, optional) – Axis format of mermaid diagram. Defaults to “%s”.
section (bool, optional) – Section or not. Defaults to True.
range_time (tuple[int, int], optional) – Range of Gantt chart. Defaults to (0, sys.maxsize).
view_ready (bool, optional) – If True, ready tasks are included in gantt chart. Defaults to False.
detailed_info (bool, optional) – If True, detailed information is included in gantt chart. Defaults to False.
id_name_dict (dict[str, str], optional) – Dictionary of ID and name for detailed information. Defaults to None.
- print_log(target_step_time: int)[source]
Print log in target_step_time.
- Parameters:
target_step_time (int) – Target step time of printing log.
- print_mermaid_diagram(orientations: str = 'LR', shape_component: str = 'odd', link_type_str: str = '-->', subgraph: bool = True, subgraph_direction: str = 'LR')[source]
Print mermaid diagram of this product.
- Parameters:
orientations (str, optional) – Orientation of mermaid diagram. See: https://mermaid.js.org/syntax/flowchart.html#direction. Defaults to “LR”.
shape_component (str, optional) – Shape of mermaid diagram. Defaults to “odd”.
link_type_str (str, optional) – Link type of mermaid diagram. Defaults to “–>”.
subgraph (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- print_target_component_mermaid_diagram(target_component_set: set[BaseComponent], orientations: str = 'LR', shape_component: str = 'odd', link_type_str: str = '-->', subgraph: bool = True, subgraph_direction: str = 'LR')[source]
Print mermaid diagram of target component.
- Parameters:
target_component_set (set[BaseComponent]) – Target component set.
orientations (str, optional) – Orientation of mermaid diagram. See: https://mermaid.js.org/syntax/flowchart.html#direction. Defaults to “LR”.
shape_component (str, optional) – Shape of mermaid diagram. Defaults to “odd”.
link_type_str (str, optional) – Link type of mermaid diagram. Defaults to “–>”.
subgraph (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- read_json_data(json_data: dict)[source]
Read the JSON data for creating BaseProduct instance.
- Parameters:
json_data (dict) – JSON data.
- record(working=True)[source]
Record placed workplace id in this time.
- Parameters:
working (bool, optional) – Whether to record as working. Defaults to True.
- remove_absence_time_list(absence_time_list: list[int])[source]
Remove record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- update_component_set(component_set: set[BaseComponent])[source]
Update target component_set to this product.
- Parameters:
component_set (set[BaseComponent]) – Target component set.
pDESy.model.base_project module
pDESy.model.base_subproject_task module
BaseSubProjectTask module.
This module provides the BaseSubProjectTask class for expressing target sub projects.
- Classes:
BaseSubProjectTask: A class representing a sub project task, inheriting from BaseTask.
- class pDESy.model.base_subproject_task.BaseSubProjectTask(file_path: str = None, unit_timedelta: timedelta = None, read_json_file: bool = False, remove_absence_time_list: bool = False, name: str = None, ID: str = None, default_work_amount: float = None, work_amount_progress_of_unit_step_time: float = None, input_task_id_dependency_set: set = None, allocated_team_id_set: set = None, allocated_workplace_id_set: set = None, parent_workflow_id: str = None, workplace_priority_rule: WorkplacePriorityRuleMode = WorkplacePriorityRuleMode.FSS, worker_priority_rule: ResourcePriorityRuleMode = ResourcePriorityRuleMode.SSP, facility_priority_rule: ResourcePriorityRuleMode = ResourcePriorityRuleMode.SSP, need_facility: bool = False, target_component_id: str = None, default_progress: float = None, due_time: float = None, auto_task: bool = True, fixing_allocating_worker_id_set: set = None, fixing_allocating_facility_id_set: set = None, est: float = 0.0, eft: float = 0.0, lst: float = -1.0, lft: float = -1.0, remaining_work_amount: float = None, remaining_work_amount_record_list: list = None, state: BaseTaskState = BaseTaskState.NONE, state_record_list: list = None, allocated_worker_facility_id_tuple_set: set = None, allocated_worker_facility_id_tuple_set_record_list: list = None, additional_work_amount: float = None, additional_task_flag: bool = False, actual_work_amount: float = None)[source]
Bases:
BaseTask
A class representing a sub project task.
This class is used for expressing a target sub project within the simulation.
- export_dict_json_data()[source]
Exports the information of this task to a JSON-serializable dictionary.
- Returns:
JSON format data.
- Return type:
dict
- set_all_attributes_from_json(file_path: str = None, remove_absence_time_list: bool = True)[source]
Reads attributes from a JSON file created by BaseProject.write_simple_json().
- Parameters:
file_path (str, optional) – JSON file path for reading sub project data. Defaults to None, which uses self.file_path.
remove_absence_time_list (bool, optional) – Whether to remove absence_time_list information from the JSON file. Defaults to True.
- Returns:
Duration step time of the target project. datetime.timedelta: Unit time of the target project.
- Return type:
int
pDESy.model.base_task module
base_task.
- class pDESy.model.base_task.BaseTask(name: str = None, ID: str = None, default_work_amount: float = 10.0, work_amount_progress_of_unit_step_time: float = 1.0, input_task_id_dependency_set: set[tuple[str, BaseTaskDependency]] = None, allocated_team_id_set: set[str] = None, allocated_workplace_id_set: set[str] = None, parent_workflow_id: str = None, workplace_priority_rule: WorkplacePriorityRuleMode = WorkplacePriorityRuleMode.FSS, worker_priority_rule: ResourcePriorityRuleMode = ResourcePriorityRuleMode.MW, facility_priority_rule: ResourcePriorityRuleMode = ResourcePriorityRuleMode.SSP, need_facility: bool = False, target_component_id: str = None, default_progress: float = 0.0, due_time: int = -1, auto_task: bool = False, fixing_allocating_worker_id_set: set[str] = None, fixing_allocating_facility_id_set: set[str] = None, est: float = 0.0, eft: float = 0.0, lst: float = -1.0, lft: float = -1.0, remaining_work_amount: float = None, remaining_work_amount_record_list: list[float] = None, state: BaseTaskState = BaseTaskState.NONE, state_record_list: list[BaseTaskState] = None, allocated_worker_facility_id_tuple_set: set[tuple[str, str]] = None, allocated_worker_facility_id_tuple_set_record_list: list[set[tuple[str, str]]] = None, additional_work_amount: float = None, additional_task_flag: bool = False, actual_work_amount: float = None)[source]
Bases:
object
BaseTask.
BaseTask class for expressing target workflow. This class will be used as a template.
- Parameters:
name (str, optional) – Name of this task. Defaults to None -> “New Task”.
ID (str, optional) – ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
default_work_amount (float, optional) – Default workamount of this BaseTask. Defaults to None -> 10.0.
work_amount_progress_of_unit_step_time (float, optional) – Baseline of work amount progress of unit step time. Default to None -> 1.0.
input_task_id_dependency_set (set(tuple(str, BaseTaskDependency)), optional) – Set of input BaseTask id and type of dependency(FS, SS, SF, F/F) tuple. Defaults to None -> set().
allocated_team_id_set (set[str], optional) – Set of allocated BaseTeam id. Defaults to None -> set().
allocated_workplace_id_set (set[str], optional) – Set of allocated BaseWorkplace id. Defaults to None -> set().
parent_workflow_id (str, optional) – Parent workflow id. Defaults to None.
workplace_priority_rule (WorkplacePriorityRuleMode, optional) – Workplace priority rule for simulation. Defaults to WorkplacePriorityRuleMode.FSS.
worker_priority_rule (ResourcePriorityRule, optional) – Worker priority rule for simulation. Defaults to ResourcePriorityRule.SSP.
facility_priority_rule (ResourcePriorityRule, optional) – Task priority rule for simulation. Defaults to TaskPriorityRule.TSLACK.
need_facility (bool, optional) – Whether one facility is needed for performing this task or not. Defaults to False.
target_component_id (str, optional) – Target BaseComponent id. Defaults to None.
default_progress (float, optional) – Progress before starting simulation (0.0 ~ 1.0). Defaults to None -> 0.0.
due_time (int, optional) – Due time. Defaults to None -> int(-1).
auto_task (bool, optional) – If True, this task is performed automatically even if there are no allocated workers. Defaults to False.
fixing_allocating_worker_id_set (set[str], optional) – Allocating worker ID set for fixing allocation in simulation. Defaults to None.
fixing_allocating_facility_id_set (set[str], optional) – Allocating facility ID set for fixing allocation in simulation. Defaults to None.
est (float, optional) – Earliest start time of CPM. This will be updated step by step. Defaults to 0.0.
eft (float, optional) – Earliest finish time of CPM. This will be updated step by step. Defaults to 0.0.
lst (float, optional) – Latest start time of CPM. This will be updated step by step. Defaults to -1.0.
lft (float, optional) – Latest finish time of CPM. This will be updated step by step. Defaults to -1.0.
remaining_work_amount (float, optional) – Remaining workamount in simulation. Defaults to None -> default_work_amount * (1.0 - default_progress).
remaining_work_amount_record_list (List[float], optional) – Record of remaining workamount in simulation. Defaults to None -> [].
state (BaseTaskState, optional) – State of this task in simulation. Defaults to BaseTaskState.NONE.
state_record_list (List[BaseTaskState], optional) – Record list of state. Defaults to None -> [].
allocated_worker_facility_id_tuple_set (set(tuple(str, str)), optional) – State of allocating worker and facility id tuple set in simulation. Defaults to None -> set().
allocated_worker_facility_id_tuple_set_record_list (List[set[tuple(str, str)]], optional) – State of allocating worker and facility id tuple set in simulation. Defaults to None -> [].
additional_work_amount (float, optional) – Advanced parameter. Defaults to None.
additional_task_flag (bool, optional) – Advanced variable. Defaults to False.
actual_work_amount (float, optional) – Advanced variable. Default to None -> default_work_amount*(1.0-default_progress)
- add_input_task(input_task: BaseTask, task_dependency_mode: BaseTaskDependency = BaseTaskDependency.FS)[source]
Add input task to input_task_id_dependency_set.
- Parameters:
input_task (BaseTask) – Input BaseTask.
task_dependency_mode (BaseTaskDependency, optional) – Task Dependency mode between input_task to this task. Default to BaseTaskDependency.FS.
- add_target_component(target_component: BaseComponent)[source]
Add target component to this task.
- Parameters:
target_component (BaseComponent) – Target BaseComponent.
- append_input_task_dependency(input_task: BaseTask, task_dependency_mode: BaseTaskDependency = BaseTaskDependency.FS)[source]
Append input task to input_task_id_dependency_set.
Deprecated since version Use: add_input_task instead.
- Parameters:
input_task (BaseTask) – Input BaseTask.
task_dependency_mode (BaseTaskDependency, optional) – Task Dependency mode between input_task to this task. Default to BaseTaskDependency.FS.
- export_dict_json_data()[source]
Export the information of this task to JSON data.
- Returns:
JSON format data.
- Return type:
dict
- extend_input_task_list(input_task_list: list[BaseTask], input_task_dependency_mode: BaseTaskDependency = BaseTaskDependency.FS)[source]
Extend the set of input tasks and FS dependency to input_task_id_dependency_set.
Deprecated since version Use: update_input_task_set instead.
- Parameters:
input_task_id_dependency_set (set(tuple(str, BaseTask))) – Set of input BaseTask and type of dependency(FS, SS, SF, F/F).
- get_gantt_mermaid_data(range_time: tuple[int, int] = (0, 9223372036854775807), detailed_info: bool = False, id_name_dict: dict[str, str] = None, view_ready: bool = False)[source]
Get gantt mermaid data of this task.
- Parameters:
range_time (tuple[int, int], optional) – Range of gantt chart. Defaults to (0, sys.maxsize).
detailed_info (bool, optional) – If True, print detailed information. Defaults to False.
id_name_dict (dict[str, str], optional) – Dictionary to map ID to name. Defaults to None.
view_ready (bool, optional) – If True, include ready time in Gantt chart. Defaults to False.
- Returns:
List of lines for gantt mermaid diagram.
- Return type:
list[str]
- get_mermaid_diagram(shape: str = 'rect', print_work_amount_info: bool = True, subgraph: bool = False, subgraph_name: str = 'Task', subgraph_direction: str = 'LR')[source]
Get mermaid diagram of this task.
- Parameters:
shape (str, optional) – Shape of mermaid diagram. Defaults to “rect”.
print_work_amount_info (bool, optional) – Print work amount information or not. Defaults to True.
subgraph (bool, optional) – Subgraph or not. Defaults to False.
subgraph_name (str, optional) – Subgraph name. Defaults to “Task”.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- Returns:
List of lines for mermaid diagram.
- Return type:
list[str]
- get_state_from_record(time: int)[source]
Get the state information in time.
- Parameters:
time (int) – Target simulation time.
- Returns:
Task State information.
- Return type:
- get_time_list_for_gantt_chart(finish_margin: float = 1.0)[source]
Get ready/working time_list for drawing Gantt chart.
- Parameters:
finish_margin (float, optional) – Margin of finish time in Gantt chart. Defaults to 1.0.
- Returns:
ready_time_list including start_time, length
working_time_list including start_time, length
- Return type:
Tuple[List[tuple(int, int)], List[tuple(int, int)]]
- initialize(error_tol: float = 1e-10, state_info: bool = True, log_info: bool = True)[source]
Initialize the changeable variables of BaseTask.
- If state_info is True, the following attributes are initialized:
est
eft
lst
lft
remaining_work_amount
state
allocated_worker_facility_id_tuple_set
additional_task_flag
actual_work_amount
- If log_info is True, the following attributes are initialized:
remaining_work_amount_record_list
state_record_list
allocated_worker_facility_id_tuple_set_record_list
- Parameters:
error_tol (float, optional) – Error toleration of work amount for checking the state of this task. Defaults to 1e-10.
state_info (bool, optional) – Whether to initialize state information. Defaults to True.
log_info (bool, optional) – Whether to initialize log information. Defaults to True.
- insert_absence_time_list(absence_time_list: list[int])[source]
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- print_all_log_in_chronological_order(backward: bool = False)[source]
Print all log in chronological order.
- Parameters:
backward (bool, optional) – If True, print logs in reverse order. Defaults to False.
- print_log(target_step_time: int)[source]
Print log in target_step_time.
- Prints:
ID
name
default_work_amount
remaining_work_amount_record_list
state_record_list[target_step_time]
allocated_worker_facility_id_tuple_set_record_list[target_step_time]
- Parameters:
target_step_time (int) – Target step time of printing log.
- print_mermaid_diagram(orientations: str = 'LR', shape: str = 'rect', print_work_amount_info: bool = True, subgraph: bool = False, subgraph_name: str = 'Task', subgraph_direction: str = 'LR')[source]
Print mermaid diagram of this task.
- Parameters:
orientations (str, optional) – Orientation of mermaid diagram. Defaults to “LR”.
shape (str, optional) – Shape of mermaid diagram. Defaults to “rect”.
print_work_amount_info (bool, optional) – Print work amount information or not. Defaults to True.
subgraph (bool, optional) – Subgraph or not. Defaults to False.
subgraph_name (str, optional) – Subgraph name. Defaults to “Task”.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- remove_absence_time_list(absence_time_list: list[int])[source]
Remove record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- update_input_task_set(input_task_set: set[BaseTask], input_task_dependency_mode: BaseTaskDependency = BaseTaskDependency.FS)[source]
Update the set of input tasks and FS dependency to input_task_id_dependency_set.
- Parameters:
input_task_id_dependency_set (set(tuple(str, BaseTask))) – Set of input BaseTask and type of dependency(FS, SS, SF, F/F).
- class pDESy.model.base_task.BaseTaskDependency(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
BaseTaskDependency.
Enum for representing task dependency types.
- FS
Finish to Start.
- Type:
int
- SS
Start to Start.
- Type:
int
- FF
Finish to Finish.
- Type:
int
- SF
Start to Finish.
- Type:
int
- FF = 2
- FS = 0
- SF = 3
- SS = 1
- class pDESy.model.base_task.BaseTaskState(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
BaseTaskState.
Enum for representing the state of a task.
- NONE
No state.
- Type:
int
- READY
Ready to start.
- Type:
int
- WORKING
Currently working.
- Type:
int
- WORKING_ADDITIONALLY
Working additionally.
- Type:
int
- FINISHED
Finished.
- Type:
int
- FINISHED = -1
- NONE = 0
- READY = 1
- WORKING = 2
- WORKING_ADDITIONALLY = 3
pDESy.model.base_team module
pDESy.model.base_worker module
pDESy.model.base_workflow module
base_workflow.
- class pDESy.model.base_workflow.BaseWorkflow(name: str = None, ID: str = None, task_set: set[BaseTask] = None, critical_path_length: float = 0.0)[source]
Bases:
object
BaseWorkflow.
BaseWorkflow class for expressing workflow in a project. BaseWorkflow consists of multiple BaseTasks. This class will be used as a template.
- Parameters:
name (str, optional) – Name of this workflow. Defaults to None -> “Workflow”.
ID (str, optional) – ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
task_set (set[BaseTask], optional) – List of BaseTask in this BaseWorkflow. Default to None -> set().
critical_path_length (float, optional) – Critical path length of PERT/CPM. Defaults to 0.0.
- add_task(task: BaseTask)[source]
Add target task to this workflow.
- Parameters:
task (BaseTask) – Target task.
- append_child_task(task: BaseTask)[source]
Append target task to this workflow.
Deprecated since version Use: add_task instead.
- Parameters:
task (BaseTask) – Target task.
- create_data_for_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, target_id_order_list: list[str] = None, finish_margin: float = 1.0, print_workflow_name: bool = True, view_ready: bool = False)[source]
Create data for gantt plotly from task_set.
- Parameters:
init_datetime (datetime.datetime) – Start datetime of project.
unit_timedelta (datetime.timedelta) – Unit time of simulation.
target_id_order_list (list[str], optional) – Target ID order list. Defaults to None.
finish_margin (float, optional) – Margin of finish time in Gantt chart. Defaults to 1.0.
print_workflow_name (bool, optional) – Print workflow name or not. Defaults to True.
view_ready (bool, optional) – View READY time or not. Defaults to False.
- Returns:
Gantt plotly information of this BaseWorkflow.
- Return type:
list[dict]
- create_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, target_id_order_list: list[str] = None, title: str = 'Gantt Chart', colors: dict[str, str] = None, index_col: str = None, showgrid_x: bool = True, showgrid_y: bool = True, group_tasks: bool = True, show_colorbar: bool = True, finish_margin: float = 1.0, print_workflow_name: bool = True, view_ready: bool = False, save_fig_path: str = None)[source]
Create Gantt chart by plotly.
This method will be used after simulation.
- Parameters:
init_datetime (datetime.datetime) – Start datetime of project.
unit_timedelta (datetime.timedelta) – Unit time of simulation.
target_id_order_list (list[str], optional) – Target ID order list. Defaults to None.
title (str, optional) – Title of Gantt chart. Defaults to “Gantt Chart”.
colors (Dict[str, str], optional) – Color setting of plotly Gantt chart. Defaults to None -> dict(WORKING=”rgb(146, 237, 5)”, READY=”rgb(107, 127, 135)”).
index_col (str, optional) – index_col of plotly Gantt chart. Defaults to None -> “State”.
showgrid_x (bool, optional) – showgrid_x of plotly Gantt chart. Defaults to True.
showgrid_y (bool, optional) – showgrid_y of plotly Gantt chart. Defaults to True.
group_tasks (bool, optional) – group_tasks of plotly Gantt chart. Defaults to True.
show_colorbar (bool, optional) – show_colorbar of plotly Gantt chart. Defaults to True.
finish_margin (float, optional) – Margin of finish time in Gantt chart. Defaults to 1.0.
print_workflow_name (bool, optional) – Print workflow name or not. Defaults to True.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure for a gantt chart.
- Return type:
figure
- create_simple_gantt(target_id_order_list: list[str] = None, finish_margin: float = 1.0, print_workflow_name: bool = True, view_auto_task: bool = False, view_ready: bool = False, task_color: str = '#00EE00', auto_task_color: str = '#005500', ready_color: str = '#C0C0C0', figsize: tuple[float, float] = None, dpi: float = 100.0, save_fig_path: str = None)[source]
Create Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
target_id_order_list (list[str], optional) – Target ID order list. Defaults to None.
finish_margin (float, optional) – Margin of finish time in Gantt chart. Defaults to 1.0.
print_workflow_name (bool, optional) – Print workflow name or not. Defaults to True.
view_auto_task (bool, optional) – View auto_task or not. Defaults to False.
view_ready (bool, optional) – View READY time or not. Defaults to False.
task_color (str, optional) – Task color setting information. Defaults to “#00EE00”.
auto_task_color (str, optional) – Auto Task color setting information. Defaults to “#005500”.
ready_color (str, optional) – Ready Task color setting information. Defaults to “#C0C0C0”.
figsize ((float, float), optional) – Width, height in inches. Default to None -> [6.4, 4.8].
dpi (float, optional) – The resolution of the figure in dots-per-inch. Default to 100.0.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure in plt.subplots(). gnt: Axes in plt.subplots().
- Return type:
fig
- create_task(name: str = None, ID: str = None, default_work_amount: float = None, work_amount_progress_of_unit_step_time: float = None, input_task_id_dependency_set: set[tuple[str, BaseTaskDependency]] = None, allocated_team_id_set: set[str] = None, allocated_workplace_id_set: set[str] = None, workplace_priority_rule: WorkplacePriorityRuleMode = WorkplacePriorityRuleMode.FSS, worker_priority_rule: ResourcePriorityRuleMode = ResourcePriorityRuleMode.MW, facility_priority_rule: ResourcePriorityRuleMode = ResourcePriorityRuleMode.SSP, need_facility: bool = False, target_component_id: str = None, default_progress: float = None, due_time: float = None, auto_task: bool = False, fixing_allocating_worker_id_set: set[str] = None, fixing_allocating_facility_id_set: set[str] = None, est: float = 0.0, eft: float = 0.0, lst: float = -1.0, lft: float = -1.0, remaining_work_amount: float = None, remaining_work_amount_record_list: list[float] = None, state: BaseTaskState = BaseTaskState.NONE, state_record_list: list[BaseTaskState] = None, allocated_worker_facility_id_tuple_set: set[tuple[str, str]] = None, allocated_worker_facility_id_tuple_set_record_list: list[set[tuple[str, str]]] = None, additional_work_amount: float = None, additional_task_flag: bool = False, actual_work_amount: float = None)[source]
Create a BaseTask instance and add it to this workflow.
- Parameters:
name (str, optional) – Name of this task. Defaults to None -> “New Task”.
ID (str, optional) – ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
default_work_amount (float, optional) – Default workamount of this BaseTask. Defaults to None -> 10.0.
work_amount_progress_of_unit_step_time (float, optional) – Baseline of work amount progress of unit step time. Default to None -> 1.0.
input_task_id_dependency_set (set(tuple(str, BaseTaskDependency)), optional) – Set of input BaseTask id and type of dependency(FS, SS, SF, F/F) tuple. Defaults to None -> set().
allocated_team_id_set (set[str], optional) – Set of allocated BaseTeam id. Defaults to None -> set().
allocated_workplace_id_set (set[str], optional) – Set of allocated BaseWorkplace id. Defaults to None -> set().
workplace_priority_rule (WorkplacePriorityRuleMode, optional) – Workplace priority rule for simulation. Defaults to WorkplacePriorityRuleMode.FSS.
worker_priority_rule (ResourcePriorityRule, optional) – Worker priority rule for simulation. Defaults to ResourcePriorityRule.SSP.
facility_priority_rule (ResourcePriorityRule, optional) – Task priority rule for simulation. Defaults to TaskPriorityRule.TSLACK.
need_facility (bool, optional) – Whether one facility is needed for performing this task or not. Defaults to False.
target_component_id (str, optional) – Target BaseComponent id. Defaults to None.
default_progress (float, optional) – Progress before starting simulation (0.0 ~ 1.0). Defaults to None -> 0.0.
due_time (int, optional) – Due time. Defaults to None -> int(-1).
auto_task (bool, optional) – If True, this task is performed automatically even if there are no allocated workers. Defaults to False.
fixing_allocating_worker_id_set (set[str], optional) – Allocating worker ID set for fixing allocation in simulation. Defaults to None.
fixing_allocating_facility_id_set (set[str], optional) – Allocating facility ID set for fixing allocation in simulation. Defaults to None.
est (float, optional) – Earliest start time of CPM. This will be updated step by step. Defaults to 0.0.
eft (float, optional) – Earliest finish time of CPM. This will be updated step by step. Defaults to 0.0.
lst (float, optional) – Latest start time of CPM. This will be updated step by step. Defaults to -1.0.
lft (float, optional) – Latest finish time of CPM. This will be updated step by step. Defaults to -1.0.
remaining_work_amount (float, optional) – Remaining workamount in simulation. Defaults to None -> default_work_amount * (1.0 - default_progress).
remaining_work_amount_record_list (List[float], optional) – Record of remaining workamount in simulation. Defaults to None -> [].
state (BaseTaskState, optional) – State of this task in simulation. Defaults to BaseTaskState.NONE.
state_record_list (List[BaseTaskState], optional) – Record list of state. Defaults to None -> [].
allocated_worker_facility_id_tuple_set (set(tuple(str, str)), optional) – State of allocating worker and facility id tuple set in simulation. Defaults to None -> set().
allocated_worker_facility_id_tuple_set_record_list (List[set[tuple(str, str)]], optional) – State of allocating worker and facility id tuple set in simulation. Defaults to None -> [].
additional_work_amount (float, optional) – Advanced parameter. Defaults to None.
additional_task_flag (bool, optional) – Advanced variable. Defaults to False.
actual_work_amount (float, optional) – Advanced variable. Default to None -> default_work_amount*(1.0-default_progress)
- Returns:
The created task.
- Return type:
- draw_networkx(g: DiGraph = None, pos: dict = None, arrows: bool = True, task_node_color: str = '#00EE00', auto_task_node_color: str = '#005500', figsize: tuple[float, float] = None, dpi: float = 100.0, save_fig_path: str = None, **kwargs)[source]
Draw networkx.
- Parameters:
g (networkx.Digraph, optional) – The information of networkx graph. Defaults to None -> self.get_networkx_graph().
pos (networkx.layout, optional) – Layout of networkx. Defaults to None -> networkx.spring_layout(g).
arrows (bool, optional) – Digraph or Graph(no arrows). Defaults to True.
task_node_color (str, optional) – Node color setting information. Defaults to “#00EE00”.
auto_task_node_color (str, optional) – Node color setting information. Defaults to “#005500”.
figsize ((float, float), optional) – Width, height in inches. Default to None -> [6.4, 4.8].
dpi (float, optional) – The resolution of the figure in dots-per-inch. Default to 100.0.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
**kwargs – Other networkx settings.
- Returns:
Figure for a network.
- Return type:
figure
- draw_plotly_network(g: DiGraph = None, pos: dict = None, title: str = 'Workflow', node_size: int = 20, task_node_color: str = '#00EE00', auto_task_node_color: str = '#005500', save_fig_path=None)[source]
Draw plotly network.
- Parameters:
g (networkx.Digraph, optional) – The information of networkx graph. Defaults to None -> self.get_networkx_graph().
pos (networkx.layout, optional) – Layout of networkx. Defaults to None -> networkx.spring_layout(g).
title (str, optional) – Figure title of this network. Defaults to “Workflow”.
node_size (int, optional) – Node size setting information. Defaults to 20.
task_node_color (str, optional) – Node color setting information. Defaults to “#00EE00”.
auto_task_node_color (str, optional) – Node color setting information. Defaults to “#005500”.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure for a network.
- Return type:
figure
- export_dict_json_data()[source]
Export the information of this workflow to JSON data.
- Returns:
JSON format data.
- Return type:
dict
- extend_child_task_list(task_set: set[BaseTask])[source]
Extend target task_set to this workflow.
Deprecated since version Use: updated_task_set instead.
- Parameters:
task_set (set[BaseTask]) – Target task set.
- extract_finished_task_set(target_time_list: list[int])[source]
Extract FINISHED task list from simulation result.
- Parameters:
target_time_list (List[int]) – Target time list. If you want to extract finished task from time 2 to time 4, you must set [2, 3, 4] to this argument.
- Returns:
List of BaseTask.
- Return type:
List[BaseTask]
- extract_none_task_set(target_time_list: list[int])[source]
Extract NONE task set from simulation result.
- Parameters:
target_time_list (List[int]) – Target time list. If you want to extract none task from time 2 to time 4, you must set [2, 3, 4] to this argument.
- Returns:
List of BaseTask.
- Return type:
List[BaseTask]
- extract_ready_task_set(target_time_list: list[int])[source]
Extract READY task set from simulation result.
- Parameters:
target_time_list (List[int]) – Target time list. If you want to extract ready task from time 2 to time 4, you must set [2, 3, 4] to this argument.
- Returns:
List of BaseTask.
- Return type:
List[BaseTask]
- extract_working_task_set(target_time_list: list[int])[source]
Extract WORKING task list from simulation result.
- Parameters:
target_time_list (List[int]) – Target time list. If you want to extract working task from time 2 to time 4, you must set [2, 3, 4] to this argument.
- Returns:
List of BaseTask.
- Return type:
List[BaseTask]
- get_gantt_mermaid(target_id_order_list: list[str] = None, section: bool = True, range_time: tuple[int, int] = (0, 9223372036854775807), view_ready: bool = False, detailed_info: bool = False, id_name_dict: dict[str, str] = None)[source]
Get mermaid diagram of Gantt chart.
- Parameters:
target_id_order_list (list[str], optional) – Target ID order list. Defaults to None.
section (bool, optional) – Section or not. Defaults to True.
range_time (tuple[int, int], optional) – Range of Gantt chart. Defaults to (0, sys.maxsize).
view_ready (bool, optional) – If True, ready tasks are included in gantt chart. Defaults to False.
detailed_info (bool, optional) – Detailed information or not. Defaults to False.
id_name_dict (dict[str, str], optional) – Dictionary of ID and name for tasks. Defaults to None.
- Returns:
List of lines for mermaid diagram.
- Return type:
list[str]
- get_mermaid_diagram(shape_task: str = 'rect', print_work_amount_info: bool = True, link_type_str: str = '-->', print_dependency_type: bool = False, subgraph: bool = True, subgraph_direction: str = 'LR')[source]
Get mermaid diagram of this workflow.
- Parameters:
shape_task (str, optional) – Shape of mermaid diagram. Defaults to “rect”.
print_work_amount_info (bool, optional) – Print work amount information or not. Defaults to True.
link_type_str (str, optional) – Link type string. Defaults to “–>”.
print_dependency_type (bool, optional) – Print dependency type information or not. Defaults to False.
subgraph (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- Returns:
List of lines for mermaid diagram.
- Return type:
list[str]
- get_networkx_graph()[source]
Get the information of networkx graph.
- Returns:
Directed graph of the workflow.
- Return type:
networkx.DiGraph
- get_node_and_edge_trace_for_plotly_network(g: DiGraph = None, pos: dict = None, node_size: int = 20, task_node_color: str = '#00EE00', auto_task_node_color: str = '#005500')[source]
Get nodes and edges information of plotly network.
- Parameters:
g (networkx.Digraph, optional) – The information of networkx graph. Defaults to None -> self.get_networkx_graph().
pos (networkx.layout, optional) – Layout of networkx. Defaults to None -> networkx.spring_layout(g).
node_size (int, optional) – Node size setting information. Defaults to 20.
task_node_color (str, optional) – Node color setting information. Defaults to “#00EE00”.
auto_task_node_color (str, optional) – Node color setting information. Defaults to “#005500”.
- Returns:
Normal Task Node information of plotly network. auto_task_node_trace: Auto Task Node information of plotly network. edge_trace: Edge information of plotly network.
- Return type:
task_node_trace
- get_target_task_mermaid_diagram(target_task_set: set[BaseTask], shape_task: str = 'rect', print_work_amount_info: bool = True, link_type_str: str = '-->', print_dependency_type: bool = False, subgraph: bool = True, subgraph_direction: str = 'LR')[source]
Get mermaid diagram of target task.
- Parameters:
target_task_set (set[BaseTask]) – Set of target tasks.
shape_task (str, optional) – Shape of mermaid diagram. Defaults to “rect”.
print_work_amount_info (bool, optional) – Print work amount information or not. Defaults to True.
link_type_str (str, optional) – Link type string. Defaults to “–>”.
print_dependency_type (bool, optional) – Print dependency type information or not. Defaults to False.
subgraph (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- Returns:
List of lines for mermaid diagram.
- Return type:
list[str]
- get_task_set(name: str = None, ID: str = None, default_work_amount: float = None, input_task_id_dependency_set: set[tuple[str, BaseTaskDependency]] = None, allocated_team_id_set: set[str] = None, allocated_workplace_id_set: set[str] = None, need_facility: bool = None, target_component_id: str = None, default_progress: float = None, due_time: int = None, auto_task: bool = None, fixing_allocating_worker_id_set: set[str] = None, fixing_allocating_facility_id_set: set[str] = None, est: float = None, eft: float = None, lst: float = None, lft: float = None, remaining_work_amount: float = None, state: BaseTaskState = None, allocated_worker_facility_id_tuple_set: set[tuple[str, str]] = None, allocated_worker_facility_id_tuple_set_record_list: list[set[tuple[str, str]]] = None)[source]
Get task list by using search conditions related to BaseTask parameter.
If there is no searching condition, this function returns all task_set
- Parameters:
name (str, optional) – Target task name. Defaults to None.
ID (str, optional) – Target task ID. Defaults to None.
default_work_amount (float, optional) – Target task default_work_amount. Defaults to None.
input_task_id_dependency_set (set(tuple(str, BaseTaskDependency)), optional) – Target task input_task_id_dependency_set. Defaults to None.
allocated_team_id_set (set[str], optional) – Target task allocated_team_id_set. Defaults to None.
allocated_workplace_id_set (set[str], optional) – Target task allocated_workplace_id_set. Defaults to None.
need_facility (bool, optional) – Target task need_facility. Defaults to None.
target_component_id (str, optional) – Target task target_component_id. Defaults to None.
default_progress (float, optional) – Target task default_progress. Defaults to None.
due_time (int, optional) – Target task due_time. Defaults to None.
auto_task (bool, optional) – Target task auto_task. Defaults to None.
fixing_allocating_worker_id_set (set[str], optional) – Target task fixing_allocating_worker_id_set. Defaults to None.
fixing_allocating_facility_id_set (set[str], optional) – Target task fixing_allocating_facility_id_set. Defaults to None.
est (float, optional) – Target task est. Defaults to None.
eft (float, optional) – Target task eft. Defaults to None.
lst (float, optional) – Target task lst. Defaults to None.
lft (float, optional) – Target task lft. Defaults to None.
remaining_work_amount (float, optional) – Target task remaining_work_amount. Defaults to None.
state (BaseTaskState, optional) – Target task state. Defaults to None.
allocated_worker_facility_id_tuple_set (set(tuple(str, str)), optional) – Target task allocated_worker_facility_id_tuple_set. Defaults to None.
allocated_worker_facility_id_tuple_set_record_list (List[set(tuple(str, str))], optional) – Target task allocated_worker_facility_id_tuple_set_record_list. Defaults to None.
- Returns:
List of BaseTask.
- Return type:
List[BaseTask]
- initialize(state_info: bool = True, log_info: bool = True)[source]
Initialize the changeable variables of BaseWorkflow including PERT calculation.
- If state_info is True, the following attributes are initialized:
critical_path_length
PERT data
The state of each task after all tasks are initialized.
BaseTask in task_set are also initialized by this function.
- Parameters:
state_info (bool, optional) – Whether to initialize state information. Defaults to True.
log_info (bool, optional) – Whether to initialize log information. Defaults to True.
- insert_absence_time_list(absence_time_list: list[int])[source]
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- plot_simple_gantt(target_id_order_list: list[str] = None, finish_margin: float = 1.0, print_workflow_name: bool = True, view_auto_task: bool = False, view_ready: bool = False, task_color: str = '#00EE00', auto_task_color: str = '#005500', ready_color: str = '#C0C0C0', figsize: tuple[float, float] = None, dpi: float = 100.0, save_fig_path: str = None)[source]
Plot Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
target_id_order_list (list[str], optional) – Target ID order list. Defaults to None.
finish_margin (float, optional) – Margin of finish time in Gantt chart. Defaults to 1.0.
print_workflow_name (bool, optional) – Print workflow name or not. Defaults to True.
view_auto_task (bool, optional) – View auto_task or not. Defaults to False.
view_ready (bool, optional) – View READY time or not. Defaults to False.
task_color (str, optional) – Task color setting information. Defaults to “#00EE00”.
auto_task_color (str, optional) – Auto Task color setting information. Defaults to “#005500”.
ready_color (str, optional) – Ready Task color setting information. Defaults to “#C0C0C0”.
figsize ((float, float), optional) – Width, height in inches. Default to None -> [6.4, 4.8].
dpi (float, optional) – The resolution of the figure in dots-per-inch. Default to 100.0.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure in plt.subplots().
- Return type:
fig
- print_all_log_in_chronological_order(backward: bool = False)[source]
Print all log in chronological order.
- Parameters:
backward (bool, optional) – If True, print logs in reverse order. Defaults to False.
- print_gantt_mermaid(target_id_order_list: list[str] = None, date_format: str = 'X', axis_format: str = '%s', section: bool = True, range_time: tuple[int, int] = (0, 9223372036854775807), view_ready: bool = False, detailed_info: bool = False, id_name_dict: dict[str, str] = None)[source]
Print mermaid diagram of Gantt chart.
- Parameters:
target_id_order_list (list[str], optional) – Target ID order list. Defaults to None.
date_format (str, optional) – Date format of mermaid diagram. Defaults to “X”.
axis_format (str, optional) – Axis format of mermaid diagram. Defaults to “%s”.
section (bool, optional) – Section or not. Defaults to True.
range_time (tuple[int, int], optional) – Range of Gantt chart. Defaults to (0, sys.maxsize).
view_ready (bool, optional) – If True, ready tasks are included in gantt chart. Defaults to False.
detailed_info (bool, optional) – Detailed information or not. Defaults to False.
id_name_dict (dict[str, str], optional) – Dictionary of ID and name for tasks. Defaults to None.
- print_log(target_step_time: int)[source]
Print log in target_step_time.
- Parameters:
target_step_time (int) – Target step time of printing log.
- print_mermaid_diagram(orientations: str = 'LR', shape_task: str = 'rect', print_work_amount_info: bool = True, link_type_str: str = '-->', print_dependency_type: bool = False, subgraph: bool = True, subgraph_direction: str = 'LR')[source]
Print mermaid diagram of this workflow.
- Parameters:
orientations (str, optional) – Orientation of mermaid diagram. See: https://mermaid.js.org/syntax/flowchart.html#direction. Defaults to “LR”.
shape_task (str, optional) – Shape of mermaid diagram. Defaults to “rect”.
print_work_amount_info (bool, optional) – Print work amount information or not. Defaults to True.
link_type_str (str, optional) – Link type string. Defaults to “–>”.
print_dependency_type (bool, optional) – Print dependency type information or not. Defaults to False.
subgraph (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- print_target_task_mermaid_diagram(target_task_set: set[BaseTask], orientations: str = 'LR', shape_task: str = 'rect', print_work_amount_info: bool = True, link_type_str: str = '-->', print_dependency_type: bool = False, subgraph: bool = True, subgraph_direction: str = 'LR')[source]
Print mermaid diagram of target task.
- Parameters:
target_task_set (set[BaseTask]) – Set of target tasks.
orientations (str, optional) – Orientation of mermaid diagram. See: https://mermaid.js.org/syntax/flowchart.html#direction. Defaults to “LR”.
shape_task (str, optional) – Shape of mermaid diagram. Defaults to “rect”.
print_work_amount_info (bool, optional) – Print work amount information or not. Defaults to True.
link_type_str (str, optional) – Link type string. Defaults to “–>”.
print_dependency_type (bool, optional) – Print dependency type information or not. Defaults to False.
subgraph (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- read_json_data(json_data: dict)[source]
Read the JSON data for creating BaseWorkflow instance.
- Parameters:
json_data (dict) – JSON data.
- record(working: bool = True)[source]
Record the state of all tasks in task_set.
- Parameters:
working (bool, optional) – Whether to record as working. Defaults to True.
- remove_absence_time_list(absence_time_list: list[int])[source]
Remove record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- reverse_dependencies()[source]
Reverse all task dependencies in task_set.
Note
This method is developed only for backward simulation.
pDESy.model.base_workplace module
Module contents
__init__.