simprocesd.utils package
Submodules
simprocesd.utils.math_utils module
- simprocesd.utils.math_utils.geometric_distribution_sample(probability, target_successes=1)
How many Bernoulli trials will it take to reach a number of successes.
This function performs random trials based on provided probability. Because the trials are random calling the function will same parameters does not mean same results.
Randomness is generated with Python’s ‘random’ module.
- Parameters:
probability (float) – Chance of success of each trial (0 to 1).
target_successes (int, default=1) – Desired number of successes.
- Returns:
Number of iterations it took to get desired number of successes.
- Return type:
int
simprocesd.utils.simulation_info_utils module
- simprocesd.utils.simulation_info_utils.plot_buffer_levels(system, buffers, subplot=None)
Show a graph of Buffer levels over time.
Graph is shown using matplotlib library.
- Parameters:
system (System) – System object used in the simulation.
buffers (list) – List of Buffers whose data will be plotted.
subplot (matplotlib.axes.Axes, default = None) – Optional subplot to graph the data on. If None then a new figure will be created and shown.
- simprocesd.utils.simulation_info_utils.plot_damage(system, machines, subplot=None)
Show a graph of damage over time for MachineWithDamage.
Graph is shown using matplotlib library.
- Parameters:
system (System) – System object used in the simulation.
machines (list) – List of Machines whose damage data will be plotted. One example of a Machine that tracks damage is MachineWithDamage.
subplot (matplotlib.axes.Axes, default = None) – Optional subplot to graph the data on. If None then a new figure will be created and shown.
- simprocesd.utils.simulation_info_utils.plot_resources(system, resources, subplot=None, hide_max=False)
Show a graph of active resource usage over time.
Graph is shown using matplotlib library.
- Parameters:
system (System) – System object used in the simulation.
resources (list) – List of resource names for resources whose data will be plotted.
subplot (matplotlib.axes.Axes, default = None) – Optional subplot to graph the data on. If None then a new figure will be created and shown.
- simprocesd.utils.simulation_info_utils.plot_throughput(system, machines, subplot=None)
Show a graph of cumulative mean throughput over time.
Cumulative throughput means at time=100 the graph will show the mean throughput between time 0 and 100.
Graph is shown using matplotlib library.
- Parameters:
system (System) – System object used in the simulation.
machines (list) – List of Machines whose data will be plotted.
subplot (matplotlib.axes.Axes, default = None) – Optional subplot to graph the data on. If None then a new figure will be created and shown.
- simprocesd.utils.simulation_info_utils.plot_value(assets, subplot=None)
Show a graph of value over time for any assets.
Graph is shown using matplotlib library.
- Parameters:
assets (list) – List of Assets whose data will be plotted.
subplot (matplotlib.axes.Axes, default = None) – Optional subplot to graph the data on. If None then a new figure will be created and shown.
- simprocesd.utils.simulation_info_utils.print_finished_work_order_counts(system)
Print which machines had work orders completed on them and how many of those work orders there were.
- Parameters:
system (System) – System object used in the simulation.
- simprocesd.utils.simulation_info_utils.print_produced_parts_and_average_quality(system, machines)
Print the number of Parts produced by each machine in the list and the Part’s average quality.
- Parameters:
system (System) – System object used in the simulation.
machines (list) – List of Machines whose data will be printed.
- simprocesd.utils.simulation_info_utils.simple_plot(x, y, title='', xlabel='', ylabel='', data_label=None, fmt=None, subplot=None)
Show a graph with a single plot from the provided data.
- Parameters:
x (list) – List of x values.
y (list) – List of y values, must be same length as <x>.
title (str, optional) – Graph title.
data_label – Label for the data being graphed.
fmt (string, default = None) – Format string that defines the appearance of the line. See matplotlib.pyplot.plot documentation for more information.
subplot (matplotlib.axes.Axes, default = None) – Optional subplot to graph the data on. If None then a new figure will be created and shown.
simprocesd.utils.utils module
- simprocesd.utils.utils.assert_callable(obj, none_allowed=False, message=None)
Check if an object appears callable.
The check is done using the built-in ‘callable()’ function. In some cases it is possible the function not to raise an error even if <obj> cannot be called like a function.
Returns immediately if not in debug mode.
- Parameters:
obj (object) – Object that will be checked.
none_allowed (bool, default=False) – If the value of None is allowed.
message (str, optional) – Error message if object is not callable.
- Raises:
TypeError – If object is not callable.
- simprocesd.utils.utils.assert_is_instance(obj, class_type, message=None)
Check if an object is an instance of a specific class type.
Returns immediately if not in debug mode.
- Parameters:
obj (object) – Object that will be checked.
class_type (type) – Class type that the object needs to be or a tuple of all acceptable class types.
message (str, optional) – Error message if object is not an instance of <class_type>.
- Raises:
TypeError – If <obj> is not an instance of <class_type>
- simprocesd.utils.utils.load_object(file_path)
Load an object from a file that was created using save_object().
See save_object() for information on how objects are stored.
Warning
Loaded object could execute arbitrary code when it is loaded. Recommended to only load object from files you created or ones from a source with a high degree of trust.
- Parameters:
file_path (str) – Relative or absolute path to the file to load.
- simprocesd.utils.utils.save_list_to_csv(filename, data_list)
Save a list or table as a CSV file.
Each list entry will occupy one row and if the list entry is a list or a tuple then the entry’s elements will be split into columns.
Example:in: data_list = [ [1,2], [3,4,5] ]file out: Row 1 = 1,2Row 2 = 3,4,5- Parameters:
filename (str) – Relative or absolute path of where to store the CSV file.
data_list (list) – Data to be stored, can be a 1 or 2 dimensional list.
- simprocesd.utils.utils.save_object(obj, file_path, override_file=False)
Serialize, compress, and save an object as a file.
Uses Dill module to serialize the object. https://pypi.org/project/dill/
Serialized data is compresses using lzma module.
- Parameters:
obj (object) – Object to be serialized and stored.
file_path (str) – Relative or absolute path of where to store the object.
override_file (bool, default=False) – If True then any existing file at <file_path> will be overwritten.
- Raises:
FileExistsError – If a file at <file_path> already exists and <override_file> is set to False.