-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
69 lines (39 loc) · 1.88 KB
/
test.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
from m4a_classes.models import ancillaryService, VirtualPowerPlant, FleetOperator, electricityMarket
from m4a_optimizer.setCS import setCS
from m4a_optimizer.plotResults import plotResults
from m4a_optimizer.sortresults import sortResults
from pathlib import Path
import os
import pandas as pd
import matplotlib.pyplot as plt
path = Path(os.getcwd()).parent
ancillarydata = os.path.join(path, 'ancillaryservicevalues.xlsx')
servicelist = ['freq_control', 'redispatch']
vpp = VirtualPowerPlant()
service = ancillaryService()
fp = FleetOperator()
#fp.demandmat2excel(r"C:\Users\Usuario\Documents\Trabajo\TU Berlin\E-mobility flexiblity potential\iLMS2VPP_Depot.mat", 'bus1')
inputs = fp.createFleetObjects()
em = electricityMarket()
afrrfile = 'Automatic_Frequency_Restoration_Reserve_202201010000_202201082359' + '.csv'
afrrpath = [os.path.join(path, 'mob4anci', 'data', afrrfile)]
em.setBalancingMarketAttributes()
#em.storeReserveMarketData(afrrpath)
cs = setCS()
results, fleet, em = fp.setValuesForOptimization()
for res in results:
i = results.index(res)
cpx_sol = res.solution.get_values()
cpx_var = res.variables.get_names()
timeseries = sortResults(cs, cpx_sol, cpx_var)
plotResults(cs, timeseries, em.price_em, fleet)
em.setMarketAttributes('price_em')
freqcontrol = service.getFreqcontrolObject()
redispatch = service.getRedispatchObject()
writecols = list(pd.read_excel(path/'outputvalues.xlsx', 'output').columns)[2:] #get columns in which data is to be written in outputvalues. remove 2 initial elements
for service in servicelist:
for key in inputs:
if service == 'freq_control':
checks = fp.compareValues(inputs[key], freqcontrol, service, writecols)
elif service == 'redispatch':
checks = fp.compareValues(inputs[key], redispatch, service, writecols)