3. Functions of User Agents
The user agent determines the amount and price of bids according to the user’s equipment and demand, aiming to maximize the profit of each consumer or prosumer. The user agent makes decisions about when and how much to sell (or buy) and at what price, based on demand and power generation forecasts, and executes bids to the blockchain market. In the case of P2P transactions at the individual level, it is unrealistic for electricity consumers to constantly monitor the market just like day traders in the stock market, calculate the amount of electricity they need, and place bids. Therefore, we need such an agent module that automatically procures the amount of electricity consumers need from the market.
Bidding agents are required to take into account the various needs of consumers and power generators and automatically execute transactions in accordance with their preferences. The purpose of the bidding agent is to realize various needs, such as the financial need to purchase cheap electricity anyway, and the environmental value need to use renewable energy as much as possible. In the development of bidding agents, the assets they own are also an important factor. By optimizing the charging and discharging of EVs, consumers who own EVs can be expected to enjoy cost advantages, such as procuring more electricity from the market when electricity prices are low, storing it in batteries, and discharging it from batteries when electricity prices in the market are rising. In addition, optimizing the charging and discharging of EVs is an important factor not only in terms of cost, but also in terms of satisfying the RE preferences of individual users, as it can be expected to increase the RE ratio at a low cost by charging EVs when surplus inexpensive RE is generated. When EVs and storage batteries are not owned, the amount of electricity demanded is a constraint on electricity transactions, but when EVs and storage batteries are owned, it is possible to reduce costs and increase the RE ratio by recharging and discharging at appropriate times.
The processing flow of the user agent is shown in
Figure 2. In the electricity demand forecasting function, electricity demand forecasting is performed based on consumer demand data and weather data. In the case of PV power generation, the PV power generation forecast is based on past power generation data and weather data. Here, the solar radiation forecasting API of the Meteorological Engineering Center [
23] is used to create a machine learning model using random forest [
24] that learns the relationship between actual PV power generation values and forecasted solar radiation values to make forecasts. The bid creation function creates bids specifying the time frame, amount of electricity, and price based on the trading mode (green mode or economy mode) set by the user, the forecast results, and the SOC of the EV, and the bid execution function puts the created bids into the energy market. The details of the bid creation method will be described in the following sections. The execution result acquisition function acquires a record of the executed bids in the energy market, and the results are submitted again to the bid creation function to recalculate a new bid. The energy market trades electricity in 30-min increments, bids can be submitted from 24 h before the actual electricity fusion to one hour before the fusion, and user agents change their bids for the same market every 30 min. At that time, the bid cancellation function is a function that sends a command to the market to cancel the old bids from the past. The entire process from forecasting to bidding is repeated for each agent at 30-min intervals until one hour before the market closes. The EV charging/discharging command function actually issues charging/discharging commands to EVs through the EV PCS API based on the calculated EV charging/discharging plan once the target market has been closed. The EV charging/discharging plan is calculated in the optimization calculation in the bid creation.
4. User Agent Bidding Modes and Bid Optimization
The bid creation function optimizes the bidding to the market and the charging and discharging of EVs based on the forecasted amount of demand, the forecasted amount of power generation, the SOC value, the expected market contract price, and the retail price of electricity. Two types of bid creation modes have been established: the economy mode and the green mode. In the economy mode, optimization is performed with the objective function of minimizing costs, including electricity sales revenue. It aims to maximize profits (minimize costs) by adjusting the timing and amount of procurement from the market and the grid, and by controlling the charging and discharging of its own EVs. The green mode is optimized by minimizing the cost, including the revenue from electricity sales, as the objective function while placing the constraint of meeting the target RE ratio set by the user. The objective is to maximize profits (or minimize costs) by adjusting the timing and amount of procurement from the market and grid, and by controlling the charging and discharging of its own EVs, while meeting the desired renewable energy consumption ratio (target RE ratio).
Equations (1)–(9) show the optimization equation for the economy mode. Each agent optimizes its own bid using this optimization equation. The objective function, Equation (1), to be minimized is the cost of procurement from the market (including revenue from electricity sales) + the cost of procurement from the grid + a penalty term, each of which is the sum of the values from the market one hour ahead to the market 48 h ahead of the target bid. The penalty term is expected to have the effect of preventing unnecessary trading from occurring, for example, buying 100 kWh and selling 99 kWh at the same price when one wants to buy 1 kWh. The variables to be optimized are
,
,
,
, and
and they are optimized by the calculations in Equations (1)–(9). In other words, we optimize the values from 1 h ahead to 49 h ahead for these variables. Each of these variables represents the amount of electricity purchased in the market, the amount of electricity sold in the market, the amount of electricity purchased from the retail business, and the amount of charging and discharging of the EV’s battery. In addition to optimizing the charging and discharging of the EV’s battery, the amount of electricity bought and sold in the market and the amount of electricity bought and sold from the retail business are simultaneously optimized. Since
is the amount of charge for a certain 30 min, the upper limit of
is the maximum charging speed of the battery (
) [kW] multiplied by 0.5. Similarly, the value obtained by multiplying
[kW] by 0.5 is the upper limit of discharge (
).
Each variable is defined as follows.
| Amount of electricity to be purchased in the market at time t [kWh] (Optimization target) |
| Amount of electricity to be sold in the market at time t [kWh] (Optimization target) |
| Amount of electricity to be purchased from electricity retailers at time t [yen/kWh] (Optimization target) |
| Amount of charge to the battery at time t [kWh] (Optimization target) |
| Amount of discharge from the battery at time t [kWh] (Optimization target) |
| Expected price at time t [yen/kWh] (estimated by each agent based on expected power generation) |
| Retail price of electricity at time t [yen/kWh] (defined in advance) |
| Expected demand at time t [kWh] (calculated by demand forecast) |
| Expected power generation at time t [kWh] (calculated by power generation forecast) |
| Percentage of remaining charge of the battery at time t [%] |
| Maximum charging output of the battery [kW] (6.7 [kW]) |
| Maximum discharge output of the battery [kW] (6.0 [kW]) |
| Lower limit of SOC [%] (set to 20 percent) |
| Upper limit of SOC [%] (set to 90%) |
| Rated capacity of battery [kWh] (40 [kWh] was set.) |
| Battery charging efficiency [%] (set to 86.6%, so that CHARGE_RATE*DISCHARGE_RATE=75%) |
| Discharge efficiency of the battery [%] (set to 86.6%, the same as CHARGE_RATE) |
| Expected energy consumption by driving at time t [kWh]. This is always set to 0 because the EV is not running in this demonstration experiment. |
| The bool value indicating whether or not the EV is running at time t. It is always set to “false” because it is not run in this verification experiment. |
is the expected price in the market at time t. This expected price is calculated by each agent based on the weather information of the target day to predict the PV power generation on that day, and the expected price is calculated based on the power generation rate, which is the predicted PV power generation divided by the rated maximum output. Since the only electricity to be sold in the market in this case study is PV-derived, we believe it is a reasonable approach to forecast the PV power generation and predict the price according to the amount. The formula for calculating the expected price from the generation rate
is defined in Equation (2).
Figure 3 plots the relationship between the power generation rate defined in Equation (2) and the expected market price. As the power generation rate p increases, the price approaches D = 5. In addition, when
p = 0, the price is C + D = 28. In this demonstration experiment, we have taken the approach of calculating the price based on the expected amount of electricity generated. However, if such a trading market has actually been in operation for some time and sufficient data have been accumulated, a better method would be to create a regression model to predict the price using past contract prices and the weather conditions of the target market.
gives the price list for each time. For the price list, we used the pay-as-you-go rates of the price table of “Hapi-e-time R” of Kansai Electric Power Co., Osaka, Japan [
25]. This price list is shown in
Table 1.
is the agent’s prediction of its own demand. The temperature and time information of the weather forecast data are used as explanatory variables, and a regression by random forest is conducted to make predictions. The predictions are made for 96 frames in 30-min increments for 48 h from 1:00 to 49:00 on the previous day.
is the agent’s prediction of its own photovoltaic power generation. The prediction is made by using the predicted solar radiation and time information as explanatory variables and conducting a regression by random forest. The predictions are made for 96 frames in 30-min increments for 48 h from 1:00 to 49:00 on the previous day.
is the percent [%] of remaining charge of the battery at time t. The current battery state is obtained from the EV GW, and it is given as the initial state, but the subsequent times are calculated in the optimization according to the amount of charge and discharge, so it can be said that it is also optimized as a result.
Equations (11)–(20) show the optimization equation for green mode. The fact that the objective function (11) to be minimized is the cost of procurement from the market (including the revenue from electricity sales) + the cost of procurement from the grid + the penalty term is the same as in the economy mode, but the condition that the ratio of RE to the electricity consumed by the user should exceed the target RE ratio (
) has been added to the constraints (12). This allows us to plan the bidding to the market and the charging and discharging of the EVs so that the target RE ratio is exceeded. It should be noted that there may be cases where no solution exists due to this constraint condition. If a solution does not exist, the target RE ratio will be temporarily lowered by 5% in stages until a solution is found.
Each variable is defined as follows.
| Target RE ratio (set by user between 0~100%) |
The other items are the same as in (1)–(9).
In the case that the user does not own the EV, among the variables related to the EV () in Equations (1)–(9) and Equations (11)–(20), respectively, all variables other than are set to 0. can be any real number other than 0 since it can be the denominator in the constraint.
Next, in the bid submission section, among the results calculated by the above optimization, and are bid into the blockchain market as the purchase and sales amount, respectively, and the unit price as . Bidding is done for 48 markets every 30 min for the next 24 h. Here, optimization is performed until 48 h in the future, aiming to calculate the charging and discharging strategies for the last 24 h in a way that takes into account the future from 24 to 48 h in the future. If only the last 24 h are taken into account for optimization, even if the next two days are sunny and inexpensive electricity is supplied in abundance during the daytime, it is possible to store a lot of electricity in the batteries, so that when you try to store inexpensive electricity the next two days, the batteries are too full to store it. Therefore, the optimization is conducted for a longer period of time than the actual bidding.
In the contract results acquisition section, the contract status of the bids is obtained. Bids that have not yet been contracted are submitted under new conditions after optimization calculations. In this case, the existing bids are cancelled, and new bids are made.
This process of contract results acquisition, bid creation, bid cancelling, and bid submission is repeated every 30 min, and a time-evolving bidding experiment is conducted.
Regarding the optimization calculation of bidding agents, a single optimization calculation of an agent itself takes only a few seconds, and the calculation time increases linearly as the number of agents increases. Since the agents do not share information with each other, parallel computation is possible, and the problem can be solved by preparing multiple servers for computation.