pDESy.model package¶
Submodules¶
pDESy.model.base_component module¶
base_component.
- class pDESy.model.base_component.BaseComponent(name=None, ID=None, parent_component_list=None, child_component_list=None, targeted_task_list=None, space_size=None, parent_product=None, state=BaseComponentState.NONE, state_record_list=None, placed_workplace=None, placed_workplace_id_record=None, error_tolerance=None, error=None)[source]¶
Bases:
object
BaseComponent.
BaseComponent class for expressing target product. This class can be used as template.
- Parameters:
name (str, optional) – Basic parameter. Name of this component. Defaults to None -> “New Component”
ID (str, optional) – Basic parameter. ID will be defined automatically.
parent_component_list (List[BaseComponent], optional) – Basic parameter. List of parent BaseComponents. Defaults to None -> [].
child_component_list (List[BaseComponent], optional) – Basic parameter. List of child BaseComponents. Defaults to None -> [].
targeted_task_list (List[BaseTask], optional) – Basic parameter. List of targeted tasks. Defaults to None -> [].
space_size (float, optional) – Basic parameter. Space size related to base_workplace’s max_space_size. Default to None -> 1.0.
parent_product (BaseProduct, optional) – Basic parameter. Parent product. Defaults to None.
state (BaseComponentState, optional) – Basic variable. State of this task in simulation. Defaults to BaseComponentState.NONE.
state_record_list (List[BaseComponentState], optional) – Basic variable. Record list of state. Defaults to None -> [].
placed_workplace (BaseWorkplace, optional) – Basic variable. A workplace which this component is placed in simulation. Defaults to None.
placed_workplace_id_record (List[str], optional) – Basic variable. Record of placed workplace ID in simulation. Defaults to None -> [].
error_tolerance (float, optional) – Advanced parameter.
error (float, optional) – Advanced variables.
- append_child_component(child_component)[source]¶
Append child component to child_component_list.
- Parameters:
child_component (BaseComponent) – BaseComponent which is child of this component.
Examples
>>> c = BaseComponent('c') >>> print([child_c.name for child_c in c.child_component_list]) [] >>> c1 = BaseComponent('c1') >>> c.append_child_component(c1) >>> print([child_c.name for child_c in c.child_component_list]) ['c1'] >>> print([parent_c.name for parent_c in c1.parent_component_list]) ['c']
- append_targeted_task(targeted_task)[source]¶
Append targeted task to targeted_task_list.
- Parameters:
targeted_task (BaseTask) – Targeted task of this component
Examples
>>> c = BaseComponent('c') >>> print([targeted_t.name for targeted_t in c.targeted_task_list]) [] >>> t1 = BaseTask('t1') >>> c.append_targeted_task(t1) >>> print([targeted_t.name for targeted_t in c.targeted_task_list]) ['t1'] >>> print(t1.target_component.name) 'c'
- create_data_for_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, finish_margin=1.0, view_ready=False)[source]¶
Create data for gantt plotly.
From start_time_list and finish_time_list of BaseTask in targeted_task_list.
- Parameters:
init_datetime (datetime.datetime) – Start datetime of project
unit_timedelta (datetime.timedelta) – Unit time of simulation
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 False.
- Returns:
Gantt plotly information of this BaseComponent
- Return type:
list[dict]
- 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)[source]¶
Extend the list of child components.
- Parameters:
child_component_list (List[BaseComponent]) – List of BaseComponents which are children of this component.
Examples
>>> c = BaseComponent('c') >>> print([child_c.name for child_c in c.child_component_list]) [] >>> c.extend_child_component_list([BaseComponent('c1'),BaseComponent('c2')]) >>> print([child_c.name for child_c in c.child_component_list]) ['c1', 'c2']
- extend_targeted_task_list(targeted_task_list)[source]¶
Extend the list of targeted tasks to targeted_task_list.
- Parameters:
targeted_task_list (List[BaseTask]) – List of targeted tasks
Examples
>>> c = BaseComponent('c') >>> print([targeted_t.name for targeted_t in c.targeted_task_list]) [] >>> c.extend_targeted_task_list([BaseTask('t1'),BaseTask('t2')]) >>> print([targeted_t.name for targeted_t in c.targeted_task_list]) ['t1', 't2']
- get_mermaid_diagram(shape: str = 'odd', subgraph: bool = False, subgraph_name: str = 'Component', subgraph_direction: str = 'LR')[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_gannt_chart(finish_margin=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 List[tuple(int, int)]: working_time_list including start_time, length
- Return type:
List[tuple(int, int)]
- initialize(state_info=True, log_info=True, check_task_state=True)[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
- Parameters:
state_info (bool) – State information are initialized or not. Defaluts to True.
log_info (bool) – Log information are initialized or not. Defaults to True.
check_task_state (bool) – Check the state of each task in this component or not. Defaults to True.
- insert_absence_time_list(absence_time_list)[source]¶
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- is_ready()[source]¶
Check READY component or not.
READY component is defined by satisfying the following conditions:
All tasks are not NONE.
There is no WORKING task in this component.
The states of append_targeted_task includes READY.
- Returns:
this component is READY or not.
- Return type:
bool
- print_log(target_step_time)[source]¶
Print log in target_step_time as follows:
ID
name
sum of default workamount in related tasks
sum of remaining workamount in related tasks.
state_record_list[target_step_time]
placed_workplace_id_record[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')[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()[source]¶
Record workplace id in this time to placed_workplace_id_record.
- remove_absence_time_list(absence_time_list)[source]¶
Remove record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- set_placed_workplace(placed_workplace, set_to_all_children=True)[source]¶
Set the placed_workplace.
- Parameters:
placed_workplace (BaseWorkplace) – Workplace placed in this component
set_to_all_children (bool) – If True, set placed_workplace to all children components Default to True
- update_error_value(no_error_prob: float, error_increment: float, seed=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.
Examples
>>> c = Component("c") >>> c.update_error_value(0.9, 1.0, seed=32) >>> print(c.error) 0.0 >>> c.update_error_value(0.4, 1.0, seed=32) >>> print(c.error) # Random 1.0 or 0.0 1.0
Note
This method is developed for customized simulation.
pDESy.model.base_facility module¶
base_facility.
- class pDESy.model.base_facility.BaseFacility(name=None, ID=None, workplace_id=None, cost_per_time=0.0, solo_working=False, workamount_skill_mean_map={}, workamount_skill_sd_map={}, absence_time_list=None, state=BaseFacilityState.FREE, state_record_list=None, cost_list=None, assigned_task_list=None, assigned_task_id_record=None)[source]¶
Bases:
object
BaseFacility.
BaseFacility class for expressing a workplace. This class will be used as template.
- Parameters:
name (str, optional) – Basic parameter. Name of this facility. Defaults to None -> “New Facility”
ID (str, optional) – Basic parameter. ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
workplace_id (str, optional) – Basic parameter. ID of Workplace which this facility is belonged. Defaults to None.
cost_per_time (float, optional) – Basic parameter. Cost of this facility per unit time. Defaults to 0.0.
solo_working (bool, optional) – Basic parameter. Flag whether this facility can work any task with other facilities or not. Defaults to False.
workamount_skill_mean_map (Dict[str, float], optional) – Basic parameter. Mean skill for expressing progress in unit time. Defaults to {}.
workamount_skill_sd_map (Dict[str, float], optional) – Basic parameter. Standard deviation of skill for expressing progress in unit time. Defaults to {}.
absence_time_list (List[int], optional) – List of absence time of simulation. Defaults to None -> [].
state (BaseFacilityState, optional) – Basic variable. State of this facility in simulation. Defaults to BaseFacilityState.FREE.
state_record_list (List[BaseFacilityState], optional) – Basic variable. Record list of state. Defaults to None -> [].
cost_list (List[float], optional) – Basic variable. History or record of his or her cost in simulation. Defaults to None -> [].
assigned_task_list (List[BaseTask], optional) – Basic variable. State of his or her assigned tasks in simulation. Defaults to None -> [].
assigned_task_id_record (List[List[str]], optional) – Basic variable. Record of his or her assigned tasks’ id in simulation. Defaults to None -> [].
- check_update_state_from_absence_time_list(step_time)[source]¶
Check and Update state of all resources to ABSENCE or FREE or WORKING.
- Parameters:
step_time (int) – Target step time of checking and updating state of workers and facilities.
- export_dict_json_data()[source]¶
Export the information of this facility to JSON data.
- Returns:
JSON format data.
- Return type:
dict
- get_mermaid_diagram(shape: str = 'stadium', subgraph: bool = False, subgraph_name: str = 'Facility', subgraph_direction: str = 'LR')[source]¶
Get mermaid diagram of this facility.
- Parameters:
shape (str, optional) – Shape of this facility. Defaults to “stadium”.
subgraph (bool, optional) – Whether to use subgraph or not. Defaults to False.
subgraph_name (str, optional) – Name of subgraph. Defaults to “Facility”.
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_gannt_chart(finish_margin=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 List[tuple(int, int)]: working_time_list including start_time, length List[tuple(int, int)]: absence_time_list including start_time, length
- Return type:
List[tuple(int, int)]
- get_work_amount_skill_progress(task_name, seed=None)[source]¶
Get progress of workamount by his or her contribution in this time.
If he or she has multiple tasks in this time, progress p_r(t) is defined as follows:
p_r(t)={ps_r(t)}/{N_r(t)}
ps_r(t): progress if he or she has only this task in this time
N_r(t): Number of allocated tasks to him or her in this time
- Parameters:
task_name (str) – Task name
error_tol (float, optional) – Countermeasures against numerical error. Defaults to 1e-10.
- Returns:
Progress of workamount by his or her contribution in this time
- Return type:
float
- has_workamount_skill(task_name, error_tol=1e-10)[source]¶
Check whether he or she has workamount skill or not.
By checking workamount_skill_mean_map.
- Parameters:
task_name (str) – Task name
error_tol (float, optional) – Measures against numerical error. Defaults to 1e-10.
- Returns:
whether he or she has workamount skill of task_name or not
- Return type:
bool
- initialize(error_tol=1e-10, state_info=True, log_info=True)[source]¶
Initialize the following changeable variables of BaseFacility.
If state_info is True, the following attributes are initialized.
state
assigned_task_list
- IF log_info is True, the following attributes are initialized.
state_record_list
cost_list
assigned_task_id_record
- Parameters:
state_info (bool) – State information are initialized or not. Defaults to True.
log_info (bool) – Log information are initialized or not. Defaults to True.
- insert_absence_time_list(absence_time_list)[source]¶
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- print_log(target_step_time)[source]¶
Print log in target_step_time as follows:
ID
name
state_record_list[target_step_time]
assigned_task_id_record[target_step_time]
- Parameters:
target_step_time (int) – Target step time of printing log.
- print_mermaid_diagram(orientations: str = 'LR', shape: str = 'stadium', subgraph: bool = False, subgraph_name: str = 'Facility', subgraph_direction: str = 'LR')[source]¶
Print mermaid diagram of this facility.
- 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 “stadium”.
subgraph (bool, optional) – Subgraph or not. Defaults to False.
subgraph_name (str, optional) – Subgraph name. Defaults to “Facility”.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
pDESy.model.base_organization module¶
base_organization.
- class pDESy.model.base_organization.BaseOrganization(name=None, ID=None, team_list=None, workplace_list=None, cost_list=None)[source]¶
Bases:
object
BaseOrganization.
BaseOrganization class for expressing organization in target project. BaseOrganization is consist of multiple BaseTeam and BaseWorkplace. This class will be used as template.
- Parameters:
name (str, optional) – Basic parameter. Name of this organization. Defaults to None -> “Organization”.
ID (str, optional) – Basic parameter. ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
team_list (List[BaseTeam], optional) – Basic parameter. List of BaseTeam in this organization. Default to None -> []
workplace_list (List[BaseWorkplace], optional) – Basic parameter. List of BaseWorkplace in this organization. Default to None -> []
cost_list (List[float], optional) – Basic variable. History or record of this organization’s cost in simulation. Defaults to None -> [].
- add_labor_cost(only_working=True, add_zero_to_all_workers=False, add_zero_to_all_facilities=False)[source]¶
Add labor cost to teams and workers in this organization.
- Parameters:
only_working (bool, optional) – If True, add labor cost to only WORKING workers in this organization. If False, add labor cost to all workers in this organization. Defaults to True.
add_zero_to_all_workers (bool, optional) – If True, add 0 labor cost to all workers in this team. If False, calculate labor cost normally. Defaults to False.
add_zero_to_all_facilities (bool, optional) – If True, add 0 labor cost to all facilities in this team. If False, calculate labor cost normally. Defaults to False.
- Returns:
Total labor cost of this team in this time.
- Return type:
float
- check_update_state_from_absence_time_list(step_time)[source]¶
Check and Update state of all resources to ABSENCE or FREE or WORKING.
- Parameters:
step_time (int) – Target step time of checking and updating state of workers and facilities.
- create_cost_history_plotly(init_datetime: datetime, unit_timedelta: timedelta, title='Cost Chart', save_fig_path=None)[source]¶
Create cost 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
title (str, optional) – Title of cost chart. Defaults to “Cost Chart”.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure for a gantt chart
- Return type:
figure
- create_data_for_cost_history_plotly(init_datetime: datetime, unit_timedelta: timedelta)[source]¶
Create data for cost history plotly from cost_list of team_list.
- Parameters:
init_datetime (datetime.datetime) – Start datetime of project
unit_timedelta (datetime.timedelta) – Unit time of simulation
- Returns:
Information of cost history chart.
- Return type:
data (List[go.Bar(name, x, y)]
- create_data_for_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, finish_margin=1.0, view_ready=False, view_absence=False)[source]¶
Create data for gantt plotly from team_list.
- Parameters:
init_datetime (datetime.datetime) – Start datetime of project
unit_timedelta (datetime.timedelta) – Unit time of simulation
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 False.
view_absence (bool, optional) – View READY time or not. Defaults to False.
- Returns:
Gantt plotly information of this BaseOrganization.
- Return type:
List[dict]
- create_gantt_plotly(init_datetime, unit_timedelta, title='Gantt Chart', colors=None, index_col=None, showgrid_x=True, showgrid_y=True, group_tasks=True, show_colorbar=True, finish_margin=1.0, view_ready=False, view_absence=False, save_fig_path=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
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. If None, the following default is used: {“WORKING”: “rgb(46, 137, 205)”, “READY”: “rgb(220, 220, 220)”, “ABSENCE”: “rgb(105, 105, 105)”}
index_col (str, optional) – index_col of plotly Gantt chart. Defaults to None -> “Type”.
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.
view_ready (bool, optional) – View READY time or not. Defaults to False.
view_absence (bool, optional) – View ABSENCE 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
Todo
Now, save_fig_path can be utilized only json and html format. Saving figure png, jpg, svg file is not implemented…
- create_simple_gantt(finish_margin=1.0, view_ready=False, view_absence=False, view_workers=True, view_facilities=True, team_color='#0099FF', worker_color='#D9E5FF', workplace_color='#0099FF', facility_color='#D9E5FF', ready_color='#DCDCDC', absence_color='#696969', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None)[source]¶
Create Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
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 False.
view_absence (bool, optional) – View ABSENCE time or not. Defaults to False.
view_workers (bool, optional) – Including workers in networkx graph or not. Default to Trstate = w.state_record_list[time]ue.
team_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
worker_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
workplace_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
facility_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
ready_color (str, optional) – Ready color setting information. Defaults to “#DCDCDC”.
absence_color (str, optional) – Absence color setting information. Defaults to “#696969”.
figsize ((float, float), optional) – Width, height in inches. Default to [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:
fig in plt.subplots() gnt: ax in plt.subplots()
- Return type:
fig
- draw_networkx(G=None, pos=None, arrows=True, view_workers=False, team_node_color='#0099FF', worker_node_color='#D9E5FF', view_facilities=False, workplace_node_color='#0099FF', facility_node_color='#D9E5FF', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None, **kwds)[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.
view_workers (bool, optional) – Including workers in networkx graph or not. Default to False.
team_node_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
worker_node_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
view_facilities (bool, optional) – Including facilities in networkx graph or not. Default to False.
workplace_node_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
facility_node_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
figsize ((float, float), optional) – Width, height in inches. Default to [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.
**kwds – another networkx settings.
- Returns:
Figure for a network
- Return type:
figure
- draw_plotly_network(G=None, pos=None, title='Organization', node_size=20, team_node_color='#0099FF', worker_node_color='#D9E5FF', view_workers=False, workplace_node_color='#0099FF', facility_node_color='#D9E5FF', view_facilities=False, 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 “Organization”.
node_size (int, optional) – Node size setting information. Defaults to 20.
team_node_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
worker_node_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
view_workers (bool, optional) – Including workers in networkx graph or not. Default to False.
workplace_node_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
facility_node_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
view_facilities (bool, optional) – Including facilities in networkx graph or not. Default to False.
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 organization to JSON data.
- Returns:
JSON format data.
- Return type:
dict
- get_facility_list(name=None, ID=None, workplace_id=None, cost_per_time=None, solo_working=None, workamount_skill_mean_map=None, workamount_skill_sd_map=None, state=None, cost_list=None, assigned_task_list=None, assigned_task_id_record=None)[source]¶
Get facility list by using search conditions related to BaseFacility parameter.
This method just executes BaseTeam.get_facility_list() in self.workplace_list.
- Parameters:
name (str, optional) – Target facility name. Defaults to None.
ID (str, optional) – Target facility ID. Defaults to None.
workplace_id (str, optional) – Target facility workplace_id. Defaults to None.
cost_per_time (float, optional) – Target facility cost_per_time. Defaults to None.
solo_working (bool, optional) – Target facility solo_working. Defaults to None.
workamount_skill_mean_map (Dict[str, float], optional) – Target facility workamount_skill_mean_map. Defaults to None.
workamount_skill_sd_map (Dict[str, float], optional) – Target facility workamount_skill_sd_map. Defaults to None.
state (BaseFacilityState, optional) – Target facility state. Defaults to None.
cost_list (List[float], optional) – Target facility cost_list. Defaults to None.
assigned_task_list (List[BaseTask], optional) – Target facility assigned_task_list. Defaults to None.
assigned_task_id_record (List[List[str]], optional) – Target facility assigned_task_id_record. Defaults to None.
- Returns:
List of BaseFacility.
- Return type:
List[BaseFacility]
- get_mermaid_diagram(print_worker: bool = True, shape_worker: str = 'stadium', link_type_str_worker: str = '-->', subgraph_team: bool = True, subgraph_direction_team: str = 'LR', print_facility: bool = True, shape_facility: str = 'stadium', link_type_str_facility: str = '-->', subgraph_workplace: bool = True, subgraph_direction_workplace: str = 'LR', subgraph: bool = False, subgraph_direction: str = 'LR')[source]¶
Get mermaid diagram of this organization.
- Parameters:
print_worker (bool) – Print workers or not. Defaults to True.
shape_worker (str) – Shape of worker. Defaults to “stadium”.
link_type_str_worker (str) – Link type string each worker. Defaults to “–>”.
subgraph_team (bool) – Print subgraph for team or not. Defaults to True.
subgraph_direction_team (str) – Direction of subgraph for team. Defaults to “LR”.
print_facility (bool) – Print facility or not. Defaults to True.
shape_facility (str) – Shape of facility. Defaults to “stadium”.
link_type_str_facility (str) – Link type string each facility. Defaults to “ –> “.
subgraph_workplace (bool) – Print subgraph for workplace or not. Defaults to True.
subgraph_direction_workplace (str) – Direction of subgraph for workplace. Defaults to “LR”.
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(view_workers=False, view_facilities=False)[source]¶
Get the information of networkx graph.
- Parameters:
view_workers (bool, optional) – Including workers in networkx graph or not. Default to False.
view_facilities (bool, optional) – Including facilities in networkx graph or not. Default to False.
- Returns:
networkx.Digraph()
- Return type:
G
- get_node_and_edge_trace_for_plotly_network(G=None, pos=None, node_size=20, team_node_color='#0099FF', worker_node_color='#D9E5FF', view_workers=False, workplace_node_color='#0099FF', facility_node_color='#D9E5FF', view_facilities=False)[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.
team_node_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
worker_node_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
view_workers (bool, optional) – Including workers in networkx graph or not. Default to False.
workplace_node_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
facility_node_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
view_facilities (bool, optional) – Including facilities in networkx graph or not. Default to False.
- Returns:
Team Node information of plotly network. worker_node_trace: Worker Node information of plotly network. workplace_node_trace: Workplace Node information of plotly network. facility_node_trace: Facility Node information of plotly network. edge_trace: Edge information of plotly network.
- Return type:
team_node_trace
- get_team_list(name=None, ID=None, worker_list=None, targeted_task_list=None, parent_team=None, cost_list=None)[source]¶
Get team list by using search conditions related to BaseTeam parameter.
If there is no searching condition, this function returns all self.team_list
- Parameters:
name (str, optional) – Target team name. Defaults to None.
ID (str, optional) – Target team ID. Defaults to None.
worker_list (List[BaseWorker], optional) – Target team worker_list. Defaults to None.
targeted_task_list (List[BaseTask], optional) – Target team targeted_task_list. Defaults to None.
parent_team (BaseTeam, optional) – Target team parent_team. Defaults to None.
cost_list (List[float], optional) – Target team cost_list. Defaults to None.
- Returns:
List of BaseTeam.
- Return type:
List[BaseTeam]
- get_worker_list(name=None, ID=None, team_id=None, cost_per_time=None, solo_working=None, workamount_skill_mean_map=None, workamount_skill_sd_map=None, facility_skill_map=None, state=None, cost_list=None, assigned_task_list=None, assigned_task_id_record=None)[source]¶
Get worker list by using search conditions related to BaseWorker parameter.
This method just executes BaseTeam.get_worker_list() in self.team_list.
- Parameters:
name (str, optional) – Target worker name. Defaults to None.
ID (str, optional) – Target worker ID. Defaults to None.
workplace_id (str, optional) – Target worker workplace_id. Defaults to None.
cost_per_time (float, optional) – Target worker cost_per_time. Defaults to None.
solo_working (bool, optional) – Target worker solo_working. Defaults to None.
workamount_skill_mean_map (Dict[str, float], optional) – Target worker workamount_skill_mean_map. Defaults to None.
workamount_skill_sd_map (Dict[str, float], optional) – Target worker workamount_skill_sd_map. Defaults to None.
facility_skill_map (Dict[str, float], optional) – Target worker facility_skill_map. Defaults to None.
state (BaseWorkerState, optional) – Target worker state. Defaults to None.
cost_list (List[float], optional) – Target worker cost_list. Defaults to None.
assigned_task_list (List[BaseTask], optional) – Target worker assigned_task_list. Defaults to None.
assigned_task_id_record (List[List[str]], optional) – Target worker assigned_task_id_record. Defaults to None.
- Returns:
List of BaseWorker.
- Return type:
List[BaseWorker]
- get_workplace_list(name=None, ID=None, facility_list=None, targeted_task_list=None, parent_workplace=None, max_space_size=None, cost_list=None, placed_component_list=None, placed_component_id_record=None)[source]¶
Get workplace list by using search conditions related to BaseTeam parameter.
If there is no searching condition, this function returns all self.workplace_list
- Parameters:
name (str, optional) – Target workplace name. Defaults to None.
ID (str, optional) – Target workplace ID. Defaults to None.
facility_list (List[BaseFacility], optional) – Target workplace facility_list. Defaults to None.
targeted_task_list (List[BaseTask], optional) – Target workplace targeted_task_list. Defaults to None.
parent_workplace (BaseWorkplace, optional) – Target workplace parent_workplace. Defaults to None.
max_space_size (float, optional) – Target workplace max_space_size. Defaults to None.
placed_component_list (List[BaseComponent], optional) – Target workplace placed_component_list. Defaults to None.
placed_component_id_record (List[List[str]], optional) – Target workplace placed_component_id_record. Defaults to None.
cost_list (List[float], optional) – Target workplace cost_list. Defaults to None.
- Returns:
List of BaseWorkplace.
- Return type:
List[BaseWorkplace]
- initialize(state_info=True, log_info=True)[source]¶
Initialize the changeable variables of BaseOrganization.
- If log_info is True, the following attributes are initialized.
cost_list
BaseTeam in team_list and BaseWorkplace in workplace_list are also initialized by this function.
- Parameters:
state_info (bool) – State information are initialized or not. Defaluts to True.
log_info (bool) – Log information are initialized or not. Defaults to True.
- insert_absence_time_list(absence_time_list)[source]¶
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- plot_simple_gantt(finish_margin=1.0, view_ready=False, view_workers=True, view_facilities=True, team_color='#0099FF', worker_color='#D9E5FF', workplace_color='#0099FF', facility_color='#D9E5FF', ready_color='#C0C0C0', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None)[source]¶
Plot Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
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 False.
view_workers (bool, optional) – Including workers in networkx graph or not. Default to Trstate = w.state_record_list[time]ue.
team_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
worker_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
workplace_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
facility_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
ready_color (str, optional) – Ready Worker/Facility color setting information. Defaults to “#C0C0C0”.
figsize ((float, float), optional) – Width, height in inches. Default to [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:
fig in plt.subplots()
- Return type:
fig
- print_log(target_step_time)[source]¶
Print log in target_step_time.
- Parameters:
target_step_time (int) – Target step time of printing log.
- print_mermaid_diagram(orientations: str = 'LR', print_worker: bool = True, shape_worker: str = 'stadium', link_type_str_worker: str = ' --> ', subgraph_team: bool = True, subgraph_direction_team: str = 'LR', print_facility: bool = True, shape_facility: str = 'stadium', link_type_str_facility: str = ' --> ', subgraph_workplace: bool = True, subgraph_direction_workplace: str = 'LR', subgraph: bool = False, subgraph_direction: str = 'LR')[source]¶
Print mermaid diagram of this team.
- Parameters:
orientations (str) – Orientation of the flowchart. Defaults to “LR”.
print_worker (bool) – Print workers or not. Defaults to True.
shape_worker (str) – Shape of worker. Defaults to “stadium”.
link_type_str_worker (str) – Link type string for team. Defaults to “ –> “.
subgraph_team (bool) – Print subgraph for team or not. Defaults to True.
subgraph_direction_team (str) – Direction of subgraph for team. Defaults to “LR”.
print_facility (bool) – Print facility or not. Defaults to True.
shape_facility (str) – Shape of facility. Defaults to “stadium”.
link_type_str_facility (str) – Link type string for workplace. Defaults to “ –> “.
subgraph_workplace (bool) – Print subgraph for workplace or not. Defaults to True.
subgraph_direction_workplace (str) – Direction of subgraph for workplace. Defaults to “LR”.
subgraph (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- read_json_data(json_data)[source]¶
Read the JSON data for creating BaseOrganization instance.
- Parameters:
json_data (dict) – JSON data.
- remove_absence_time_list(absence_time_list)[source]¶
Remove record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
pDESy.model.base_priority_rule module¶
base_priority_rule.
- class pDESy.model.base_priority_rule.ResourcePriorityRuleMode(*values)[source]¶
Bases:
IntEnum
ResourcePriorityRuleMode.
- HSV = 2¶
- MW = -1¶
- SSP = 0¶
- VC = 1¶
- class pDESy.model.base_priority_rule.TaskPriorityRuleMode(*values)[source]¶
Bases:
IntEnum
TaskPriorityRuleMode.
- EST = 1¶
- FIFO = 4¶
- LPT = 3¶
- LRPT = 5¶
- LWRPT = 7¶
- SPT = 2¶
- SRPT = 6¶
- SWRPT = 8¶
- TSLACK = 0¶
- class pDESy.model.base_priority_rule.WorkplacePriorityRuleMode(*values)[source]¶
Bases:
IntEnum
WorkplacePriorityRuleMode.
- FSS = 0¶
- SSP = 1¶
- pDESy.model.base_priority_rule.sort_facility_list(facility_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
args – Other information of each rule.
- Returns:
facility_list after sorted
- Return type:
List[BaseFacility]
- pDESy.model.base_priority_rule.sort_task_list(task_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 (ResourcePriorityRuleMode, 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, 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
args – Other information of each rule.
- Returns:
worker_list after sorted
- Return type:
List[BaseWorker]
- pDESy.model.base_priority_rule.sort_workplace_list(workplace_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
args – Other information of each rule.
- Returns:
resource_list after sorted
- Return type:
List[BaseWorkplace]
pDESy.model.base_product module¶
base_product.
- class pDESy.model.base_product.BaseProduct(name=None, ID=None, component_list=None)[source]¶
Bases:
object
BaseProduct.
BaseProduct class for expressing target product in a project. BaseProduct is consist of multiple BaseComponents. This class will be used as template.
- Parameters:
name (str, optional) – Basic parameter. Name of this product. Defaults to None -> “Product”.
ID (str, optional) – Basic parameter. ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
component_list (List[BaseComponent], optional) – List of BaseComponents
- append_child_component(component)[source]¶
Append target component to this workflow. :param component: target component :type component: BaseComponent
- check_removing_placed_workplace()[source]¶
Check removing this product from placed_workplace or not. If all tasks of this product is finished, this product will be removed automatically.
- create_data_for_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, finish_margin=1.0, view_ready=False)[source]¶
Create data for gantt plotly from component_list.
- Parameters:
init_datetime (datetime.datetime) – Start datetime of project
unit_timedelta (datetime.timedelta) – Unit time of simulation
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 False.
- Returns:
Gantt plotly information of this BaseProduct
- Return type:
List[dict]
- create_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, title='Gantt Chart', colors=None, index_col=None, showgrid_x=True, showgrid_y=True, group_tasks=True, show_colorbar=True, finish_margin=1.0, view_ready=False, save_fig_path=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
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 -> “Type”.
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.
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(finish_margin=1.0, view_ready=True, component_color='#FF6600', ready_color='#C0C0C0', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None)[source]¶
Create Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
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.
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 [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:
fig in plt.subplots() gnt: ax in plt.subplots()
- Return type:
fig
- draw_networkx(G=None, pos=None, arrows=True, component_node_color='#FF6600', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None, **kwds)[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 [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.
**kwds – another networkx settings.
- Returns:
Figure for a network
- Return type:
figure
- draw_plotly_network(G=None, pos=None, title='Product', node_size=20, component_node_color='#FF6600', 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 “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_child_component_list(component_list)[source]¶
Extend target component_list to this product. :param component_list: target component list :type component_list: List[BaseComponent]
- extract_finished_component_list(target_time_list)[source]¶
Extract FINISHED component list 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_list(target_time_list)[source]¶
Extract NONE component list 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_list(target_time_list)[source]¶
Extract READY component list 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_list(target_time_list)[source]¶
Extract WORKING component list 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_component_list(name=None, ID=None, parent_component_list=None, child_component_list=None, targeted_task_list=None, space_size=None, placed_workplace=None, placed_workplace_id_record=None)[source]¶
Get component list by using search conditions related to BaseComponent parameter.
If there is no searching condition, this function returns component_list.
- Parameters:
name (str, optional) – Target component name. Default to None.
ID (str, optional) – Target component ID. Default to None.
parent_component_list (List[BaseComponent], optional) – Target component parent_component_list. Default to None.
child_component_list (List[BaseComponent], optional) – Target component child_component_list. Default to None.
targeted_task_list (List[BaseTask], optional) – Target component targeted_task_list. Default to None.
space_size (float, optional) – Target component space_size. Default to None.
placed_workplace (BaseWorkplace, optional) – Target component placed_workplace. Default to None.
placed_workplace_id_record (List[str], optional) – Target component placed_workplace_id_record. Default to None.
- Returns:
List of BaseComponent.
- Return type:
List[BaseComponent]
- 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:
networkx.Digraph()
- Return type:
G
- get_node_and_edge_trace_for_plotly_network(G=None, pos=None, node_size=20, component_node_color='#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
- initialize(state_info=True, log_info=True)[source]¶
Initialize the following changeable variables of BaseProduct.
BaseComponent in component_list are also initialized by this function.
- Parameters:
state_info (bool) – State information are initialized or not. Defaults to True.
log_info (bool) – Log information are initialized or not. Defaults to True.
- insert_absence_time_list(absence_time_list)[source]¶
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- plot_simple_gantt(finish_margin=1.0, view_ready=True, component_color='#FF6600', ready_color='#C0C0C0', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None)[source]¶
Plot Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
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.
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 [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:
fig in plt.subplots()
- Return type:
fig
- print_log(target_step_time)[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”.
- read_json_data(json_data)[source]¶
Read the JSON data for creating BaseProduct instance.
- Parameters:
json_data (dict) – JSON data.
pDESy.model.base_project module¶
base_project.
- class pDESy.model.base_project.BaseProject(name=None, ID=None, init_datetime=None, unit_timedelta=None, absence_time_list=None, perform_auto_task_while_absence_time=None, product_list=None, workflow_list=None, team_list=None, workplace_list=None, time=0, cost_list=None, simulation_mode=None, status=None)[source]¶
Bases:
object
BaseProject.
BaseProject class for expressing target project including product, workflow, team_list and workplace_list. This class will be used as template.
- Parameters:
name (str, optional) – Basic parameter. Name of this project. Defaults to None -> “Project”.
ID (str, optional) – Basic parameter. ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
init_datetime (datetime.datetime, optional) – Start datetime of project. Defaults to None -> datetime.datetime.now().
unit_timedelta (datetime.timedelta, optional) – Unit time of simulation. Defaults to None -> datetime.timedelta(minutes=1).
absence_time_list (List[int], optional) – List of absence time of simulation. Defaults to None -> [].
perform_auto_task_while_absence_time (bool, optional) – Perform auto_task while absence time or not. Defaults to None -> False. This means that auto_task does not be performed while absence time.
product_list (List[BaseProduct], optional) – List of BaseProduct in this project. Defaults to None -> [].
workflow_list (List[BaseWorkflow], optional) – List of BaseWorkflow in this project. Defaults to None -> [].
team_list (List[BaseTeam], optional) – List of BaseTeam in this project. Defaults to None -> [].
workplace_list (List[BaseWorkplace], optional) – List of BaseWorkplace in this project. Defaults to None -> [].
time (int, optional) – Simulation time executing this method. Defaults to 0.
cost_list (List[float], optional) – Basic variable. History or record of this project’s cost in simulation. Defaults to None -> [].
simulation_mode (SimulationMode, optional) – Basic variable. Simulation mode. Defaults to None -> SimulationMode.NONE
status (BaseProjectStatus, optional) – Basic variable. Project status. Defaults to None -> BaseProjectStatus.NONE
- append_project_log_from_simple_json(file_path, encoding='utf-8')[source]¶
Append project log information from json file which is created by BaseProject.write_simple_json(). TODO: This function is not yet verified sufficiently.
- Parameters:
file_path (str) – File path for reading targeted extended project data.
- backward_simulate(task_performed_mode='multi-workers', task_priority_rule=TaskPriorityRuleMode.TSLACK, error_tol=1e-10, absence_time_list=[], perform_auto_task_while_absence_time=False, initialize_state_info=True, initialize_log_info=True, max_time=10000, unit_time=1, considering_due_time_of_tail_tasks=False, reverse_log_information=True)[source]¶
Simulate this BaseProject by using backward simulation.
- Parameters:
task_performed_mode (str, optional) – Mode of performed task in simulation. pDESy has the following options of this mode in simulation. - multi-workers Defaults to “multi-workers”.
task_priority_rule (TaskPriorityRule, optional) – Task priority rule for simulation. Defaults to TaskPriorityRule.TSLACK.
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.
error_tol (float, optional) – Measures against numerical error. Defaults to 1e-10.
absence_time_list (List[int], optional) – List of absence time in simulation. Defaults to []. This means workers work every time.
perform_auto_task_while_absence_time (bool, optional) – Perform auto_task while absence time or not. Defaults to False. This means that auto_task does not be performed while absence time.
initialize_state_info (bool, optional) – Whether initializing state info of this project or not. Defaults to True.
initialize_log_info (bool, optional) – Whether initializing log info of this project or not. Defaults to True.
max_time (int, optional) – Max time of simulation. Defaults to 10000.
unit_time (int, optional) – Unit time of simulation. Defaults to 1.
considering_due_time_of_tail_tasks (bool, optional) – Consider due_time of tail tasks or not. Default to False.
reverse_time_information (bool, optional) – Reverse information of simulation log or not. Defaults to True.
Note
This function is only for research and still in progress. Especially, this function is not suitable for simulation considering rework.
- create_gantt_plotly(title='Gantt Chart', colors=None, index_col=None, showgrid_x=True, showgrid_y=True, group_tasks=False, show_colorbar=True, finish_margin=1.0, save_fig_path=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
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)”,Task=”rgb(146, 237, 5)” ,Worker=”rgb(46, 137, 205)” ,Facility=”rgb(46, 137, 205)”,).
index_col (str, optional) – index_col of plotly Gantt chart. Defaults to None -> “Type”.
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.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure for a gantt chart
- Return type:
figure
- draw_networkx(G=None, pos=None, arrows=True, component_node_color='#FF6600', task_node_color='#00EE00', auto_task_node_color='#005500', team_node_color='#0099FF', worker_node_color='#D9E5FF', view_workers=False, view_facilities=False, workplace_node_color='#0099FF', facility_node_color='#D9E5FF', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None, **kwds)[source]¶
Draw networkx.
- Parameters:
G (networkx.SDigraph, 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”.
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”.
team_node_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
worker_node_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
view_workers (bool, optional) – Including workers in networkx graph or not. Default to False.
view_facilities (bool, optional) – Including facilities in networkx graph or not. Default to False.
workplace_node_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
facility_node_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
figsize ((float, float), optional) – Width, height in inches. Default to [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.
**kwds – another networkx settings.
- Returns:
Figure for a network
- Return type:
figure
- draw_plotly_network(G=None, pos=None, title='Project', node_size=20, component_node_color='#FF6600', task_node_color='#00EE00', auto_task_node_color='#005500', team_node_color='#0099FF', worker_node_color='#D9E5FF', view_workers=False, workplace_node_color='#0099FF', facility_node_color='#D9E5FF', view_facilities=False, 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 “Project”.
node_size (int, optional) – Node size setting information. Defaults to 20.
component_node_color (str, optional) – Node color setting information. Defaults to “#FF6600”.
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”.
team_node_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
worker_node_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
view_workers (bool, optional) – Including workers in networkx graph or not. Default to False.
workplace_node_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
facility_node_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
view_facilities (bool, optional) – Including facilities in networkx graph or not. Default to False.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure for a network
- Return type:
figure
- get_all_component_list()[source]¶
Get all component list in this project.
- Returns:
All component list in this project.
- Return type:
List[BaseComponent]
- get_all_facility_list()[source]¶
Get all facility list of this project.
- Returns:
All facility list of this project.
- Return type:
all_facility_list (list)
- get_all_task_list()[source]¶
Get all task list in this project.
- Returns:
All task list in this project.
- Return type:
List[BaseTask]
- get_all_worker_list()[source]¶
Get all worker list of this project.
- Returns:
All worker list of this project.
- Return type:
all_worker_list (list)
- get_mermaid_diagram(shape_component: str = 'odd', link_type_str_component: str = '-->', subgraph_product: bool = True, subgraph_direction_product: str = 'LR', shape_task: str = 'rect', print_work_amount_info: bool = True, print_dependency_type: bool = False, link_type_str_task: str = '-->', subgraph_workflow: bool = True, subgraph_direction_workflow: str = 'LR', print_worker: bool = True, shape_worker: str = 'stadium', link_type_str_worker: str = '-->', subgraph_team: bool = True, subgraph_direction_team: str = 'LR', print_facility: bool = True, shape_facility: str = 'stadium', link_type_str_facility: str = '-->', subgraph_workplace: bool = True, subgraph_direction_workplace: str = 'LR', link_type_str_component_task: str = '-.-', link_type_str_worker_task: str = '-.-', link_type_str_facility_task: str = '-.-', link_type_str_worker_facility: str = '-.-', subgraph: bool = False, subgraph_direction: str = 'LR')[source]¶
Get mermaid diagram of this project.
- Parameters:
shape_component (str, optional) – Shape of mermaid diagram. Defaults to “odd”.
link_type_str_component (str, optional) – Link type string of each component. Defaults to “–>”.
subgraph_product (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction_product (str, optional) – Direction of subgraph. 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.
print_dependency_type (bool, optional) – Print dependency type information or not. Defaults to False.
link_type_str_task (str, optional) – Link type string of each task. Defaults to “–>”.
subgraph_workflow (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction_workflow (str, optional) – Direction of subgraph. Defaults to “LR”.
print_worker (bool, optional) – Print workers or not. Defaults to True.
shape_worker (str, optional) – Shape of mermaid diagram. Defaults to “stadium”.
link_type_str_worker (str, optional) – Link type string of each worker. Defaults to “–>”.
subgraph_team (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction_team (str, optional) – Direction of subgraph. Defaults to “LR”.
print_facility (bool, optional) – Print facilities or not. Defaults to True.
shape_facility (str, optional) – Shape of mermaid diagram. Defaults to “stadium”.
link_type_str_facility (str, optional) – Link type string of each facility. Defaults to “–>”.
subgraph_workplace (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction_workplace (str, optional) – Direction of subgraph. Defaults to “LR”.
link_type_str_component_task (str, optional) – Link type string of each component and task. Defaults to “-.-“.
link_type_str_worker_task (str, optional) – Link type string of each worker and task. Defaults to “-.-“.
link_type_str_facility_task (str, optional) – Link type string of each facility and task. Defaults to “-.-“.
link_type_str_worker_facility (str, optional) – Link type string of each worker and facility. Defaults to “-.-“.
subgraph (bool, optional) – Subgraph or not. Defaults to False.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- Returns:
List of lines for mermaid diagram.
- Return type:
list[str]
- get_networkx_graph(view_workers=False, view_facilities=False)[source]¶
Get the information of networkx graph.
- Parameters:
view_workers (bool, optional) – Including workers in networkx graph or not. Default to False.
view_facilities (bool, optional) – Including facilities in networkx graph or not. Default to False.
- Returns:
networkx.Digraph()
- Return type:
G
- get_node_and_edge_trace_for_plotly_network(G=None, pos=None, node_size=20, component_node_color='#FF6600', task_node_color='#00EE00', auto_task_node_color='#005500', team_node_color='#0099FF', worker_node_color='#D9E5FF', view_workers=False, workplace_node_color='#0099FF', facility_node_color='#D9E5FF', view_facilities=False)[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”.
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”.
team_node_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
worker_node_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
view_workers (bool, optional) – Including workers in networkx graph or not. Default to False.
workplace_node_color (str, optional) – Node color setting information. Defaults to “#0099FF”.
facility_node_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
view_facilities (bool, optional) – Including facilities in networkx graph or not. Default to False.
- Returns:
component nodes information of plotly network. task_node_trace: task nodes information of plotly network. auto_task_node_trace: auto task nodes information of plotly network. team_node_trace: team nodes information of plotly network. worker_node_trace: worker nodes information of plotly network. workplace_node_trace: Workplace Node information of plotly network. facility_node_trace: Facility Node information of plotly network. edge_trace: Edge information of plotly network.
- Return type:
component_node_trace
- initialize(state_info=True, log_info=True)[source]¶
Initialize the following changeable variables of BaseProject.
If state_info is True, the attributes of this class are not initialized.
If log_info is True, the following attributes are initialized.
time
cost_list
simulation_mode
status
BaseProduct in product, BaseWorkflow in workflow, BaseTeam in team_list, and BaseWorkplace in workplace_list are initialized.
- Parameters:
state_info (bool) – State information are initialized or not. Defaults to True.
log_info (bool) – Log information are initialized or not. Defaults to True.
- insert_absence_time_list(absence_time_list)[source]¶
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- print_log(target_step_time)[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_component: str = '-->', subgraph_product: bool = True, subgraph_direction_product: str = 'LR', shape_task: str = 'rect', print_work_amount_info: bool = True, print_dependency_type: bool = False, link_type_str_task: str = '-->', subgraph_workflow: bool = True, subgraph_direction_workflow: str = 'LR', print_worker: bool = True, shape_worker: str = 'stadium', link_type_str_worker: str = '-->', subgraph_team: bool = True, subgraph_direction_team: str = 'LR', print_facility: bool = True, shape_facility: str = 'stadium', link_type_str_facility: str = '-->', subgraph_workplace: bool = True, subgraph_direction_workplace: str = 'LR', link_type_str_component_task: str = '-.-', link_type_str_worker_task: str = '-.-', link_type_str_facility_task: str = '-.-', link_type_str_worker_facility: str = '-.-', subgraph: bool = False, subgraph_direction: str = 'LR')[source]¶
Print mermaid diagram of this project.
- Parameters:
orientations (str) – Orientation of the flowchart. Defaults to “LR”.
shape_component (str, optional) – Shape of mermaid diagram. Defaults to “odd”.
link_type_str_component (str, optional) – Link type string of each component. Defaults to “–>”.
subgraph_product (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction_product (str, optional) – Direction of subgraph. 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.
print_dependency_type (bool, optional) – Print dependency type information or not. Defaults to False.
link_type_str_task (str, optional) – Link type string of each task. Defaults to “–>”.
subgraph_workflow (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction_workflow (str, optional) – Direction of subgraph. Defaults to “LR”.
print_worker (bool, optional) – Print workers or not. Defaults to True.
shape_worker (str, optional) – Shape of mermaid diagram. Defaults to “stadium”.
link_type_str_worker (str, optional) – Link type string of each worker. Defaults to “–>”.
subgraph_team (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction_team (str, optional) – Direction of subgraph. Defaults to “LR”.
print_facility (bool, optional) – Print facilities or not. Defaults to True.
shape_facility (str, optional) – Shape of mermaid diagram. Defaults to “stadium”.
link_type_str_facility (str, optional) – Link type string of each facility. Defaults to “–>”.
subgraph_workplace (bool, optional) – Subgraph or not. Defaults to True.
subgraph_direction_workplace (str, optional) – Direction of subgraph. Defaults to “LR”.
link_type_str_component_task (str, optional) – Link type string of each component and task. Defaults to “-.-“.
link_type_str_worker_task (str, optional) – Link type string of each worker and task. Defaults to “-.-“.
link_type_str_facility_task (str, optional) – Link type string of each facility and task. Defaults to “-.-“.
link_type_str_worker_facility (str, optional) – Link type string of each worker and facility. Defaults to “-.-“.
subgraph (bool, optional) – Subgraph or not. Defaults to False.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- read_simple_json(file_path, encoding='utf-8')[source]¶
Read json file which is created by BaseProject.write_simple_json().
- Parameters:
file_path (str) – File path for reading this project data.
- set_last_datetime(last_datetime, unit_timedelta=None, set_init_datetime=True)[source]¶
Set the last datetime to project simulation result. This means that calculate the init datetime of this project considering last_datetime.
- Parameters:
last_datetime (datetime.datetime) – Last datetime of project.
unit_timedelta (datetime.timedelta, optional) – Unit time of simulation. Defaults to None -> self.unit_timedelta
set_init_datetime (bool, optional) – Set calculated init_datetime or not in this project. Defaults to True.
- Returns:
Init datetime of project considering the last_datetime
- Return type:
datetime.datetime
- simulate(task_performed_mode='multi-workers', task_priority_rule=TaskPriorityRuleMode.TSLACK, error_tol=1e-10, absence_time_list=[], perform_auto_task_while_absence_time=False, initialize_state_info=True, initialize_log_info=True, max_time=10000, unit_time=1)[source]¶
Simulate this BaseProject.
- Parameters:
task_performed_mode (str, optional) –
Mode of performed task in simulation. pDESy has the following options of this mode in simulation.
multi-workers
Defaults to “multi-workers”.
task_priority_rule (TaskPriorityRule, optional) – Task priority rule for simulation. Defaults to TaskPriorityRule.TSLACK.
error_tol (float, optional) – Measures against numerical error. Defaults to 1e-10.
absence_time_list (List[int], optional) – List of absence time in simulation. Defaults to []. This means workers work every time.
perform_auto_task_while_absence_time (bool, optional) – Perform auto_task while absence time or not. Defaults to False. This means that auto_task does not be performed while absence time.
initialize_state_info (bool, optional) – Whether initializing state info of this project or not. Defaults to True.
initialize_log_info (bool, optional) – Whether initializing log info of this project or not. Defaults to True.
max_time (int, optional) – Max time of simulation. Defaults to 10000.
unit_time (int, optional) – Unit time of simulation. Defaults to 1.
pDESy.model.base_subproject_task module¶
base_subproject_task.
- class pDESy.model.base_subproject_task.BaseSubProjectTask(file_path=None, unit_timedelta=None, read_json_file=False, remove_absence_time_list=False, name=None, ID=None, default_work_amount=None, work_amount_progress_of_unit_step_time=None, input_task_list=None, output_task_list=None, allocated_team_list=None, allocated_workplace_list=None, parent_workflow=None, workplace_priority_rule=WorkplacePriorityRuleMode.FSS, worker_priority_rule=ResourcePriorityRuleMode.SSP, facility_priority_rule=ResourcePriorityRuleMode.SSP, need_facility=False, target_component=None, default_progress=None, due_time=None, auto_task=True, fixing_allocating_worker_id_list=None, fixing_allocating_facility_id_list=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_list=None, allocated_worker_id_record=None, allocated_facility_list=None, allocated_facility_id_record=None, additional_work_amount=None, additional_task_flag=False, actual_work_amount=None)[source]¶
Bases:
BaseTask
BaseSubProjectTask.
BaseSubProjectTask class for expressing target sub project.
- Parameters:
file_path (str, optional) – File path of sub project data. Defaults to None.
unit_timedelta (datetime.timedelta, optional) – Unit time of simulation. Defaults to None -> datetime.timedelta(minutes=1).
read_json_file (bool, optional) – Read json file or not. Defaults to False.
remove_absence_time_list (bool, optional) – Remove absence_time_list or not. Defaults to False.
- export_dict_json_data()[source]¶
Export the information of this task to JSON data.
- Returns:
JSON format data.
- Return type:
dict
- set_all_attributes_from_json(file_path=None, remove_absence_time_list=True)[source]¶
Read json file which is created by BaseProject.write_simple_json().
- Parameters:
file_path (str, optional) – Json file path for reading sub this project data. Default to None -> self.file_path
remove_absence_time_list (bool, optional) – Remove absence_time_list information from target json file or not. Default to True.
- Returns:
duration step time of target project. datetime.timedelta: unit time of target project.
- Return type:
int
pDESy.model.base_task module¶
base_task.
- class pDESy.model.base_task.BaseTask(name=None, ID=None, default_work_amount=None, work_amount_progress_of_unit_step_time=None, input_task_list=None, output_task_list=None, allocated_team_list=None, allocated_workplace_list=None, parent_workflow=None, workplace_priority_rule=WorkplacePriorityRuleMode.FSS, worker_priority_rule=ResourcePriorityRuleMode.MW, facility_priority_rule=ResourcePriorityRuleMode.SSP, need_facility=False, target_component=None, default_progress=None, due_time=None, auto_task=False, fixing_allocating_worker_id_list=None, fixing_allocating_facility_id_list=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_list=None, allocated_worker_id_record=None, allocated_facility_list=None, allocated_facility_id_record=None, additional_work_amount=None, additional_task_flag=False, actual_work_amount=None)[source]¶
Bases:
object
BaseTask.
BaseTask class for expressing target workflow. This class will be used as template.
- Parameters:
name (str, optional) – Basic parameter. Name of this task. Defaults to None -> “New Task”.
ID (str, optional) – Basic parameter. ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
default_work_amount (float, optional) – Basic parameter. 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_list (List[BaseTask,BaseTaskDependency], optional) – Basic parameter. List of input BaseTask and type of dependency(FS, SS, SF, F/F). Defaults to None -> [].
output_task_list (List[BaseTask,BaseTaskDependency], optional) – Basic parameter. List of input BaseTask and type of dependency(FS, SS, SF, F/F). Defaults to None -> [].
allocated_team_list (List[BaseTeam], optional) – Basic parameter. List of allocated BaseTeam Defaults to None -> [].
allocated_workplace_list (List[BaseWorkplace], optional) – Basic parameter. List of allocated BaseWorkplace. Defaults to None -> [].
parent_workflow (BaseWorkflow, optional) – Basic parameter. Parent workflow. 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) – Basic parameter. Whether one facility is needed for performing this task or not. Defaults to False
target_component (BaseComponent, optional) – Basic parameter. Target BaseComponent. Defaults to None.
default_progress (float, optional) – Basic parameter. Progress before starting simulation (0.0 ~ 1.0) Defaults to None -> 0.0.
due_time (int, optional) – Basic parameter. Defaults to None -> int(-1).
auto_task (bool, optional) – Basic parameter. If True, this task is performed automatically even if there are no allocated workers. Defaults to False.
fixing_allocating_worker_id_list (List[str], optional) – Basic parameter. Allocating worker ID list for fixing allocation in simulation. Defaults to None.
fixing_allocating_facility_id_list (List[str], optional) – Basic parameter. Allocating facility ID list for fixing allocation in simulation. Defaults to None.
est (float, optional) – Basic variable. Earliest start time of CPM. This will be updated step by step. Defaults to 0.0.
eft (float, optional) – Basic variable. Earliest finish time of CPM. This will be updated step by step. Defaults to 0.0.
lst (float, optional) – Basic variable. Latest start time of CPM. This will be updated step by step. Defaults to -1.0.
lft (float, optional) – Basic variable. Latest finish time of CPM. This will be updated step by step. Defaults to -1.0.
remaining_work_amount (float, optional) – Basic variable. Remaining workamount in simulation. Defaults to None -> default_work_amount * (1.0 - default_progress).
remaining_work_amount_record_list (List[float], optional) – Basic variable. Record of remaining workamount in simulation. Defaults to None -> [].
state (BaseTaskState, optional) – Basic variable. State of this task in simulation. Defaults to BaseTaskState.NONE.
state_record_list (List[BaseTaskState], optional) – Basic variable. Record list of state. Defaults to None -> [].
allocated_worker_list (List[BaseWorker], optional) – Basic variable. State of allocating worker list in simulation. Defaults to None -> [].
allocated_worker_id_record (List[List[str]], optional) – Basic variable. State of allocating worker id list in simulation. Defaults to None -> [].
allocated_facility_list (List[BaseFacility], optional) – Basic variable. State of allocating facility list in simulation. Defaults to None -> [].
allocated_facility_id_record (List[List[str]], optional) – Basic variable. State of allocating facility id list 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)
- append_input_task(input_task, task_dependency_mode=BaseTaskDependency.FS)[source]¶
Append input task to input_task_list.
- Parameters:
input_task (BaseTask) – Input BaseTask
task_dependency_mode (BaseTaskDependency, optional) – Task Dependency mode between input_task to this task. Default to BaseTaskDependency.FS
Examples
>>> task = BaseTask("task") >>> print([input_t.name for input_t in task.input_task_list]) [] >>> task1 = BaseTask("task1") >>> task.append_input_task(task1) >>> print([input_t.name for input_t in task.input_task_list]) ['task1'] >>> print([parent_t.name for parent_t in task1.output_task_list]) ['task']
- can_add_resources(worker=None, facility=None)[source]¶
Judge whether this task can be assigned another resources or not.
- Parameters:
worker (BaseWorker) – Target worker for allocating. Defaults to None.
facility (BaseFacility) – Target facility for allocating. Defaults to None.
- create_data_for_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, finish_margin=1.0, view_ready=False)[source]¶
Create data for gantt plotly.
- Parameters:
init_datetime (datetime.datetime) – Start datetime of project
unit_timedelta (datetime.timedelta) – Unit time of simulation
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 False.
- Returns:
Gantt plotly information of this BaseTask
- Return type:
list[dict]
- 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, task_dependency_mode=BaseTaskDependency.FS)[source]¶
Extend the list of input tasks to input_task_list.
- Parameters:
input_task_list (List[BaseTask]) – List of input BaseTask
task_dependency_mode (BaseTaskDependency) – Task Dependency mode between input_task to this task.
Examples
>>> task = BaseTask("task") >>> print([input_t.name for input_t in task.input_task_list]) [] >>> task1 = BaseTask("task1") >>> task.append_input_task(task1) >>> print([input_t.name for input_t in task.input_task_list]) ['task1'] >>> print([parent_t.name for parent_t in task1.output_task_list]) ['task']
- 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 “Product”.
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_gannt_chart(finish_margin=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 List[tuple(int, int)]: working_time_list including start_time, length
- Return type:
List[tuple(int, int)]
- initialize(error_tol=1e-10, state_info=True, log_info=True)[source]¶
Initialize the following changeable variables of BaseTask.
If state_info is True, the following attributes are initialized.
est
eft
lst
lft
remaining_work_amount
state
allocated_worker_list
allocated_facility_list
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_id_record
allocated_facility_id_record
- Parameters:
state_info (bool) – State information are initialized or not. Defaults to True.
log_info (bool) – Log information are initialized or not. Defaults to True.
error_tol (float) – error toleration of work amount for checking the state of this task. Defaults to 1e-10.
- insert_absence_time_list(absence_time_list)[source]¶
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- perform(time: int, seed=None, increase_component_error=1.0)[source]¶
Perform this BaseTask in this simulation.
- Parameters:
time (int) – Simulation time executing this method.
seed (int, optional) – Random seed for describing deviation of progress. Defaults to None.
increase_component_error (float, optional) – For advanced simulation. Increment error value when error has occurred. Defaults to 1.0.
Note
This method includes advanced code of custom simulation. We have to separete basic code and advanced code in the future.
- print_log(target_step_time)[source]¶
Print log in target_step_time as follows:
ID
name
default_work_amount
remaining_work_amount_record_list
state_record_list[target_step_time]
allocated_worker_id_record[target_step_time]
allocated_facility_id_record[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. See: https://mermaid.js.org/syntax/flowchart.html#direction 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”.
- record_allocated_workers_facilities_id()[source]¶
Record allocated worker & facilities id.
Target attributes are allocated_worker_id_record and allocated_facility_id_record.
pDESy.model.base_team module¶
base_team.
- class pDESy.model.base_team.BaseTeam(name=None, ID=None, worker_list=None, targeted_task_list=None, parent_team=None, cost_list=None)[source]¶
Bases:
object
BaseTeam.
BaseTeam class for expressing team in a project. This class will be used as template.
- Parameters:
name (str, optional) – Basic parameter. Name of this team. Defaults to None -> “New Team”
ID (str, optional) – Basic parameter. ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
worker_list (List[BaseWorker], optional) – Basic parameter. List of BaseWorkers who belong to this team. Defaults to None -> [].
targeted_task_list (List[BaseTask], optional) – Basic parameter. List of targeted BaseTasks. Defaults to None -> [].
parent_team (BaseTeam, optional) – Basic parameter. Parent team of this team. Defaults to None.
cost_list (List[float], optional) – Basic variable. History or record of this team’s cost in simulation. Defaults to None -> [].
- add_labor_cost(only_working=True, add_zero_to_all_workers=False)[source]¶
Add labor cost to workers in this team.
- Parameters:
only_working (bool, optional) – If True, add labor cost to only WORKING workers in this team. If False, add labor cost to all workers in this team. Defaults to True.
add_zero_to_all_workers (bool, optional) – If True, add 0 labor cost to all workers in this team. If False, calculate labor cost normally. Defaults to False.
- Returns:
Total labor cost of this team in this time.
- Return type:
float
- add_worker(worker)[source]¶
Add worker to worker_list.
- Parameters:
worker (BaseWorker) – Worker which is added to this workplace
- append_targeted_task(targeted_task)[source]¶
Append targeted task.
- Parameters:
targeted_task (BaseTask) – Targeted task
Examples
>>> team = BaseTeam('team') >>> print([targeted_t.name for targeted_t in team.targeted_task_list]) [] >>> t1 = BaseTask('t1') >>> team.append_targeted_task(t1) >>> print([targeted_t.name for targeted_t in team.targeted_task_list]) ['t1'] >>> print([target_team.name for target_team in t1.allocated_team_list]) ['team']
- check_update_state_from_absence_time_list(step_time)[source]¶
Check and Update state of all resources to ABSENCE or FREE or WORKING.
- Parameters:
step_time (int) – Target step time of checking and updating state of workers.
- create_cost_history_plotly(init_datetime: datetime, unit_timedelta: timedelta, title='Cost Chart', save_fig_path=None)[source]¶
Create cost 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
title (str, optional) – Title of cost chart. Defaults to “Cost Chart”.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure for a gantt chart
- Return type:
figure
- create_data_for_cost_history_plotly(init_datetime: datetime, unit_timedelta: timedelta)[source]¶
Create data for cost history plotly from cost_list of BaseWorker in worker_list.
- Parameters:
init_datetime (datetime.datetime) – Start datetime of project
unit_timedelta (datetime.timedelta) – Unit time of simulation
- Returns:
Information of cost history chart.
- Return type:
data (List[go.Bar(name, x, y)]
- create_data_for_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, finish_margin=1.0, view_ready=False, view_absence=False)[source]¶
Create data for gantt plotly of BaseWorker in worker_list.
- Parameters:
init_datetime (datetime.datetime) – self.cost_list = self.cost_list[::-1] Start datetime of project
unit_timedelta (datetime.timedelta) – Unit time of simulation
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 False.
view_absence (bool, optional) – View Absence time or not. Defaults to False.
- Returns:
Gantt plotly information of this BaseTeam
- Return type:
List[dict]
- create_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, title='Gantt Chart', colors=None, index_col=None, showgrid_x=True, showgrid_y=True, group_tasks=True, show_colorbar=True, save_fig_path=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
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. If None, default color setting will be used: {“WORKING”: “rgb(46, 137, 205)”, “READY”: “rgb(220, 220, 220)”, “ABSENCE”: “rgb(105, 105, 105)”}
index_col (str, optional) – index_col of plotly Gantt chart. Defaults to None -> “Type”.
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.
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(finish_margin=1.0, view_ready=False, view_absence=False, worker_color='#D9E5FF', ready_color='#DCDCDC', absence_color='#696969', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None)[source]¶
Create Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
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 False.
view_absence (bool, optional) – View ABSENCE time or not. Defaults to False.
worker_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
ready_color (str, optional) – Ready color setting information. Defaults to “#DCDCDC”.
absence_color (str, optional) – Absence color setting information. Defaults to “#696969”.
figsize ((float, float), optional) – Width, height in inches. Default to [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:
fig in plt.subplots() gnt: ax in plt.subplots()
- Return type:
fig
- export_dict_json_data()[source]¶
Export the information of this team to JSON data.
- Returns:
JSON format data.
- Return type:
dict
- extend_targeted_task_list(targeted_task_list)[source]¶
Extend the list of targeted tasks.
- Parameters:
targeted_task_list (list[BaseTask]) – List of targeted tasks
Examples
>>> team = BaseTeam('team') >>> print([targeted_t.name for targeted_t in team.targeted_task_list]) [] >>> team.extend_targeted_task_list([BaseTask('t1'),BaseTask('t2')]) >>> print([targeted_t.name for targeted_t in team.targeted_task_list]) ['t1', 't2']
- extract_free_worker_list(target_time_list)[source]¶
Extract FREE worker list from simulation result.
- Parameters:
target_time_list (List[int]) – Target time list. If you want to extract free worker from time 2 to time 4, you must set [2, 3, 4] to this argument.
- Returns:
List of BaseWorker
- Return type:
List[BaseWorker]
- extract_working_worker_list(target_time_list)[source]¶
Extract WORKING worker list from simulation result.
- Parameters:
target_time_list (List[int]) – Target time list. If you want to extract working worker from time 2 to time 4, you must set [2, 3, 4] to this argument.
- Returns:
List of BaseWorker
- Return type:
List[BaseWorker]
- get_mermaid_diagram(print_worker: bool = True, shape_worker: str = 'stadium', link_type_str: str = '-->', subgraph: bool = True, subgraph_direction: str = 'LR')[source]¶
Get mermaid diagram of this team.
- Parameters:
print_worker (bool, optional) – Print workers or not. Defaults to True.
shape_worker (str, optional) – Shape of workers in this team. Defaults to “stadium”.
link_type_str (str, optional) – Link type string. Defaults to “–>”.
subgraph (bool, optional) – Whether to use 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_worker_list(name=None, ID=None, team_id=None, cost_per_time=None, solo_working=None, workamount_skill_mean_map=None, workamount_skill_sd_map=None, facility_skill_map=None, state=None, cost_list=None, assigned_task_list=None, assigned_task_id_record=None)[source]¶
Get worker list by using search conditions related to BaseWorker parameter.
If there is no searching condition, this function returns all self.worker_list
- Parameters:
name (str, optional) – Target worker name. Defaults to None.
ID (str, optional) – Target worker ID. Defaults to None.
workplace_id (str, optional) – Target worker workplace_id. Defaults to None.
cost_per_time (float, optional) – Target worker cost_per_time. Defaults to None.
solo_working (bool, optional) – Target worker solo_working. Defaults to None.
workamount_skill_mean_map (Dict[str, float], optional) – Target worker workamount_skill_mean_map. Defaults to None.
workamount_skill_sd_map (Dict[str, float], optional) – Target worker workamount_skill_sd_map. Defaults to None.
facility_skill_map (Dict[str, float], optional) – Target worker facility_skill_map. Defaults to None.
state (BaseWorkerState, optional) – Target worker state. Defaults to None.
cost_list (List[float], optional) – Target worker cost_list. Defaults to None.
assigned_task_list (List[BaseTask], optional) – Target worker assigned_task_list. Defaults to None.
assigned_task_id_record (List[List[str]], optional) – Target worker assigned_task_id_record. Defaults to None.
- Returns:
List of BaseWorker.
- Return type:
List[BaseWorker]
- initialize(state_info=True, log_info=True)[source]¶
Initialize the following changeable variables of BaseTeam.
If log_info is True, the following attributes are initialized.
cost_list
BaseWorker in worker_list are also initialized by this function.
- Parameters:
state_info (bool) – State information are initialized or not. Defaluts to True.
log_info (bool) – Log information are initialized or not. Defaults to True.
- insert_absence_time_list(absence_time_list)[source]¶
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- plot_simple_gantt(finish_margin=1.0, view_ready=False, worker_color='#D9E5FF', ready_color='#C0C0C0', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None)[source]¶
Plot Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
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.
worker_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
ready_color (str, optional) – Ready color setting information. Defaults to “#C0C0C0”.
figsize ((float, float), optional) – Width, height in inches. Default to [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:
fig in plt.subplots()
- Return type:
fig
- print_log(target_step_time)[source]¶
Print log in target_step_time.
- Parameters:
target_step_time (int) – Target step time of printing log.
- print_mermaid_diagram(orientations: str = 'LR', print_worker: bool = True, shape_worker: str = 'stadium', link_type_str: str = '-->', subgraph: bool = False, subgraph_direction: str = 'LR')[source]¶
Print mermaid diagram of this team.
- Parameters:
orientations (str) – Orientation of the flowchart. Defaults to “LR”.
print_worker (bool, optional) – Print workers or not. Defaults to True.
shape_worker (str, optional) – Shape of workers in this team. Defaults to “stadium”.
link_type_str (str, optional) – Link type string. Defaults to “–>”.
subgraph (bool, optional) – Whether to use subgraph or not. Defaults to True.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- read_json_data(json_data)[source]¶
Read the JSON data for creating BaseTeam instance.
- Parameters:
json_data (dict) – JSON data.
- record_all_worker_state(working=True)[source]¶
Record the state of all workers by using BaseWorker.record_state().
pDESy.model.base_worker module¶
base_worker.
- class pDESy.model.base_worker.BaseWorker(name=None, ID=None, team_id=None, main_workplace_id=None, cost_per_time=0.0, solo_working=False, workamount_skill_mean_map={}, workamount_skill_sd_map={}, facility_skill_map={}, absence_time_list=None, state=BaseWorkerState.FREE, state_record_list=None, cost_list=None, assigned_task_list=None, assigned_task_id_record=None, quality_skill_mean_map={}, quality_skill_sd_map={})[source]¶
Bases:
object
BaseWorker.
BaseWorker class for expressing a worker. This class will be used as template.
- Parameters:
name (str, optional) – Basic parameter. Name of this worker. Defaults to None -> “New Worker”
ID (str, optional) – Basic parameter. ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
team_id (str, optional) – Basic parameter. Defaults to None.
main_workplace_id (str, optional) – Basic parameter. Defaults to None.
cost_per_time (float, optional) – Basic parameter. Cost of this worker per unit time. Defaults to 0.0.
solo_working (bool, optional) – Basic parameter. Flag whether this worker can work with other workers or not. Defaults to False.
workamount_skill_mean_map (Dict[str, float], optional) – Basic parameter. Skill for expressing progress in unit time. Defaults to {}.
workamount_skill_sd_map (Dict[str, float], optional) – Basic parameter. Standard deviation of skill for expressing progress in unit time. Defaults to {}.
facility_skill_map (Dict[str, float], optional) – Basic parameter. Skill for operating facility in unit time. Defaults to {}.
absence_time_list (List[int], optional) – List of absence time of simulation. Defaults to None -> [].
state (BaseWorkerState, optional) – Basic variable. State of this worker in simulation. Defaults to BaseWorkerState.FREE.
state_record_list (List[BaseWorkerState], optional) – Basic variable. Record list of state. Defaults to None -> [].
cost_list (List[float], optional) – Basic variable. History or record of his or her cost in simulation. Defaults to None -> [].
assigned_task_list (List[BaseTask], optional) – Basic variable. State of his or her assigned tasks in simulation. Defaults to None -> [].
assigned_task_id_record (List[List[str]], optional) – Basic variable. Record of his or her assigned tasks’ id in simulation. Defaults to None -> [].
quality_skill_mean_map (Dict[str, float], optional) – Advanced parameter. Skill for expressing quality in unit time. Defaults to {}.
quality_skill_sd_map (Dict[str, float], optional) – Advanced parameter. Standard deviation of skill for expressing quality in unit time. Defaults to {}.
- check_update_state_from_absence_time_list(step_time)[source]¶
Check and Update state of all resources to ABSENCE or FREE or WORKING.
- Parameters:
step_time (int) – Target step time of checking and updating state of workers and facilities.
- export_dict_json_data()[source]¶
Export the information of this worker to JSON data.
- Returns:
JSON format data.
- Return type:
dict
- get_mermaid_diagram(shape: str = 'stadium', subgraph: bool = False, subgraph_name: str = 'Worker', subgraph_direction: str = 'LR')[source]¶
Get mermaid diagram of this worker.
- Parameters:
shape (str, optional) – Shape of this worker. Defaults to “stadium”.
subgraph (bool, optional) – Whether to use subgraph or not. Defaults to False.
subgraph_name (str, optional) – Name of subgraph. Defaults to “Worker”.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- Returns:
List of lines for mermaid diagram.
- Return type:
list[str]
- get_quality_skill_point(task_name, seed=None)[source]¶
Get point of quality by his or her contribution in this time.
- Parameters:
task_name (str) – Task name
error_tol (float, optional) – Countermeasures against numerical error. Defaults to 1e-10.
- Returns:
Point of quality by his or her contribution in this time
- Return type:
float
- get_time_list_for_gannt_chart(finish_margin=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 List[tuple(int, int)]: working_time_list including start_time, length
- Return type:
List[tuple(int, int)]
- get_work_amount_skill_progress(task_name, seed=None)[source]¶
Get progress of workamount by his or her contribution in this time.
If he or she has multiple tasks in this time, progress p_r(t) is defined as follows:
p_r(t)={ps_r(t)}/{N_r(t)}
ps_r(t): progress if he or she has only this task in this time
N_r(t): Number of allocated tasks to him or her in this time
- Parameters:
task_name (str) – Task name
error_tol (float, optional) – Countermeasures against numerical error. Defaults to 1e-10.
- Returns:
Progress of workamount by his or her contribution in this time
- Return type:
float
- has_facility_skill(facility_name, error_tol=1e-10)[source]¶
Check whether he or she has facility skill or not.
By checking facility_skill_map.
- Parameters:
facility_name (str) – Facility name
error_tol (float, optional) – Measures against numerical error. Defaults to 1e-10.
- Returns:
whether he or she has workamount skill of task_name or not
- Return type:
bool
- has_quality_skill(task_name, error_tol=1e-10)[source]¶
Check whether he or she has quality skill or not.
By checking quality_skill_mean_map.
- Parameters:
task_name (str) – Task name
error_tol (float, optional) – Measures against numerical error. Defaults to 1e-10.
- Returns:
whether he or she has quality skill of task_name or not
- Return type:
bool
- has_workamount_skill(task_name, error_tol=1e-10)[source]¶
Check whether he or she has workamount skill or not.
By checking workamount_skill_mean_map.
- Parameters:
task_name (str) – Task name
error_tol (float, optional) – Measures against numerical error. Defaults to 1e-10.
- Returns:
whether he or she has workamount skill of task_name or not
- Return type:
bool
- initialize(state_info=True, log_info=True)[source]¶
Initialize the following changeable variables of BaseResource.
If state_info is True, the following attributes are initialized.
state
assigned_task_list
If log_info is True, the following attributes are initialized.
state_record_list
cost_list
assigned_task_id_record
- Parameters:
state_info (bool) – State information are initialized or not. Defaults to True.
log_info (bool) – Log information are initialized or not. Defaults to True.
- insert_absence_time_list(absence_time_list)[source]¶
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- print_log(target_step_time)[source]¶
Print log in target_step_time as follows:
ID
name
state_record_list[target_step_time]
assigned_task_id_record[target_step_time]
- Parameters:
target_step_time (int) – Target step time of printing log.
- print_mermaid_diagram(orientations: str = 'LR', shape: str = 'stadium', subgraph: bool = False, subgraph_name: str = 'Worker', subgraph_direction: str = 'LR')[source]¶
Print mermaid diagram of this worker.
- 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 “stadium”.
subgraph (bool, optional) – Subgraph or not. Defaults to False.
subgraph_name (str, optional) – Subgraph name. Defaults to “Worker”.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
pDESy.model.base_workflow module¶
base_workflow.
- class pDESy.model.base_workflow.BaseWorkflow(name=None, ID=None, task_list=None, critical_path_length=0.0)[source]¶
Bases:
object
BaseWorkflow.
BaseWorkflow class for expressing workflow in a project. BaseWorkflow is consist of multiple BaseTasks. This class will be used as template.
- Parameters:
name (str, optional) – Basic parameter. Name of this workflow. Defaults to None -> “Workflow”.
ID (str, optional) – Basic parameter. ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
task_list (List[BaseTask], optional) – Basic parameter. List of BaseTask in this BaseWorkflow. Default to None -> [].
critical_path_length (float, optional) – Basic variable. Critical path length of PERT/CPM. Defaults to 0.0.
- append_child_task(task)[source]¶
Append target task to this workflow. :param task: target task :type task: BaseTask
- check_state(time: int, state: BaseTaskState)[source]¶
Check state of all BaseTasks in task_list.
- Parameters:
time (int) – Simulation time
state (BaseTaskState) – Check target state. Search and update all tasks which can change only target state.
- create_data_for_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, finish_margin=1.0, view_ready=False)[source]¶
Create data for gantt plotly from task_list.
- Parameters:
init_datetime (datetime.datetime) – Start datetime of project
unit_timedelta (datetime.timedelta) – Unit time of simulation
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 False.
- Returns:
Gantt plotly information of this BaseWorkflow
- Return type:
list[dict]
- create_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, title='Gantt Chart', colors=None, index_col=None, showgrid_x=True, showgrid_y=True, group_tasks=True, show_colorbar=True, finish_margin=1.0, view_ready=False, save_fig_path=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
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.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure for a gantt chart
- Return type:
figure
- create_simple_gantt(finish_margin=1.0, view_auto_task=False, view_ready=False, task_color='#00EE00', auto_task_color='#005500', ready_color='#C0C0C0', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None)[source]¶
Create Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
finish_margin (float, optional) – Margin of finish time in Gantt chart. Defaults to 1.0.
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 [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:
fig in plt.subplots() gnt: ax in plt.subplots()
- Return type:
fig
- draw_networkx(G=None, pos=None, arrows=True, task_node_color='#00EE00', auto_task_node_color='#005500', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None, **kwds)[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 [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.
**kwds – another networkx settings.
- Returns:
Figure for a network
- Return type:
figure
- draw_plotly_network(G=None, pos=None, title='Workflow', node_size=20, task_node_color='#00EE00', auto_task_node_color='#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_list)[source]¶
Extend target task_list to this workflow. :param task_list: target task list :type task_list: List[BaseTask]
- extract_finished_task_list(target_time_list)[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_list(target_time_list)[source]¶
Extract NONE task list 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_list(target_time_list)[source]¶
Extract READY task list 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_list(target_time_list)[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_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:
networkx.Digraph()
- Return type:
G
- get_node_and_edge_trace_for_plotly_network(G=None, pos=None, node_size=20, task_node_color='#00EE00', auto_task_node_color='#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_task_list(name=None, ID=None, default_work_amount=None, input_task_list=None, output_task_list=None, allocated_team_list=None, allocated_workplace_list=None, need_facility=None, target_component=None, default_progress=None, due_time=None, auto_task=None, fixing_allocating_worker_id_list=None, fixing_allocating_facility_id_list=None, est=None, eft=None, lst=None, lft=None, remaining_work_amount=None, state=None, allocated_worker_list=None, allocated_worker_id_record=None, allocated_facility_list=None, allocated_facility_id_record=None)[source]¶
Get task list by using search conditions related to BaseTask parameter.
If there is no searching condition, this function returns all task_list
- Parameters:
name (str, optional) – Target task name. Default 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_list (List[BaseTask,BaseTaskDependency], optional) – Target task input_task_list Defaults to None.
output_task_list (List[BaseTask,BaseTaskDependency], optional) – Target task output_task_list Defaults to None.
allocated_team_list (List[BaseTeam], optional) – Target task allocated_team_list Defaults to None.
allocated_workplace_list (List[BaseWorkplace], optional) – Target task allocated_workplace_list Defaults to None.
need_facility (bool, optional) – Target task need_facility Defaults to None.
target_component (BaseComponent, optional) – Target task target_component 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_list (List[str], optional) – Target task fixing_allocating_worker_id_list Defaults to None.
fixing_allocating_facility_id_list (List[str], optional) – Target task fixing_allocating_facility_id_list 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_list (List[BaseWorker], optional) – Target task allocated_worker_list Defaults to None.
allocated_worker_id_record (List[List[str]], optional) – Target task allocated_worker_id_record Defaults to None.
allocated_facility_list (List[BaseFacility], optional) – Target task allocated_facility_list Defaults to None.
allocated_facility_id_record (List[List[str]], optional) – Target task allocated_facility_id_record Defaults to None.
- Returns:
List of BaseTask
- Return type:
List[BaseTask]
- initialize(state_info=True, log_info=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_list are also initialized by this function.
- Parameters:
state_info (bool) – State information are initialized or not. Defaults to True.
log_info (bool) – Log information are initialized or not. Defaults to True.
- insert_absence_time_list(absence_time_list)[source]¶
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- perform(time: int, only_auto_task=False, seed=None, increase_component_error=1.0)[source]¶
Perform BaseTask in task_list in simulation.
- Parameters:
time (int) – Simulation time.
only_auto_task (bool, optional) – Perform only auto task or not. Defaults to False.
seed (int, optional) – Random seed for describing deviation of progress. Defaults to None.
increase_component_error (float, optional) – For advanced simulation. Increment error value when error has occurred. Defaults to 1.0.
Note
This method includes advanced code of custom simulation. We have to separate basic code and advanced code in the future.
- plot_simple_gantt(finish_margin=1.0, view_auto_task=False, view_ready=False, task_color='#00EE00', auto_task_color='#005500', ready_color='#C0C0C0', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None)[source]¶
Plot Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
finish_margin (float, optional) – Margin of finish time in Gantt chart. Defaults to 1.0.
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 [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:
fig in plt.subplots()
- Return type:
fig
- print_log(target_step_time)[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”.
- read_json_data(json_data)[source]¶
Read the JSON data for creating BaseWorkflow instance.
- Parameters:
json_data (dict) – JSON data.
- remove_absence_time_list(absence_time_list)[source]¶
Remove record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
pDESy.model.base_workplace module¶
base_workplace.
- class pDESy.model.base_workplace.BaseWorkplace(name=None, ID=None, facility_list=None, targeted_task_list=None, parent_workplace=None, max_space_size=None, input_workplace_list=None, output_workplace_list=None, cost_list=None, placed_component_list=None, placed_component_id_record=None)[source]¶
Bases:
object
BaseWorkplace.
BaseWorkplace class for expressing workplace including facilities in a project. This class will be used as template.
- Parameters:
name (str, optional) – Basic parameter. Name of this workplace. Defaults to None -> “New Workplace”
ID (str, optional) – Basic parameter. ID will be defined automatically. Defaults to None -> str(uuid.uuid4()).
facility_list (List[BaseFacility], optional) – Basic parameter. List of BaseFacility who belong to this workplace. Defaults to None -> [].
targeted_task_list (List[BaseTask], optional) – Basic parameter. List of targeted BaseTasks. Defaults to None -> [].
parent_workplace (BaseWorkplace, optional) – Basic parameter. Parent workplace of this workplace. Defaults to None.
max_space_size (float, optional) – Basic parameter Max size of space for placing components Default to None -> 1.0
input_workplace_list (List[BaseWorkplace], optional) – Basic parameter. List of input BaseWorkplace. Defaults to None -> [].
output_workplace_list (List[BaseWorkplace], optional) – Basic parameter. List of input BaseWorkplace. Defaults to None -> [].
placed_component_list (List[BaseComponent], optional) – Basic variable. Components which places to this workplace in simulation. Defaults to None -> [].
placed_component_id_record (List[List[str]], optional) – Basic variable. Record of placed components ID in simulation. Defaults to None -> [].
cost_list (List[float], optional) – Basic variable. History or record of this workplace’s cost in simulation. Defaults to None -> [].
- add_facility(facility)[source]¶
Add facility to facility_list.
- Parameters:
facility (BaseFacility) – Facility which is added to this workplace
- add_labor_cost(only_working=True, add_zero_to_all_facilities=False)[source]¶
Add labor cost to facilities in this workplace.
- Parameters:
only_working (bool, optional) – If True, add labor cost to only WORKING facilities in this workplace. If False, add labor cost to all facilities in this workplace. Defaults to True.
add_zero_to_all_facilities (bool, optional) – If True, add 0 labor cost to all facilities in this workplace. If False, calculate labor cost normally. Defaults to False.
- Returns:
Total labor cost of this workplace in this time.
- Return type:
float
- append_input_workplace(input_workplace)[source]¶
Append input workplace to input_workplace_list.
- Parameters:
input_workplace (BaseWorkplace) – input workplace
Examples
>>> workplace = BaseWorkplace("workplace") >>> print([input_w.name for input_w in workplace.input_workplace_list]) [] >>> workplace1 = BaseWorkplace("workplace1") >>> workplace.append_input_task(workplace1) >>> print([input_w.name for input_w in workplace.input_workplace_list]) ['workplace1'] >>> print([parent_w.name for parent_w in workplace1.output_workplace_list]) ['workplace']
- append_targeted_task(targeted_task)[source]¶
Append targeted task to targeted_task_list.
- Parameters:
targeted_task (BaseTask) – Targeted task
Examples
>>> workplace = BaseWorkplace('workplace') >>> print([targeted_t.name for targeted_t in workplace.targeted_task_list]) [] >>> t1 = BaseTask('t1') >>> workplace.append_targeted_task(t1) >>> print([targeted_t.name for targeted_t in workplace.targeted_task_list]) ['t1'] >>> print([target_f.name for target_f in t1.allocated_workplace_list]) ['workplace']
- can_put(component, error_tol=1e-08)[source]¶
Check whether the target component can be put to this workplace in this time.
- Parameters:
component (BaseComponent) – BaseComponent
error_tol (float, optional) – Measures against numerical error. Defaults to 1e-8.
- Returns:
whether the target component can be put to this workplace in this time
- Return type:
bool
- check_update_state_from_absence_time_list(step_time)[source]¶
Check and Update state of all resources to ABSENCE or FREE or WORKING.
- Parameters:
step_time (int) – Target step time of checking and updating state of facilities.
- create_cost_history_plotly(init_datetime: datetime, unit_timedelta: timedelta, title='Cost Chart', save_fig_path=None)[source]¶
Create cost 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
title (str, optional) – Title of cost chart. Defaults to “Cost Chart”.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure for a gantt chart
- Return type:
figure
- create_data_for_cost_history_plotly(init_datetime: datetime, unit_timedelta: timedelta)[source]¶
Create data for cost history plotly from cost_list in facility_list.
- Parameters:
init_datetime (datetime.datetime) – Start datetime of project
unit_timedelta (datetime.timedelta) – Unit time of simulation
- Returns:
Information of cost history chart.
- Return type:
data (List[go.Bar(name, x, y)]
- create_data_for_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, finish_margin=1.0, view_ready=False, view_absence=False)[source]¶
Create data for gantt plotly of BaseFacility in facility_list.
- Parameters:
init_datetime (datetime.datetime) – Start datetime of project
unit_timedelta (datetime.timedelta) – Unit time of simulation
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 False.
view_absence (bool, optional) – View ABSENCE time or not. Defaults to False.
- Returns:
Gantt plotly information of this BaseWorkplace
- Return type:
List[dict]
- create_gantt_plotly(init_datetime: datetime, unit_timedelta: timedelta, title='Gantt Chart', colors=None, index_col=None, showgrid_x=True, showgrid_y=True, group_tasks=True, show_colorbar=True, save_fig_path=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
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. If None, default color setting will be used: {“WORKING”: “rgb(46, 137, 205)”, “READY”: “rgb(220, 220, 220)”, “ABSENCE”: “rgb(105, 105, 105)”}
index_col (str, optional) – index_col of plotly Gantt chart. Defaults to None -> “Type”.
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.
save_fig_path (str, optional) – Path of saving figure. Defaults to None.
- Returns:
Figure for a gantt chart
- Return type:
figure
- create_simple_gantt(finish_margin=1.0, view_ready=False, view_absence=False, facility_color='#D9E5FF', ready_color='#DCDCDC', absence_color='#696969', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None)[source]¶
Create Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
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 False.
view_absence (bool, optional) – View Absence time or not. Defaults to False.
facility_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
ready_color (str, optional) – Ready color setting information. Defaults to “#DCDCDC”.
absence_color (str, optional) – Absence color setting information. Defaults to “#696969”.
figsize ((float, float), optional) – Width, height in inches. Default to [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:
fig in plt.subplots() gnt: ax in plt.subplots()
- Return type:
fig
- export_dict_json_data()[source]¶
Export the information of this workplace to JSON data.
- Returns:
JSON format data.
- Return type:
dict
- extend_input_workplace_list(input_workplace_list)[source]¶
Extend the list of input workplaces to input_workplace_list.
- Parameters:
input_workplace_list (list[BaseWorkplace]) – List of input workplaces
Examples
>>> workplace = BaseWorkplace('workplace') >>> print([input_w.name for input_w in workplace.input_workplace_list]) [] >>> workplace.extend_input_workplace_list([BaseWorkplace('wp1'),Base('wp2')]) >>> print([input_w.name for input_t in workplace.input_workplace_list]) ['wp1', 'wp2']
- extend_targeted_task_list(targeted_task_list)[source]¶
Extend the list of targeted tasks to targeted_task_list.
- Parameters:
targeted_task_list (list[BaseTask]) – List of targeted tasks
Examples
>>> workplace = BaseWorkplace('workplace') >>> print([targeted_t.name for targeted_t in workplace.targeted_task_list]) [] >>> workplace.extend_targeted_task_list([BaseTask('t1'),BaseTask('t2')]) >>> print([targeted_t.name for targeted_t in workplace.targeted_task_list]) ['t1', 't2']
- extract_free_facility_list(target_time_list)[source]¶
Extract FREE facility list from simulation result.
- Parameters:
target_time_list (List[int]) – Target time list. If you want to extract free facility from time 2 to time 4, you must set [2, 3, 4] to this argument.
- Returns:
List of BaseFacility
- Return type:
List[BaseFacility]
- extract_working_facility_list(target_time_list)[source]¶
Extract WORKING facility list from simulation result.
- Parameters:
target_time_list (List[int]) – Target time list. If you want to extract working facility from time 2 to time 4, you must set [2, 3, 4] to this argument.
- Returns:
List of BaseFacility
- Return type:
List[BaseFacility]
- get_available_space_size()[source]¶
Get available space size in this time.
- Returns:
available space size in this time
- Return type:
float
- get_facility_list(name=None, ID=None, workplace_id=None, cost_per_time=None, solo_working=None, workamount_skill_mean_map=None, workamount_skill_sd_map=None, state=None, cost_list=None, assigned_task_list=None, assigned_task_id_record=None)[source]¶
Get facility list by using search conditions related to BaseFacility parameter.
If there is no searching condition, this function returns all self.facility_list.
- Parameters:
name (str, optional) – Target facility name. Defaults to None.
ID (str, optional) – Target facility ID. Defaults to None.
workplace_id (str, optional) – Target facility workplace_id. Defaults to None.
cost_per_time (float, optional) – Target facility cost_per_time. Defaults to None.
solo_working (bool, optional) – Target facility solo_working. Defaults to None.
workamount_skill_mean_map (Dict[str, float], optional) – Target facility workamount_skill_mean_map. Defaults to None.
workamount_skill_sd_map (Dict[str, float], optional) – Target facility workamount_skill_sd_map. Defaults to None.
state (BaseFacilityState, optional) – Target facility state. Defaults to None.
cost_list (List[float], optional) – Target facility cost_list. Defaults to None.
assigned_task_list (List[BaseTask], optional) – Target facility assigned_task_list. Defaults to None.
assigned_task_id_record (List[List[str]], optional) – Target facility assigned_task_id_record. Defaults to None.
- Returns:
List of BaseFacility.
- Return type:
List[BaseFacility]
- get_mermaid_diagram(print_facility: bool = True, shape_facility: str = 'stadium', link_type_str: str = '-->', subgraph: bool = True, subgraph_direction: str = 'LR')[source]¶
Get mermaid diagram of this workplace.
- Parameters:
print_facility (bool, optional) – Print facilities or not. Defaults to True.
shape_facility (str, optional) – Shape of facilities in this workplace. Defaults to “stadium”.
link_type_str (str, optional) – Link type string. Defaults to “–>”.
subgraph (bool, optional) – Whether to use 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_total_workamount_skill(task_name, error_tol=1e-10)[source]¶
Get total number of workamount skill of all facilities.
By checking workamount_skill_mean_map.
- Parameters:
task_name (str) – Task name
error_tol (float, optional) – Measures against numerical error. Defaults to 1e-10.
- Returns:
total workamount skill of target task name
- Return type:
float
- initialize(state_info=True, log_info=True)[source]¶
Initialize the following changeable variables of BaseWorkplace.
If state_info is True, the following attributes are initialized.
placed_component_list
- If log_info is True, the following attributes are initialized.
cost_list
placed_component_id_record
BaseFacility in facility_list are also initialized by this function.
- Parameters:
state_info (bool) – State information are initialized or not. Defaults to True.
log_info (bool) – Log information are initialized or not. Defaults to True.
- insert_absence_time_list(absence_time_list)[source]¶
Insert record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- plot_simple_gantt(finish_margin=1.0, view_ready=False, facility_color='#D9E5FF', ready_color='#C0C0C0', figsize=[6.4, 4.8], dpi=100.0, save_fig_path=None)[source]¶
Plot Gantt chart by matplotlib.
In this Gantt chart, datetime information is not included. This method will be used after simulation.
- Parameters:
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.
facility_color (str, optional) – Node color setting information. Defaults to “#D9E5FF”.
ready_color (str, optional) – Ready color setting information. Defaults to “#C0C0C0”.
figsize ((float, float), optional) – Width, height in inches. Default to [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:
fig in plt.subplots()
- Return type:
fig
- print_log(target_step_time)[source]¶
Print log in target_step_time.
- Parameters:
target_step_time (int) – Target step time of printing log.
- print_mermaid_diagram(orientations: str = 'LR', print_facility: bool = True, shape_facility: str = 'stadium', link_type_str: str = '-->', subgraph: bool = True, subgraph_direction: str = 'LR')[source]¶
Print mermaid diagram of this workplace.
- Parameters:
orientations (str) – Orientation of the flowchart. Defaults to “LR”.
print_facility (bool, optional) – Print facilities or not. Defaults to True.
shape_facility (str, optional) – Shape of facilities in this workplace. Defaults to “stadium”.
link_type_str (str, optional) – Link type string. Defaults to “–>”.
subgraph (bool, optional) – Whether to use subgraph or not. Defaults to True.
subgraph_direction (str, optional) – Direction of subgraph. Defaults to “LR”.
- read_json_data(json_data)[source]¶
Read the JSON data to populate the attributes of a BaseWorkplace instance.
- Parameters:
json_data (dict) – JSON data containing the attributes of the workplace.
- remove_absence_time_list(absence_time_list)[source]¶
Remove record information on absence_time_list.
- Parameters:
absence_time_list (List[int]) – List of absence step time in simulation.
- remove_placed_component(placed_component, remove_to_all_children_components=True)[source]¶
Remove the placed_workplace.
- Parameters:
placed_component (BaseComponent) – Component which places to this workplace
remove_to_all_children_components (bool) – If True, remove placed_workplace to all children components Default to True
- set_parent_workplace(parent_workplace)[source]¶
Set parent_workplace.
- Parameters:
parent_workplace (BaseWorkplace) – Parent workplace
Examples
>>> t = BaseWorkplace('t') >>> t1 = BaseWorkplace('t1') >>> t.set_parent_workplace(t1) >>> print(t.parent_workplace.name) 't1'
- set_placed_component(placed_component, set_to_all_children_components=True)[source]¶
Set the placed_workplace.
- Parameters:
placed_component (BaseComponent) – Component which places to this workplace
set_to_all_children_components (bool) – If True, set placed_workplace to all children components Default to True
Module contents¶
__init__.