jobshoplab.env.rendering package

Submodules

jobshoplab.env.rendering.gant_dashboard module

class DashboardUtils[source]

Bases: object

Utility class for dashboard operations.

static map_time(int_time, current_time)[source]

Map integer time to real-time representation.

Parameters:
int_time : int

Integer time to be mapped.

current_time : int

Current time reference.

Returns:

MM:SS’.

Return type:

Formatted time string in the format ‘YYYY-MM-DD HH

static is_port_in_use(port)[source]

Check if a port is in use.

Parameters:
port : int

Port number to check.

Returns:

True if port is in use, False otherwise.

Return type:

bool

static check_port(port)[source]

Find an available port starting from the given port.

Parameters:
port : int

Starting port number to check.

Returns:

An available port number.

Return type:

int

static has_transports(data)[source]

Check if the data contains transport information.

Parameters:
data : Dict[str, Any]

Dictionary containing state data.

Returns:

True if transport data is present and valid, False otherwise.

Return type:

bool

class DashboardDataMapper[source]

Bases: object

Class responsible for mapping data for dashboard visualization.

static map_key_to_sort(key)[source]

Map component keys to sort values for consistent ordering.

Parameters:
key : str

Component identifier key (e.g., ‘j1’, ‘m2’, ‘t3’, ‘b4’).

Returns:

Integer value for sorting purposes.

Return type:

int

static get_color_mapping(keys)[source]

Create a color mapping for different component types.

Parameters:
keys : Set[str]

Set of component identifier keys.

Returns:

Dictionary mapping component keys to color values.

Return type:

Dict[str, str]

static make_hover_text(d)[source]

Generate hover text for Gantt chart elements.

Parameters:
d : Dict[str, Any]

Dictionary containing element data.

Returns:

Formatted HTML string for hover tooltip.

Return type:

str

static build_figure(data, current_time, axis)[source]

Build Plotly Gantt chart figure from data.

Parameters:
data : List[Dict[str, Any]]

List of dictionaries containing schedule, transport, and buffer data.

current_time : Any

Current time to display as vertical line.

axis : bool

If True, use components as y-axis; if False, use jobs as y-axis.

Returns:

Plotly Figure object.

Return type:

Figure

static map_states_to_schedule_data(last_state, latest_time)[source]

Extract schedule data from state machine state.

Parameters:
last_state : Any

The final state machine state containing job and operation info.

latest_time : Any

The latest time in the state machine history.

Returns:

Tuple of dictionaries containing schedule data.

Return type:

Tuple[Dict[str, Any], …]

static map_transports_to_data(transport, current_time)[source]

Map transport data to visualization format.

Parameters:
transport : Any

Transport object with state information.

current_time : Any

Current time reference.

Returns:

Dictionary containing formatted transport data.

Return type:

Dict[str, Any]

static make_transport_data(transports)[source]

Generate transport data in visualization-ready format.

Parameters:
transports : List[Any]

List of transport objects with state information.

Yields:

Dictionaries containing formatted transport data.

Return type:

Iterator[Dict[str, Any]]

static map_states_to_transport_data(history, latest_time)[source]

Extract transport data from state machine history.

Parameters:
history : Tuple[Any, ...]

Tuple of state machine results.

latest_time : Any

The latest time in the state machine history.

Returns:

Tuple of dictionaries containing transport data.

Return type:

Tuple[Dict[str, Any], …]

static map_states_to_buffer_data(history, latest_time)[source]

Extract buffer data from state machine history.

Parameters:
history : Tuple[Any, ...]

Tuple of state machine results.

latest_time : Any

The latest time in the state machine history.

Returns:

Tuple of dictionaries containing buffer data (currently not implemented).

Return type:

Tuple[Dict[str, Any], …]

static get_latest_time(last_state)[source]

Get the latest time from the state machine state.

Parameters:
last_state : Any

The final state machine state.

Returns:

The latest time value from operations.

Return type:

int

static add_sub_states_to_history(history)[source]

Extract and combine sub-states from history.

Parameters:
history : Tuple[Any, ...]

Tuple of state machine results.

Returns:

Tuple of states including sub-states.

Return type:

Tuple[Any, …]

static map_states_to_gant_data(history)[source]

Map state machine history to Gantt chart data.

Parameters:
history : Tuple[Any, ...]

Tuple of state machine results.

Returns:

Dictionary containing schedules, transports, and buffer data.

Return type:

Dict[str, Tuple[Dict[str, Any], …]]

class JobShopDashboard[source]

Bases: object

Main dashboard class for visualizing job shop scheduling data.

data

Dictionary containing schedule, transport, and buffer data.

num_machines

Tuple containing the number of machines.

num_jobs

Number of jobs in the instance.

current_time

Current time reference.

has_transports

Boolean indicating if transport data is present.

debug

Boolean flag for debug mode.

port

Port number for the dashboard server.

logger

Logger instance.

app

Dash application instance.

__init__(data, num_machines, num_jobs, current_time, has_transports, debug, port)[source]

Initialize the JobShopDashboard.

Parameters:
data : Dict[str, Any]

Dictionary containing schedule, transport, and buffer data.

num_machines : Tuple[int]

Tuple containing the number of machines.

num_jobs : int

Number of jobs in the instance.

current_time : Any

Current time reference.

has_transports : bool

Boolean indicating if transport data is present.

debug : bool

Boolean flag for debug mode.

port : int

Port number for the dashboard server.

Return type:

None

update_fig(data, current_time, show_transport, show_schedules, show_buffer, axis)[source]

Update the Gantt chart figure based on user selections.

Parameters:
data : Dict[str, List[Dict[str, Any]]]

Dictionary containing schedule, transport, and buffer data.

current_time : int

Current time reference.

show_transport : bool

Whether to display transport data.

show_schedules : bool

Whether to display schedule data.

show_buffer : bool

Whether to display buffer data.

axis : bool

If True, use components as y-axis; if False, use jobs as y-axis.

Returns:

Updated Plotly Figure object.

Return type:

Figure

download_db(data, current_time, num_jobs, num_machines, n_clicks)[source]

Prepare dashboard data for download in binary format.

Parameters:
data : Dict[str, Any]

Dictionary containing schedule, transport, and buffer data.

current_time : int

Current time reference.

num_jobs : int

Number of jobs in the instance.

num_machines : Tuple[int]

Tuple containing the number of machines.

n_clicks : int

Number of times the download button has been clicked.

Returns:

Dictionary containing download data or None if an error occurs.

Return type:

Dict[str, Any] | None

download_csv(data, n_clicks)[source]

Prepare dashboard data for download in CSV format.

Parameters:
data : Dict[str, List[Dict[str, Any]]]

Dictionary containing schedule, transport, and buffer data.

n_clicks : int

Number of times the download button has been clicked.

Returns:

Dictionary containing download data or None if an error occurs.

Return type:

Dict[str, Any] | None

run()[source]

Run the dashboard application.

Raises:

Exception – If dashboard fails to launch.

Return type:

None

start_dashboard_from_file(file_path, debug, port)[source]

Start the dashboard from a data file.

Parameters:
file_path : str

Path to the data file.

debug : bool

Flag to enable debug mode.

port : int

Port number for the dashboard server.

Raises:
Return type:

None

render_in_dashboard(loglevel, history, instance, debug=False, port=8050, *args, **kwargs)[source]

Render state machine results in a dashboard.

Parameters:
loglevel : int | str

Log level for the dashboard.

history : Tuple[StateMachineResult, ...]

Tuple of state machine results.

instance : InstanceConfig

Instance configuration.

debug : bool

Flag to enable debug mode.

port : int

Port number for the dashboard server.

*args

Additional positional arguments.

**kwargs

Additional keyword arguments.

Return type:

None

parse_cli_arguments()[source]

Parse command line arguments.

Returns:

Parsed command line arguments.

Return type:

Namespace

main()[source]

Main entry point for the dashboard application.

Return type:

None

jobshoplab.env.rendering.simulation module

dummy_sim(log_level, config, state_history)[source]
Parameters:
log_level : int | str

config : __SPHINX_IMMATERIAL_TYPE_VAR__V_Config

state_history : tuple[StateMachineResult, ...]

Return type:

None

jobshoplab.env.rendering.state_transitions_rendering module

render_state_transitions(config, loglevel, backend)[source]

Render the state transitions.

Parameters:
config : Config

The configuration object.

loglevel : int | str

The log level

backend : callable

The backend to use for rendering.

Module contents