Assignment - 2
The Electrical Power Generation problem that his assignment is based on is explainedhere
Please read the problem description in the notebook and answer the following questions.
Note: The conditions provided in the questions are for each question and do not carry over between questions.
#Toinstallgurobipyuncommentfollowingcommandthisworksoncolab,#otherwisefollowtheinstruction%pipinstallgurobipyimportpandasaspdimportgurobipyasgpfromgurobipyimportGRBimportmatplotlib.pyplotaspltimportnumpyasnp
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/ Collecting gurobipy Downloading gurobipy-9.5.2-cp37-cp37m-manylinux2014_x86_64.whl (11.5 MB) K |████████████████████████████████| 11.5 MB 26.5 MB/s ?25hInstalling collected packages: gurobipy Successfully installed gurobipy-9.5.2
Question-1: Assumptions:
- Modify the number of generators that are assumed to be on at the first period to zero for all generators. Compare the results and explain them.
- Modify the number of generators that are assumed to be on at the first period to 12 for type 0, 2 for type 1, and zero for type 2. Compare the results with the zero number and five number of all types of generators.
Question-2: Reliability trade-offs
In the original formulation the selected generators must be able to cope with a %15 excess in demand. The requirements are changed and the demands have to be satisfied by 15, 25, 5, 40, and 10 percent more than the predicted demand for each period, respectively. Solve the optimization problem with these new requirements and plot the demand vs time and the max_power of the running generators.
Then, assume there is a real_demand that is a Guassian random variable that has a mean value equal to the previously given demand and a standard deviation of 1500. Plot the real demand vs time after taking one sample from the Gaussian distribution for each time period and also plot the max_power of running generators on the same plot.
Question-3: More constraints:
Solve the questions with the following additional constraints:
If X number of generators type-1 are on, at least X/3 number of generators Type-2 must be on; and at least 4 generators of any type at each period of time have to be started up.
Question-4: Gradual changes in demands
What if the demands change gradually every hour with the following models: Linearly in period 1 from 1500 to 3000, exponentially in period 2 from 3000 to 2000, again exponentially in period 3, from 2000 to 4500 then linearly in period 4 from 4500 to 2000 and finally a sudden drop at the end of period 5 from 2000 to 1500
First, plot the time vs demand chart. Then, solve the optimization problem with the new demands reported and determine all the optimum times the generators of different types have to be turned on and shut down. Plot the chart for time vs the number of generators of each type.
#LINEARdefline(x,A):return(A[3]-A[2])/(A[1]-A[0])*(x-A[0])+A[2]#PERIOD2defexp_1(x):return6750*np.exp(-0.1352*x)#PERIOD3defexp_2(x):return592.5926*np.exp(0.1352*x)
#discritizationto30mind=0.5time=np.arange(0,24,d)period_hours=[6,3,6,3,6]start_time=[0,6,9,15,18,0]start_point=[1500,3000,2000,4500,2000]j=0tp=0y=[]fortintime:ift==tp:j+=1tp=start_time[j]ifj==1:y.append(line(t,[start_time[0],start_time[1],start_point[0],start_point[1]]))ifj==2:y.append(exp_1(t))ifj==3:y.append(exp_2(t))ifj==4:y.append(line(t,[start_time[3],start_time[4],start_point[3],start_point[4]]))ifj==5orj==0:y.append(2000)plt.plot(time,y)
[]