Simantha Reference

Manufacturing Objects

The following classes make up the core manufacturing objects provided by Simantha. After intatiating the objects of a system, the define_routing method must be called for each object. The additional methods listed below are provided for extending the behavior of these objects in various ways.

Warning

Currently there is no verification of system routing validity. A system with an invalid routing may result in unexpected behavior with raising an error or warning. For instance, a buffer with no downstream machine may become full and cause a “dead end” in the system of which the user will not be notified.

simantha.Source class

class simantha.Source(name='Source', interarrival_time=None, part_type=<class 'simantha.Part.Part'>)

Introduces unprocessed parts to the system. By default, machines downstream of a source are never starved.

Parameters
  • name (str) – Name of the source.

  • interarrival_time (None or simantha.simulation.Distribution) – Time between arriving parts. If None, there is no delay between arrivals.

  • part_type (simantha.Part) – Class of part objects produced by the source. A part class that inherits simantha.Part can be used to modify part atrributes and behavior.

define_routing(downstream=[])

Specifies objects downstream of the source. The downstream argument should be a list of machines that retrieve parts from the source.

Warning

It is currently assumed that machines downstream of a source object are never starved. Intermittent part arrivals have not been thoroughly tested.

simantha.Machine class

class simantha.Machine(name=None, cycle_time=1, selection_priority=1, degradation_matrix=[[1, 0], [0, 1]], cbm_threshold=None, planned_failure=None, pm_distribution=5, cm_distribution=10, initial_health=0, initial_remaining_process=None)

Machine that processes parts with optional periodic degradation and failure.

Parameters
  • name (str) – Name of the machine.

  • cycle_time (int or simantha.Distribution) – Cycle time in time units for each part processed by this machine.

  • degradation_matrix (square array) – Markovian degradation transition matrix.

  • cbm_threshold (int) – Threshold for condition-based preventive maintenance.

  • pm_distribution (int or simantha.Distribution) – Time to repair distribution for preventive maintenance.

  • cm_distribution (int or simantha.Distribution) – Time to repair distribution for corrective maintenance.

define_routing(upstream=[], downstream=[])

Specifies the upstream and downstream objects of the machine. The upstream and downstream arguments should be lists containing source, buffer, or sink objects.

Warning

Machines should be adjacent to sources, buffers, or sinks. Behavior of adjacent machines with no intermediate buffer is not tested and may result in errors or unexpected results.

The following methods may be overridden by extensions of the Machine class.

initialize_addon_process()

Called when the machine is initialized at the beginning of each simulation run.

output_addon_process(part)

Called before the processed part is transfered to a downstream buffer or sink.

repair_addon_process()

Called once a machine is restored after preventive or corrective maintenance.

The following attributes are used to indicate the state of a machine.

has_part

True if the machine is holding a part, False otherwise. Simantha uses the block after service convention wherein a machine will hold a part after processing until space for the processed part is available.

Type

bool

under_repair

True if the machine is undergoing maintenance, False otherwise.

Type

bool

in_queue

True if the machine has requested unfulfilled (preventive or corrective) maintenance, False otherwise.

Type

bool

During simulation, machines collect the following data that are available as attributes of a Machine instance.

parts_made

The number of parts successfully processed and relinquished by the machine.

Type

int

downtime

The number of time units the machine was either under maintenance or failed.

Type

int

production_data

Production information of the machine. production_data['time'] stores the time at which each part exited the machine while production_data['production'] stores the cumulative number of parts produced by the machine at the corresponding time.

Type

dict

health_data

A dictionary storing the health infomation of the machine with keys time and health and values corresponding to the time of each health state transition and the resulting health of the machine. Machines that are not subject to degradation do not undergo health state transitions and remain in perfect health for the duration of the simulation.

Type

dict

maintenance_data

Serves as a maintenance log for the machine. Key 'event' gives a list of maintenance events which can include 'enter queue', 'failure', 'begin maintenance', or 'restore', while key 'time' gives the simulation time of each event.

Type

dict

simantha.Buffer class

class simantha.Buffer(name='Buffer', capacity=inf, initial_level=0)

Buffers store parts that are waiting for processing at a downstream machine.

Parameters
  • name (str) – Name of the buffer.

  • capacity (int) – Maximum number of parts that the buffer can hold.

define_routing(upstream=[], downstream=[])

Specifies the upstream and downstream objects of the buffer.

The following attributes are used to indicate the state of a buffer.

level

Number of parts in the buffer.

Type

int

contents

List of part objects in the buffer.

Type

list

During simulation, buffers collect the following data that are available as attributes of a Buffer instance.

level_data

A dictionary with keys 'time' for the simulation times at which the level of the buffer changes and 'level' for the corresponding buffer level.

Type

dict

simantha.Sink class

class simantha.Sink(name='Sink', initial_level=0, collect_parts=False)

Sinks collect finished parts as they exit the system.

Parameters
  • name (str) – Name of the sink.

  • collect_parts (bool) – If True, the sink will maintain a list of the part objects it collects.

define_routing(upstream=[])

Specifies the machines upstream of a sink.

level

The number of parts collected by the sink.

Type

int

contents

If collect_parts = True, a list of collected part objects.

Type

list

Maintainer

simantha.Maintainer class

class simantha.Maintainer(name='maintainer', capacity=inf, machines=None)

A maintainer is responsible for repairing machines that request maintenance according to some preventive maintenance policy or upon the occurrence of failure.

Parameters
  • name (str) – Name of the maintainer.

  • capacity (int) – The maximum number of machines that the maintainer may repair simultaneously.

  • machines (list or None) – A list of machine objects that the maintainer is able to repair. If None, the maintainer may repair any machine in the system.

The following attributes are used to indicate the state of the maintainer.

utilization

The number of machines currently being repaired by the maintainer.

Type

int

The following methods may be overridden by extensions of the Maintainer class.

choose_maintenance_action(queue)

Accepts a queue as a list of machines with unfufilled maintenance requests. Should return a single machine from the queue to repair next. By default, the maintainer will choose the machine with the earliest request for maintenance (equivalent to a first-in, first-out policy).

System

simantha.System class

A System object contains the configured manufacturing objects.

class simantha.System(objects=[], maintainer=None)

A System object contains configured manufacturing objects and is used to run the simulation.

Parameters
  • objects (list) – A list of configured manufacturing objects including sources, machines, buffers, and sinks.

  • maintainer (None or simantha.Maintainer) – A user-defined maintainer or, by default, a maintainer with infinite capacity.

simulate(warm_up_time=0, simulation_time=0, verbose=True, trace=False, collect_data=True)

The primary method for simulating a system.

Parameters
  • warm_up_time (int) – The duration of the simulation warm up time. No data is collected during the warm up period.

  • simulation_time (int) – The duration of the simulation.

  • verbose (bool) – If True, prints a summary upon completion of the simulation run.

  • collect_data (bool) – If True, objects in the system will collect their respective production and maintenance data. If False, this data will not be stored which may be useful for very long simulations where memory becomes an issue.

iterate_simulation(replications, warm_up_time=0, simulation_time=0, store_system_state=False, verbose=True, jobs=1, seedseed=0)

Conduct several simulation replications of the system with the option to do so in parallel.

Parameters
  • replications (int) – The number of simulation replications.

  • warm_up_time (int) – The simulation warm up time for each replication.

  • simulation_time (int) – The simulation duration for each replication.

  • store_system_state (bool) – If True, each replication will return a copy of the simantha.System object at the end of its simulation run.

  • verbose (bool) – If True, prints a summary of the simulation replications.

  • jobs (int) – The number of jobs to run in parallel.

Returns

A list of tuples containing the results of each replication.

Return type

list

Simulation

The simulation module provides the discrete event simulation logic and random number generation for Simantha.

simantha.simulation module

class simantha.simulation.Event(time, location, action, source='', priority=0, status='')

Simulation event class. Should be extended when implementing custom simulation events.

Parameters
  • time (int) – Simulation time at which the event is to be executed.

  • location – The object at which the event is to take place.

  • action – The object method to be called upon execution of the event.

  • source (str) – A description of the event or object that scheduled this event.

  • priority (float) – The event execution priority.

get_action_priority()

Should return a priority value that correctly places this event in the event priority order.

class simantha.simulation.Distribution(distribution)

A class for representing random probability distributions. Should return an integer value when sampled.

Parameters

distribution (int or dict) – If an int is passed, the distribution will return a constant value when sampled. Otherwise, the built-in distributions are discrete uniform, specified by passing {'uniform': [a, b]} to the distribution object, and geometric, specified via {'geometric': p}.

sample()

Returns a single integer value from the specified distribution. This method should be overridden by children of the Distribution class.

Utilities

simantha.utils module

The utils module provides convenient utility functions and useful constants. Although the constants are given in minutes, a single simulation time unit can theoretically represent any duration of time.

simantha.utils.generate_degradation_matrix(p, h_max)

Generate an upper triangular degradation transition matrix.

Parameters
  • p (float) – The probability of degrading by one unit at each time step.

  • h_max (int) – The index of the failed state.

Returns

A (h_max + 1) \(\times\) (h_max + 1) degradation transition matrix.

Return type

list of lists

simantha.utils.DAY = 1440

One day in minutes.

simantha.utils.WEEK = 10080

One week in minutes.

simantha.utils.MONTH = 43200

Thirty days in minutes.

simantha.utils.YEAR = 525600

One year in minutes.