DisjunctiveGraphJspVisualizer

class graph_jsp_env.disjunctive_graph_jsp_visualizer.DisjunctiveGraphJspVisualizer(*, dpi=55, width=15, height=10, scheduled_color='#DAF7A6', not_scheduled_color='#FFC300', color_job_edge='tab:gray', node_drawing_kwargs=None, edge_drawing_kwargs=None, critical_path_drawing_kwargs=None, handle_stop_signals=True)[source]

Bases: object

this class contains the code for all the different rendering options of a DisjunctiveGraphJssEnv, but it can be also used as a standalone visualizer.

COLOR_ESCAPE_SEQUENCE = '\x1b[0m'
gantt_and_graph_vis_as_rgb_array(*, G: DiGraph, df: DataFrame, colors: dict, stack: str = 'horizontally') ndarray[source]

wrapper for the graph_rgb_array-, gantt_chart_rgb_array- and render_rgb_array-methods.

Parameters:
  • G – parameter for graph_rgb_array

  • df – parameter for gantt_chart_rgb_array

  • colors – parameter for gantt_chart_rgb_array

  • stack – specifies how the graph and gantt char shall be stacked. valid options: ‘horizontally’, ‘vertically’

Returns:

stacked chart as rgb-array

static gantt_chart_console(df: DataFrame, colors: Dict) None[source]

console version of the gantt_chart_rgb_array-method. prints a gant chart to the console. the parameters need to follow the plotly specification. see: https://plotly.com/python/gantt/ or gantt_chart_rgb_array

Parameters:
  • df – dataframe according to plotly specification (https://plotly.com/python/gantt/).

  • colors – a dict that maps resources to color values. see example below. Note: make sure that the key match the resources specified in :param df:

Returns:

a plotly gantt chart as rgb array.

color example

import numpy as np

c_map = plt.cm.get_cmap(“jet”) # select the desired cmap arr = np.linspace(0, 1, 10) # create a list with numbers from 0 to 1 with n items colors = {resource: c_map(val) for resource, val in enumerate(arr)}

gantt_chart_rgb_array(df: DataFrame, *, colors: dict) ndarray[source]

wrapper for plotly gantt chart function. turn a gantt chart into a rgb array.

see: https://plotly.com/python/gantt/

Parameters:
  • df – dataframe according to plotly specification (https://plotly.com/python/gantt/).

  • colors – a dict that maps resources to color values. see example below. Note: make sure that the key match the resources specified in :param df:

Returns:

a plotly gantt chart as rgb array.

color example

import numpy as np

c_map = plt.cm.get_cmap(“jet”) # select the desired cmap arr = np.linspace(0, 1, 10) # create a list with numbers from 0 to 1 with n items (n = 10 here) colors = {resource: c_map(val) for resource, val in enumerate(arr)} <<pass colors as parameter>>

static graph_console(G: DiGraph, /, shape: tuple, colors: dict) None[source]

console version of the graph_rgb_array-method. prints a graph that indicates which tasks are scheduled to the console.

Parameters:
  • G – the nx.DiGraph of an DisjunctiveGraphJssEnv instance

  • shape – size of the jsp

  • colors – a dict that maps resources to color values. see example below. Note: make sure that the key match the resources specified in :param df:

Returns:

None

import numpy as np

c_map = plt.cm.get_cmap(“jet”) # select the desired cmap arr = np.linspace(0, 1, 10) # create a list with numbers from 0 to 1 with n items colors = {resource: c_map(val) for resource, val in enumerate(arr)}

graph_rgb_array(G: DiGraph) ndarray[source]

Wrapper for nx drawing operations.

Parameters:

G – the nx.DiGraph of an DisjunctiveGraphJssEnv instance

Returns:

a plot of the provided graph as rgb array.

render_gantt_in_window(df: DataFrame, *, colors: dict, **render_kwargs: dict) None[source]

wrapper for the gantt_chart_rgb_array- and render_rgb_array-methods

Parameters:
  • df – parameter for gantt_chart_rgb_array

  • colors – parameter for gantt_chart_rgb_array

  • render_kwargs – additional parameters for render_rgb_array

Returns:

None

render_graph_and_gant_in_window(*, G: DiGraph, df: DataFrame, colors: dict, stack: str = 'horizontally', **render_kwargs: dict) None[source]

wrapper for the graph_rgb_array-, gantt_chart_rgb_array- and render_rgb_array-methods.

Parameters:
  • G – parameter for graph_rgb_array

  • df – parameter for gantt_chart_rgb_array

  • colors – parameter for gantt_chart_rgb_array

  • stack – specifies how the graph and gantt char shall be stacked. valid options: ‘horizontally’, ‘vertically’

  • render_kwargs – additional parameters for render_rgb_array

Returns:

None

render_graph_in_window(G: DiGraph, **render_kwargs: dict) None[source]

wrapper for the graph_rgb_array- and render_rgb_array-methods

Parameters:
  • G – parameter for graph_rgb_array

  • render_kwargs – additional parameters for render_rgb_array

Returns:

None

static render_rgb_array(vis: ndarray[Any, dtype[ScalarType]], *, window_title: str = 'Job Shop Scheduling', wait: int = 1) None[source]

renders a rgb-array in an cv2 window. the window will remain open for :param wait: ms or till the user presses any key.

Parameters:
  • vis – the rgb-array to render.

  • window_title – the title of the cv2-window

  • wait – time in ms that the cv2-window is open. if None, then the window will remain open till a keyboard occurs.

Returns:

static rgb_color_sequence(r: int | float, g: int | float, b: int | float, *, format_type: str = 'foreground') str[source]

generates a color-codes, that change the color of text in console outputs.

rgb values must be numbers between 0 and 255 or 0.0 and 1.0.

Parameters:
  • r – red value.

  • g – green value

  • b – blue value

  • format_type – specifies weather the foreground-color or the background-color shall be adjusted. valid options: ‘foreground’,’background’

Returns:

a string that contains the color-codes.

static wrap_with_color_codes(s: object, /, r: int | float, g: int | float, b: int | float, **kwargs) str[source]

stringify an object and wrap it with console color codes. It adds the color control sequence in front and one at the end that resolves the color again.

rgb values must be numbers between 0 and 255 or 0.0 and 1.0.

Parameters:
  • s – the object to stringify and wrap

  • r – red value.

  • g – green value.

  • b – blue value.

  • kwargs – additional argument for the ‘DisjunctiveGraphJspVisualizer.rgb_color_sequence’-method.

Returns: