HW11-solutions
.html
keyboard_arrow_up
School
University of Texas *
*We aren’t endorsed by this school
Course
230
Subject
Industrial Engineering
Date
Apr 3, 2024
Type
html
Pages
7
Uploaded by sjobs3121
Homework 11 for ISEN 355 (System Simulation)
¶
(C) 2023 David Eckman
Due Date: Upload to Canvas by 9:00pm (CDT) on Friday, April 28.
In [ ]:
# Import some useful Python packages.
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats
This assignment involves a simulation model of a system for producing and selling iron ore. You will need to import ironore.py
. The following code provides a function simulate()
that runs multiple replications of the model and returns three responses. You will need to use this function throughout the assignment.
In [ ]:
#from mrg32k3a import MRG32k3a
from ironore import replicate
def simulate(n_reps):
"""
Simulate n_reps replications of the model.
"""
# Initialize output vectors
all_total_profit = np.zeros(n_reps)
all_frac_producing = np.zeros(n_reps)
all_mean_stock = np.zeros(n_reps)
all_daily_stock = np.zeros((n_reps, 365)) # For 1 year.
for rep in range(n_reps):
# Run a replication
all_total_profit[rep], all_frac_producing[rep], all_mean_stock[rep], all_daily_stock[rep, :] = replicate()
return all_total_profit, all_frac_producing, all_mean_stock, all_daily_stock
The file ironore.py
contains a model that simulates multiple periods of the production and sales of iron ore from the perspective of a single producer. Iron ore is traded on a spot market where the price process is regarded as exogenous (i.e., the producer doesn't set the price) and stochastically varying over time. Because of high demand for iron ore in the market, any quantity of ore the producer wishes to sell can be sold that day at the current market rate.
The producer makes a number of decisions regarding their operations: In any period, the
producer can choose to produce more ore, sell all of their inventory, or do nothing. To simplify the policy, suppose there are three threshold prices. When the price drops below
some low threshold, the producer ceases production. When the price increases above another higher threshold, the producer commences production. When the price increases above an even higher threshold, the producer sells all current stock. There is also an inventory level at or above which the producer ceases production.
The producer has a certain maximum capacity for storing inventory and is subject to holding costs, production costs, and daily production limits.
An individual replication of the simulation model returns four outputs:
1. The total profit over the time horizon; 2. The fraction of days spent producing iron ore;
3. The average daily stock over the time horizon; and 4. A list of the daily stock over the time horizon. See the code for more details. There is no need to change the model's code for this assignment.
Problem 1. (36 points)
¶
For this question, run 100 replications of the simulation.
(a) (9 points)
For each of the first three outputs (total profit, fraction of days producing iron, and average daily stock), plot a histogram with 10 bins using plt.hist()
and a boxplot using plot.boxplot()
. Comment on the shape of the plots.
In [ ]:
# Run 100 replications
num_reps = 100
total_profit, frac_prod, avg_daily_stock, _ = simulate(num_reps)
fig, axs = plt.subplots(3, 2, figsize = (18,12))
fig.tight_layout(pad=3.0)
axs[0,0].hist(total_profit, bins = 10)
axs[0,0].set_title('Profit Histogram')
axs[0,0].set_xlabel('Total Profit ($)')
axs[0,0].set_ylabel('Frequency')
axs[0,1].boxplot(total_profit)
axs[0,1].set_title('Total Profit Box-Plot')
axs[1,0].hist(frac_prod, bins = 10)
axs[1,0].set_title('Fraction of Days with Production Histogram')
axs[1,0].set_xlabel('Fraction of Days')
axs[0,0].set_ylabel('Frequency')
axs[1,1].boxplot(frac_prod)
axs[1,1].set_title('Fraction of Days with Production Box-Plot')
axs[2,0].hist(avg_daily_stock, bins = 10)
axs[2,0].set_title('Average Daily Stock Histogram')
axs[2,0].set_xlabel('Average Daily Stock (Units)')
axs[2,0].set_ylabel('Frequency')
axs[2,1].boxplot(avg_daily_stock)
axs[2,1].set_title('Average Daily Stock Box-Plot')
plt.show()
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help