forked from maxvanatta/Equitable_Retirement_SMRs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
123 lines (102 loc) · 4.33 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# -*- coding: utf-8 -*-
"""
Created on Tue May 11 09:03:40 2021
@author: bhavrathod
"""
from EquitableRetirement import EquitableRetirement
import CoalPlants
import RenewableSites
from getReEFs import batchReEFs
import numpy as np
import pandas as pd
def test_cplex(alp,bet,gam,numYears,solFileName,winFileName,region,CONEF,REOMEF,MAXCAP,SITEMAXCAP,reSites,plants, SITEMINCAP,SMR_bool):
''' use sample data to test runtime and large-scale functionality of formulation '''
print('TEST_CPLEX:')
print('\t','getting data...')
# coal plants
### Add states here as needed
# plants = CoalPlants.getCoalPlants(region)
# plants['HISTGEN'] = CoalPlants.getPlantGeneration(plants['Plant Code'])
# plants['HD'] = CoalPlants.getMarginalHealthCosts(plants['Plant Code'])
# plants.dropna(inplace=True)
# renewables
# reSites = RenewableSites.getAnnualCF(solFileName,winFileName)
# costs
if SMR_bool == True:
SMR_num = plants.index.size
else:
SMR_num = 0
RE_num = len(reSites) - SMR_num
costs = { 'RECAPEX' : np.array([1600000]*(RE_num//2) + [1700000]*(RE_num//2) + [2526000]*(SMR_num)),
'REFOPEX' : np.array([19000]*(RE_num//2) + [43000]*(RE_num//2) + [25000]*(SMR_num)),
'REVOPEX' : np.array([0]*(RE_num//2) + [0]*(RE_num//2) + [9.46]*(SMR_num)),
'COALVOPEX' : np.ones(len(plants))*(4.+11*2.2),
'COALFOPEX' : np.ones(len(plants))*40000.
}
# site limits
limits = { 'MAXCAP' : MAXCAP,
'SITEMINCAP' : SITEMINCAP,
'SITEMAXCAP' : SITEMAXCAP,
'MAXSITES' : np.ones(len(plants))*10
}#
# employment factors
# ef = { 'RETEF' : np.ones(len(plants))*.25,
# 'CONEF' : np.ones((len(reSites),numYears))*.25,
# 'COALOMEF' : np.ones(len(plants)),
# 'REOMEF' : np.ones((len(reSites),numYears))*.25
# }
ef = { 'RETEF' : np.ones(len(plants))*1.65,
'CONEF' : np.reshape(CONEF,(len(reSites),numYears),order='F'),
'COALOMEF' : np.ones(len(plants))* (plants['Coal Capacity (MW)'].values*0.14/plants['HISTGEN'].values),
'REOMEF' : np.reshape(REOMEF,(len(reSites),numYears),order='F')
}
### BUILD MODEL
m = EquitableRetirement()
m.Y = np.arange(numYears)+2020
m.R = reSites.index.values
m.C = plants.index.values
m.Params.HISTGEN = plants['HISTGEN'].values
m.Params.COALCAP = plants['Coal Capacity (MW)'].values
m.Params.CF = reSites['Annual CF'].values
m.Params.RECAPEX = costs['RECAPEX']
m.Params.REFOPEX = costs['REFOPEX']
m.Params.REVOPEX = costs['REVOPEX']
m.Params.COALVOPEX = costs['COALVOPEX']
m.Params.COALFOPEX = costs['COALFOPEX']
m.Params.MAXCAP = limits['MAXCAP']
m.Params.SITEMINCAP = limits['SITEMINCAP']
m.Params.SITEMAXCAP = limits['SITEMAXCAP']
m.Params.MAXSITES = limits['MAXSITES']
m.Params.HD = plants['HD'].values
m.Params.RETEF = ef['RETEF']
m.Params.CONEF = ef['CONEF']
m.Params.COALOMEF = ef['COALOMEF']
m.Params.REOMEF = ef['REOMEF']
'''
### CHECK DIMS
print('\t','Y\t',len(m.Y))
print('\t','R\t',len(m.R))
print('\t','C\t',len(m.C))
print('\t','HISTGEN\t',m.Params.HISTGEN.shape)
print('\t','COALCAP\t',m.Params.COALCAP.shape)
print('\t','CF\t',m.Params.CF.shape)
print('\t','RECAPEX\t',m.Params.RECAPEX.shape)
print('\t','REFOPEX\t',m.Params.REFOPEX.shape)
print('\t','REVOPEX\t',m.Params.REVOPEX.shape)
print('\t','COALVOPEX\t',m.Params.COALVOPEX.shape)
print('\t','COALFOPEX\t',m.Params.COALFOPEX.shape)
print('\t','MAXCAP\t',m.Params.MAXCAP.shape)
print('\t','SITEMAXCAP\t',m.Params.SITEMAXCAP.shape)
print('\t','SITEMINCAP\t',m.Params.SITEMINCAP.shape)
print('\t','MAXSITES\t',m.Params.MAXSITES.shape)
print('\t','HD\t',m.Params.HD.shape)
print('\t','RETEF\t',m.Params.RETEF.shape)
print('\t','CONEF\t',m.Params.CONEF.shape)
print('\t','COALOMEF\t',m.Params.COALOMEF.shape)
print('\t','REOMEF\t',m.Params.REOMEF.shape)
print('\t','')
'''
print('\t','solving...')
m.solve(alp,bet,gam,solver='cplex')
print('\t',m.Output.Z)
return m.Output, plants, m