コード例 #1
0
def on_init(t):
    global t0
    t0 = time.time()

    global step
    step = 0

    global df_prices, df_WS
    df_prices = pandas.DataFrame(columns=[
        'clearing_price', 'clearing_quantity', 'unresponsive_loads',
        'slack_t-1'
    ])
    df_WS = pandas.read_csv('glm_generation_' + city + '/' + market_data,
                            parse_dates=[0],
                            index_col=[0])

    #Find objects
    global houses
    if flexible_houses == 0:
        houses = []
    else:
        houses = gldimport.find_objects('class=house')[:flexible_houses]

    #global df_house_state;
    #df_house_state = HHfct.get_settings_houses(houses,interval)

    batteries = gldimport.find_objects('class=battery')
    global batterylist, EVlist
    batterylist, EVlist = gldimport.sort_batteries(batteries)
    global df_battery_state
    df_battery_state = Bfct.get_settings_batteries(batterylist, interval)
    global df_EV_state
    df_EV_state = EVfct.get_settings_EVs(EVlist, interval)

    pvs = gldimport.find_objects('class=solar')
    global pvlist, pvinvlist
    pvlist, pvinvlist = gldimport.sort_pvs(pvs)
    global df_PV_state
    df_PV_state = PVfct.get_settings(pvlist, interval)

    global df_prices, df_WS
    df_prices = pandas.DataFrame(columns=[
        'clearing_price', 'clearing_quantity', 'unresponsive_loads',
        'slack_t-1'
    ])
    df_WS = pandas.read_csv('glm_generation_' + city + '/' + market_data,
                            parse_dates=[0],
                            index_col=[0])

    print('Initialize finished after ' + str(time.time() - t0))
    return True
コード例 #2
0
def on_init(t):
	global t0;
	t0 = time.time()

	global step;
	step = 0

	#Instead of mysql
	global df_buy_bids, df_supply_bids, df_awarded_bids;
	df_buy_bids = pandas.DataFrame(columns=['timestamp','appliance_name','bid_price','bid_quantity'])
	df_supply_bids = pandas.DataFrame(columns=['timestamp','appliance_name','bid_price','bid_quantity'])
	df_awarded_bids = pandas.DataFrame(columns=['timestamp','appliance_name','bid_price','bid_quantity','S_D'])

	#Find objects
	global houses;
	if flexible_houses == 0:
		houses = []
	else:
		houses = gldimport.find_objects('class=house')[:flexible_houses]
	
	#global df_house_state;
	#df_house_state = HHfct.get_settings_houses(houses,interval)

	batteries = gldimport.find_objects('class=battery')
	global batterylist, EVlist;
	batterylist, EVlist = gldimport.sort_batteries(batteries)
	global df_battery_state;
	df_battery_state = Bfct.get_settings_batteries(batterylist,interval)
	global df_EV_state;
	df_EV_state = EVfct.get_settings_EVs(EVlist,interval)

	global df_prices, df_WS;
	df_prices = pandas.DataFrame(columns=['clearing_price','clearing_quantity','unresponsive_loads','slack_t-1'])
	df_WS = pandas.read_csv('glm_generation_'+city+'/'+market_data,parse_dates=[0],index_col=[0])
	#df_WS = pandas.DataFrame(index=pandas.to_datetime(df_WS.index.astype(str)),columns=df_WS.columns,data=df_WS.values)

	print('Initialize finished after '+str(time.time()-t0))
	return True
コード例 #3
0
def on_init(t):
    global t0
    t0 = time.time()

    global step
    step = 0

    batteries = gldimport.find_objects('class=battery')
    global batterylist, EVlist
    batterylist, EVlist = gldimport.sort_batteries(batteries)

    global df_EV_state
    if EV_data == 'None':
        df_EV_state = EVfct.get_settings_EVs_rnd(EVlist, interval)
    else:
        df_EV_state = EVfct.get_settings_EVs(EVlist, interval)

    print('Initialize finished after ' + str(time.time() - t0))
    return True
コード例 #4
0
def on_init(t):
	global t0;
	t0 = time.time()

	#Empty databases
	myfct.clear_databases(table_list)
	try:
		os.remove(results_folder + '/df_supply_bids.csv')
		os.remove(results_folder + '/df_demand_bids.csv')
		os.remove(results_folder + '/df_prices.csv')
	except:
		pass

	#PHYSICS: Find objects and fill local DB with relevant settings
	#import pdb; pdb.set_trace()
	houses_names = gldimport.find_objects('class=house')
	for house_name in houses_names:
		gldimport.get_houseobjects(house_name,start_time_str)
		gldimport.get_PVs(house_name,start_time_str)
		gldimport.get_batteries(house_name,start_time_str)
		gldimport.get_chargers(house_name,start_time_str) #Gets charger inverters and maximum charging rates
		gldimport.initialize_EVs(house_name,start_time_str) #Checks if EVs are connected already and fills in state_in

	#MARKET: Create house agents
	global houses;
	houses = []
	for house_name in houses_names:
		houses += [HHfct.create_agent_house(house_name)]

	#Create WS supplier
	global retailer;
	retailer = WSSupplier()

	#Create market operator
	global LEM_operator;
	LEM_operator = MarketOperator(interval,p_max)

	print('Initialize finished after '+str(time.time()-t0))
	return True
コード例 #5
0
def on_init(t):
	global t0;
	t0 = time.time()

	global step;
	step = 0

	#Instead of mysql
	global df_buy_bids, df_supply_bids, df_awarded_bids;
	df_buy_bids = pandas.DataFrame(columns=['timestamp','appliance_name','bid_price','bid_quantity'])
	df_supply_bids = pandas.DataFrame(columns=['timestamp','appliance_name','bid_price','bid_quantity'])
	df_awarded_bids = pandas.DataFrame(columns=['timestamp','appliance_name','bid_price','bid_quantity','S_D'])

	#Find objects
	global houses;
	if flexible_houses == 0:
		houses = []
	else:
		houses = gldimport.find_objects('class=house')[:flexible_houses]
	
	#global df_house_state;
	#df_house_state = HHfct.get_settings_houses(houses,interval)

	batteries = gldimport.find_objects('class=battery')
	global batterylist, EVlist;
	batterylist, EVlist = gldimport.sort_batteries(batteries)
	global df_battery_state;
	df_battery_state = Bfct.get_settings_batteries(batterylist,interval)
	global df_EV_state;
	if EV_data == 'None':
		df_EV_state = EVfct.get_settings_EVs_rnd(EVlist,interval)
	else:
		df_EV_state = EVfct.get_settings_EVs(EVlist,interval)

	pvs = gldimport.find_objects('class=solar')
	global pvlist, pvinvlist;
	pvlist, pvinvlist = gldimport.sort_pvs(pvs)
	global df_PV_state;
	df_PV_state = PVfct.get_settings(pvlist,interval)
	if load_forecast == 'perfect':
		global df_PV_forecast;
		try:
			df_PV_all = pandas.read_csv('glm_generation_'+city+'/perfect_PV_forecast_'+month+'_all.csv',parse_dates=True,skiprows=8)
			df_PV_all['# timestamp'] = df_PV_all['# timestamp'].str.replace(r' UTC$', '')
			df_PV_all['# timestamp'] = pandas.to_datetime(df_PV_all['# timestamp'])
			df_PV_all.set_index('# timestamp',inplace=True)
			df_PV_forecast = pandas.DataFrame(index=df_PV_all.index,columns=['PV_infeed'],data=df_PV_all[df_PV_state['inverter_name']].sum(axis=1))
			df_PV_forecast.to_csv('glm_generation_'+city+'/perfect_PV_forecast_'+month+'.csv')
		except:
			print('No perfect PV forecast found, use myopic PV forecast')
			df_PV_forecast = None

	global df_prices, df_WS;
	df_prices = pandas.DataFrame(columns=['clearing_price','clearing_quantity','unresponsive_loads','slack_t-1'])
	df_WS = pandas.read_csv('glm_generation_'+city+'/'+market_data,parse_dates=[-1],index_col=[0])
	df_WS = pandas.DataFrame(index=pandas.to_datetime(df_WS.index.astype(str)),columns=df_WS.columns,data=df_WS.values.astype(float))
	
	#Align weekdays of Pecan Street Data and WS: For yearly data only (TESS, not powernet)
	# year_sim = parser.parse(gridlabd.get_global('clock')).replace(tzinfo=None).year
	# first_weekday = pandas.Timestamp(year_sim,1,1).weekday() 
	# first_weekday_WS = df_WS.index[0].weekday()
	# while not first_weekday_WS == first_weekday:
	# 	df_WS = df_WS.iloc[1:]
	# 	first_weekday_WS = df_WS.index[0].weekday()
	# df_WS =df_WS.iloc[:(365*24*12)] #Should not be hardcoded
	# df_WS.index = pandas.date_range(pandas.Timestamp(year_sim,1,1,0),pandas.Timestamp(year_sim,12,31,23,55),freq='5min')

	print('Initialize finished after '+str(time.time()-t0))
	return True
コード例 #6
0
def on_init(t):

	global t0;
	t0 = time.time()

	global step;
	step = 0

	#Documentation
	global df_buy_bids, df_supply_bids, df_awarded_bids;
	df_buy_bids = pandas.DataFrame(columns=['timestamp','appliance_name','bid_price','bid_quantity'])
	df_supply_bids = pandas.DataFrame(columns=['timestamp','appliance_name','bid_price','bid_quantity'])
	df_awarded_bids = pandas.DataFrame(columns=['timestamp','appliance_name','bid_price','bid_quantity','S_D'])

	#Customers
	customers = gldimport.find_objects('class=house')

	#Find houses with flexible HVAC (0 in MVP)
	global houses;
	if flexible_houses == 0:
		houses = []
	else:
		houses = gldimport.find_objects('class=house')
	global df_house_state;
	df_house_state = HHfct.get_settings_houses(houses,interval)

	#Batteries and EVs
	batteries = gldimport.find_objects('class=battery')
	global batterylist, EVlist;
	batterylist, EVlist = gldimport.sort_batteries(batteries)
	global df_battery_state;
	df_battery_state = Bfct.get_settings_batteries(batterylist,interval)
	global df_EV_state;
	if (EV_data == 'None') or (len(EVlist) == 0):
		df_EV_state = EVfct.get_settings_EVs_rnd(EVlist,interval)
	else:
		df_EV_state = EVfct.get_settings_EVs(EVlist,interval)

	#PVs
	pvs = gldimport.find_objects('class=solar')
	global pvlist, pvinvlist;
	pvlist, pvinvlist = gldimport.sort_pvs(pvs)
	global df_PV_state;
	df_PV_state = PVfct.get_settings(pvlist,interval)
	if load_forecast == 'perfect':
		global df_PV_forecast;
		try:
			df_PV_all = pandas.read_csv(input_folder+'/perfect_PV_forecast_'+dt_sim_time.month+'_all.csv',parse_dates=True,skiprows=8)
			df_PV_all['# timestamp'] = df_PV_all['# timestamp'].str.replace(r' UTC$', '')
			df_PV_all['# timestamp'] = pandas.to_datetime(df_PV_all['# timestamp'])
			df_PV_all.set_index('# timestamp',inplace=True)
			df_PV_forecast = pandas.DataFrame(index=df_PV_all.index,columns=['PV_infeed'],data=df_PV_all[df_PV_state['inverter_name']].sum(axis=1))
			df_PV_forecast.to_csv(input_folder+'/perfect_PV_forecast_'+dt_sim_time.month+'.csv')
		except:
			print('No perfect PV forecast found, use myopic PV forecast')
			df_PV_forecast = None

	#Tokens
	global df_tokens;
	df_tokens = pandas.DataFrame(columns=['clearing_price','clearing_quantity','partial','alpha','unresponsive_loads','system_mode','slack_t-1'])
	global df_controlroom;
	df_controlroom = pandas.read_csv(input_folder + '/' + control_room_data,index_col=[0],parse_dates=True) # This includes the control room ts of coincident peak forecast
	global df_WS;
	df_WS = pandas.read_csv(input_folder + '/' + market_data,index_col=[0],parse_dates=True) # This includes the control room ts of coincident peak forecast

	print('Initialize finished after '+str(time.time()-t0))
	return True