Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# In this simulation the library numpy is used and it is named it np # We will also use the math library

# In this simulation the library numpy is used and it is named it "np"
# We will also use the math library and we will name it math
import numpy as np
import math as math
# The seed below initializes the random generator to always obtain the same random inputs.
# DO NOT CHANGE THIS VALUE AND RERUN THIS CELL EVERYTIME YOU RUN THE PROGRAM.
np.random.seed(3500)
# Variables are defined in this cell
Cap =6 # Capacity of the reservoir
hours =24 # 24 hours in one day
days =365*100 # number of days in 100 years
nHours =0 # Counter for number of hours
inflow =2.0 # Inflow of treated water into the reservoir every hour in ML
offDem =0.45 # Offpeak demand
mean_pDem =2.6 # Mean of the demand during peak hours
cov_pDem =0.4 # Coefficient of variation of demand during peak hours
# Because the peak demand log-normally distributed the mean and standard deviation of the ln(pDem) must be obtained
Psi = math.sqrt(math.log(1+ cov_pDem**2))
Lambda = math.log(mean_pDem)- Psi**2/2
Dem = np.empty(hours*days)
volume = Cap # initialise the volume equal to the capacity
nFail =0 # counter of falures
pFail =0 # probability of failure
for day in range(days):
for hour in range(hours):
# Define peak demand period
# If peak demand randomly sample values of ln(pDem) from the lognormal distribution and store them in Dem
# If offpeak demand Dem[]=0.45
if hour>=7 and hour=23:
Dem[nHours]= math.exp(np.random.normal(Lambda,Psi))
else:
Dem[nHours]= offDem
# Perform water balance in reservoir
volume = volume + inflow - Dem[nHours]
if volume >= Cap:
volume=Cap
elif volume =0:
volume =0
if hour>=7 and hour=23:
nFail = nFail +1
nHours = nHours +1
# calculate and print the probability of damage DURING PEAK HOURS
pFail = nFail/((hours-8)*days)
print("The probability of failing to supply the demand is ", pFail). Answer the question in the image please.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

software analysis of the salaries

Answered: 1 week ago