Example #1
0
    time.sleep(15)  ###

    # get L and rho
    [L, rho,
     curtailPV] = contractADMM.functions.getOptimizationParameters().call()
    print('Optimization parameters received')
    L = np.array(L)
    L = L / 10**6
    rho = rho / 10**6
    if curtailPV == 1:  # sum(q_i)<0 <=> PVproduction > PVimported ==> curtailment of PV, no diminution of PV import
        L[length:2 * length] = np.minimum(L[length:2 * length], 0)

    # optimization of profile
    EV1.optimization(startTime, endTime, timeStep, price_imp, price_PV,
                     price_B, rho, L, yPVforecast)
    profileToSend = tl.toListInt(EV1.optimizedProfile)
    tx_hash = contractADMM.functions.sendOptimizedProfile(
        profileToSend).transact()
    tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash)
    gasSpend += tx_receipt.gasUsed
    print('Optimized profile send')

    # wait for global results
    l = 0
    while l != 1:
        #while l!=iterations:
        event_filter = contractADMM.events.EndIteration.createFilter(
            fromBlock='latest')
        #event_filter = contractADMM.events.EndIteration.createFilter(fromBlock=0)
        eventlist = event_filter.get_all_entries()
        l = len(eventlist)
Example #2
0
if startTime.month == 6:
    month = 'juin'
elif startTime.month == 12:
    month = 'decembre'

# get price function
fname = '../Data_' + month + '19/price_' + month + '19.csv'
price_imp = pd.read_csv(fname,
                        sep=';',
                        names=['timeVector', 'price'],
                        index_col=0,
                        squeeze=True,
                        parse_dates=True)
price_imp = price_imp.asfreq(freq=str(timeStep) + 'T', method='ffill')
price_imp = 1 / 1000 * price_imp[startTime:endTime]  # from €/Mwh to €/kWh
price_imp = tl.toListInt(price_imp)

price_PV = LCOE_PV * np.ones(length)
price_B = LCOS_B * np.ones(length)

# call setTimeInterval
startTime = int(startTime.timestamp())
endTime = int(endTime.timestamp())
timeStep = timeStep * 60
tx_hash = contractADMM.functions.setTimeInterval(startTime, endTime,
                                                 timeStep).transact()
tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash)
gasSpend += tx_receipt.gasUsed
print('Set time')

# call setPriceImp and setPriceLocal
Example #3
0
                                                   beta2,
                                                   parametersB,
                                                   timestepM,
                                                   startTimeM,
                                                   endTimeM,
                                                   price_PV_M,
                                                   price_b_M,
                                                   price_imp_M,
                                                   rho_M,
                                                   L_M,
                                                   X_k_M,
                                                   p_forecast_PV_total_M,
                                                   nargout=2)
    X_storage = np.asarray(X_storage)
    Storage.optimizedProfile = X_storage[:, 0]
    profileToSend = tl.toListInt(Storage.optimizedProfile)
    tx_hash = contractADMM.functions.sendOptimizedProfile(
        profileToSend).transact()
    tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash)
    gasSpend += tx_receipt.gasUsed
    print('Optimized profile send')

    #    # optimization of profile
    #    Storage.optimization(startTime, endTime, timeStep, price_imp, price_PV, price_B, rho, L, yPVforecast)
    #    profileToSend = tl.toListInt(Storage.optimizedProfile)
    #    tx_hash = contractADMM.functions.sendOptimizedProfile(profileToSend).transact()
    #    tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash)
    #    gasSpend += tx_receipt.gasUsed
    #    print('Optimized profile send')

    # wait for global results
Example #4
0
price_B = pd.Series(data=coeff_priceB * np.ones(length), index=timeVector)

# get forecast_consumer_HEI profile
fnamePV = '../Data_' + month + '19/conso_HEI_' + month + '19.csv'
forecast_consumer_HEI = pd.read_csv(fnamePV,
                                    sep=';',
                                    names=['timeVector', 'power'],
                                    index_col=0,
                                    squeeze=True,
                                    parse_dates=True)
forecast_consumer_HEI = forecast_consumer_HEI.asfreq(freq=str(timeStep) +
                                                     'T')  # retime
forecast_consumer_HEI = forecast_consumer_HEI.interpolate()
forecast_consumer_HEI = forecast_consumer_HEI[startTime:endTime]
Building.setForecast(forecast_consumer_HEI)
forecast_consumer_HEI = tl.toListInt(forecast_consumer_HEI)

# listen to event to know when total PV forecast is available
l = 0
while l != 1:
    event_filter = contractADMM.events.SendForecast.createFilter(fromBlock=0)
    eventlist = event_filter.get_all_entries()
    l = len(eventlist)
print('Get total PV forecast')

# get PV forecast
yPVforecast = contractADMM.functions.getPVforecast().call()
yPVforecast = np.array(yPVforecast)
yPVforecast = pd.Series(yPVforecast / 10**6, timeVector)

# initialisation
Example #5
0
price_B = pd.Series(data=coeff_priceB * np.ones(length), index=timeVector)

# send forecast_PV_5RNS profile
fnamePV = '../Data_' + month + '19/PV_production5RNS_' + month + '19.csv'
forecast_PV_5RNS = pd.read_csv(fnamePV,
                               sep=';',
                               names=['timeVector', 'power'],
                               index_col=0,
                               squeeze=True,
                               parse_dates=True)
forecast_PV_5RNS = forecast_PV_5RNS.asfreq(freq=str(timeStep) + 'T')  # retime
forecast_PV_5RNS = forecast_PV_5RNS.interpolate()
forecast_PV_5RNS = forecast_PV_5RNS[startTime:endTime]
PV1.setForecast(forecast_PV_5RNS)

forecast_PV_5RNS = tl.toListInt(forecast_PV_5RNS)
tx_hash = contractADMM.functions.sendPVforecast(forecast_PV_5RNS).transact()
web3.eth.waitForTransactionReceipt(tx_hash)
print('Forecast send')

result = 0
iterations = 0

X_historic = []
L_historic = []

gasSpend_initialization = gasSpend

while result == 0:  # while stopping criteria of global optimization not reached

    time.sleep(15)  ###
Example #6
0
# send forecast_PV_RIZOMME profile
fnamePV = '../Data_' + month + '19/PV_productionRIZOMME_' + month + '19.csv'
forecast_PV_RIZOMME = pd.read_csv(fnamePV,
                                  sep=';',
                                  names=['timeVector', 'power'],
                                  index_col=0,
                                  squeeze=True,
                                  parse_dates=True)
forecast_PV_RIZOMME = forecast_PV_RIZOMME.asfreq(freq=str(timeStep) +
                                                 'T')  # retime
forecast_PV_RIZOMME = forecast_PV_RIZOMME.interpolate()
forecast_PV_RIZOMME = forecast_PV_RIZOMME[startTime:
                                          endTime]  # negative values!
PV1.setForecast(forecast_PV_RIZOMME)

forecast_PV_RIZOMME = tl.toListInt(forecast_PV_RIZOMME)
tx_hash = contractADMM.functions.sendPVforecast(forecast_PV_RIZOMME).transact()
web3.eth.waitForTransactionReceipt(tx_hash)
print('Forecast send')

result = 0
iterations = 0

X_historic = []
L_historic = []

gasSpend_initialization = gasSpend

while result == 0:  # while stopping criteria of global optimization not reached

    time.sleep(15)  ###
Example #7
0
price_B = pd.Series(data=coeff_priceB * np.ones(length), index=timeVector)

# get forecast_consumer_RIZOMME profile
fnamePV = '../Data_' + month + '19/conso_RIZOMME_' + month + '19.csv'
forecast_consumer_RIZOMME = pd.read_csv(fnamePV,
                                        sep=';',
                                        names=['timeVector', 'power'],
                                        index_col=0,
                                        squeeze=True,
                                        parse_dates=True)
forecast_consumer_RIZOMME = forecast_consumer_RIZOMME.asfreq(
    freq=str(timeStep) + 'T')  # retime
forecast_consumer_RIZOMME = forecast_consumer_RIZOMME.interpolate()
forecast_consumer_RIZOMME = forecast_consumer_RIZOMME[startTime:endTime]
Building.setForecast(forecast_consumer_RIZOMME)
forecast_consumer_RIZOMME = tl.toListInt(forecast_consumer_RIZOMME)

# initialisation
result = 0
iterations = 0
X_historic = []
L_historic = []

# listen to event to know when total PV forecast is available
l = 0
while l != 1:
    event_filter = contractADMM.events.SendForecast.createFilter(fromBlock=0)
    eventlist = event_filter.get_all_entries()
    l = len(eventlist)
print('Get total PV forecast')