supplychainpy.simulations package¶
Submodules¶
supplychainpy.simulations.monte_carlo module¶
-
class
supplychainpy.simulations.monte_carlo.
SetupMonteCarlo
(analysed_orders: list, period: str = 'months', period_length: int = 12)¶ Bases:
object
Create a monte carlo simulation for inventory analysis.
-
build_window
(random_normal_demand: list, period_length: int = 0, holding_cost_percentage: decimal.Decimal = 0.48, shortage_cost_percentage: decimal.Decimal = 0.3) → dict¶ Builds the simulation window for opening stock, demand, closing stock, backlog, holding cost and shortages.
The window represents a fixed time frame, supplied by the user. The window is then run several times to generate probabilities for example the probability of stocking out during the period specified or the probability that the final closing stock will be negative. The results will indicate the accuracy of the analytical model used to calculate the safety stock etc, based on a few assumptions.
Parameters: - random_normal_demand (list) – A list of random demand normally distributed.
- period_length (int) – length of window e.g. 12 weeks for a quarter etc.
- holding_cost_percentage (Decimal) – The percentage of unit cost to associate with holding cost,
- shortage_cost_percentage (Decimal) – The percentage of unit cost to associate with shortage cost,
Returns: - The build_window returns a dictionary of lists for opening_stock, demand, delivery,closing stock,
backlog, holding cost, shortage cost.
Return type: dict
Raises: ValueError
– The period_length is currently {} and the actual length of the demand is {}. Please make sure that the two values are equal”.format(period_length, len(random_normal_demand[0][sku.sku_id]))
-
generate_normal_random_distribution
(period_length: int) → list¶ Generates the random demand for a given sku.
For each sku a set of random demands are calculated based on the normal distribution of demand for this product.
Parameters: period_length (int) – length of window e.g. 12 weeks for a quarter etc. Returns: A list of randomly generated demand. Return type: list Raises: ValueError
-
normal_random_distribution
¶
-
supplychainpy.simulations.monte_carlo_frame module¶
-
class
supplychainpy.simulations.monte_carlo_frame.
BuildFrame
(**kwargs)¶ Bases:
supplychainpy.simulations.monte_carlo_frame.MainFrame
Shares the shared frame attribute with all instances to be used when using multi-threading for
-
class
supplychainpy.simulations.monte_carlo_frame.
MainFrame
¶ Bases:
object
Borg class making shared frame global
supplychainpy.simulations.sim_summary module¶
-
supplychainpy.simulations.sim_summary.
average_items
()¶
-
supplychainpy.simulations.sim_summary.
closing_stockout_percentage
()¶
-
supplychainpy.simulations.sim_summary.
frame
()¶
-
supplychainpy.simulations.sim_summary.
optimise_service_level
()¶ Optimises the safety stock for declared service level.
Identifies which skus under performed (experiencing a service level lower than expected) after simulating transactions over a specific period. The safety stock for these items are increased and the analysis is monte carlo is run again.
Parameters: - frame_summary (list) – window summary for each period multiplied by the number of runs.
- orders_analysis (list) – prior analysis of orders data.
- service_level (double) – required service level as a percentage.
- runs (int) – number of runs from previous
- percentage_increase (double) – the percentage increase required
Returns: - Updated orders analysis with new saftey stock values based optimised from the simulation. The initial values
from the analytical model.
Return type: list
-
supplychainpy.simulations.sim_summary.
optimise_sim
()¶
-
supplychainpy.simulations.sim_summary.
optimum_std
()¶
-
supplychainpy.simulations.sim_summary.
summarize_monte_carlo
()¶ summarises the monte carlo transaction summary
Generates random distribution for demand over period specified and creates a simulation window for opening_stock, demand, closing_stock, delivery and backlog for each sku in the data set. Creates a transaction summary window for inventory movements.
Parameters: - simulation_frame (list) – The path to the file containing two columns of data, 1 period and 1 data-point per sku.
- period_length (int) – The number of periods define the simulation window e.g. 12 weeks, months etc.
Returns: A list containing the transaction summary for each period.
Return type: list
supplychainpy.simulations.simulation_frame_summary module¶
-
class
supplychainpy.simulations.simulation_frame_summary.
MonteCarloFrameSummary
¶ Bases:
object
-
static
closing_stockout_percentage
(closing_stock: list, period_length: int)¶ Calculates the percentage of stock out that occurred during the period specified.
Parameters: - period_length (int) – length of window e.g. 12 weeks for a quarter etc.
- closing_stock (list) – list of closing stock values for a given sku over the same time frame as the period_length
Returns: Percentage of final closing stock values that result in stock out and backlog.
Return type: float
Raises: ValueError
– The number of stock positions and the period length must match exactly.
-
static
supplychainpy.simulations.simulation_gui module¶
supplychainpy.simulations.simulation_summary module¶
supplychainpy.simulations.simulation_window module¶
-
class
supplychainpy.simulations.simulation_window.
MonteCarloWindow
¶ Bases:
object
Attributes for monte carlo calculations, for building the simulation window
-
backlog
¶
-
backlog_at_po_placement
¶
-
closing_stock
¶
-
demand
¶
-
holding_cost
¶
-
index
¶
-
lead_time
¶
-
opening_stock
¶
-
po_number_raised
¶
-
po_number_received
¶
-
po_raised_flag
¶
-
position
¶
-
previous_backlog
¶
-
purchase_order_raised_qty
¶
-
purchase_order_receipt_qty
¶
-
quantity_sold
¶
-
revenue
¶
-
shortage_cost
¶
-
shortage_units
¶
-
sku_id
¶
-
sold
¶
-