Abstract
In the current electricity market environment, this paper proposes a user-side resource interactive transaction decision-making method based on scipy solver and genetic algorithm, which significantly improves the user-side resource transaction volume and reduces the risk loss of e-commerce. Compared with traditional methods, this study classifies controllable load resources more accurately by introducing fuzzy C-means clustering method, which provides more reliable data support for auxiliary decision making. At the same time, the construction and solution of the two-layer programming model not only considers the peak-valley price strategy of e-commerce, but also comprehensively coordinates the user demand response, and realizes the maximization of income expectations and the minimization of transaction risks. In addition, scipy solver is used to solve the power consumption model, which further optimizes the user-side resource transaction. After testing, the method in this paper not only significantly improved the user-side resource transaction volume, but also made the power user satisfaction as high as 0.99, which fully demonstrated the significant effect of this research method in improving user satisfaction, and provided a strong support for the intelligent and sustainable development of the power market.
Keywords
Introduction
Energy is the cornerstone of social development, and its efficient use is very important to solve the problems of environment, climate change and low carbon economy. In this context, distributed energy generation has become the focus of today's power system research due to its advantages of small investment, flexible mode, low loss and environmental protection.1,2 This type of power generation uses the distribution network or facilities near the load such as photovoltaic power generation, wind power generation, fuel cells, etc., for electricity production, which is usually consumed locally. 3 However, with the increase of its penetration rate, problems such as insufficient consumption of new energy gradually appear. 4 To this end, it is considered necessary to study and promote distributed energy trading.5,6 In recent years, China's power system reform has created a favorable environment for distributed energy trading, especially the opening of the electricity sales side market, which enables more users to directly participate in the power market competition and conduct energy trading.7,8 In order to make such inter-user energy trading smooth, a more flexible intra-trading mechanism is needed, especially in regional micronetworks such as community micronetworks and incremental distribution networks.9–11
Demand side management, referred to as DSM (Data-driven Security Management) management, refers to the management activities carried out by the power supply and demand parties in cooperation and under the guidance of various policies of the government to take various measures to change the power consumption mode of users, so as to reduce the abnormal consumption of power, reduce the peak valley difference of system load, improve the reliability of power supply, and ultimately realize the interests of the participants. 12 In the research area of demand-side management, several researchers have explored various approaches to address the problem of electricity consumer behavior and its coordination with energy supply and demand response. The cartel mechanism and repeated game framework proposed by Yang et al. 13 provides a strategy to prevent the non-cooperative behavior of electricity consumers, which ensures the cooperation of consumers by setting up punishment rules, thus reducing the total cost of electricity. However, this method mainly focuses on constraint control, which is not directly applicable to the decision-making process of demand-side resource interactive trading, and can only be used as a reference for constraints. The research work by Li et al. 14 proposes a two-level optimal allocation approach that aims to coordinate the set configuration and operation. This method can optimize according to the supply and demand response state of power energy, so as to improve the robustness of resource scheduling at the user end. However, its calculation process is relatively complex, resulting in low operational efficiency, which may become a limitation in demand-side resource interactive transactions. The study by Yuan et al. 15 focuses on the bi-level programming approach for real-time pricing strategies in smart grids, especially when multiple microgrids are connected. They devised a scheme that aims to maximize the profit of the seller and the welfare of the user. This method starts from the dual perspectives of e-commerce and users, and uses bi-level programming technology to improve the effect of user side resource scheduling. However, this method has shortcomings in classifying load resources, which simply divides the load resources of the user side into controllable and uncontrollable two types. This may lead to blind planning in the scheduling process, which in turn increases the planning time cost. In summary, although these studies have made some progress in the field of demand-side management, they still have some limitations when dealing with user-side resource interaction trading decisions. Future research needs to further explore more efficient and accurate methods to adapt to the complexity and dynamics of demand-side resource interactive transactions.
The purpose of this study is to explore the auxiliary decision-making method of user-side resource interactive trading based on scipy solver and genetic algorithm. Through the construction of user-side energy trading market framework, clear trading subjects and rules. The fuzzy C-means clustering method is used to classify the controllable load. A two-layer programming model is established, in which the upper layer model focuses on the decision-making of e-commerce sales interactive transactions, and the lower layer model focuses on the decision-making of user demand response. To solve this complex model, scipy solver and genetic algorithm are introduced to effectively combine the advantages of numerical optimization and heuristic search. Through the experimental analysis, the interactive behavior of e-commerce sellers’ pricing and users’ power consumption decision-making is deeply discussed, the market optimization trading strategy of e-commerce sellers is analyzed, and the user-side resource transactions are studied, providing strong support for improving the decision-making level of user-side resource interaction transactions. This research focuses on the auxiliary decision method of user-side resource interactive transaction. By introducing scipy solver and genetic algorithm, a two-layer programming model is innovatively constructed to effectively solve the complex decision problem of user-side resource transaction. Combining the advantages of numerical optimization and heuristic search, the decision efficiency and accuracy are improved, and new ideas and tools are provided for the optimization decision of the user-side energy trading market, which helps to promote the intelligent and sustainable development of the energy market.
User side resource interactive transaction assistant decision-making method
User side energy trading market framework
In this market, there are two main types of market players: users and power grid companies. In this micro grid system, the main role of the grid company is to ensure the energy balance of the market: when the power supply of users is greater than their power demand, the excess power is sold to the grid company; When the power supply of users is less than their power demand, the missing power will be purchased from the grid company. 16
The trading mode in the market is represented by energy flow and price flow. Users who supply electricity can trade with users who need electricity or power grid companies. At this time, the energy flows out from the supplier and the price flows into the supplier; Users who demand electricity can purchase electricity from users who supply electricity or grid companies. At this time, the energy flows into the demand side, while the price flows out from the demand side. 17
Classification method of controllable load based on fuzzy C-means clustering method
According to the user's own attributes, it can be divided into commercial load, industrial load and residential load. According to whether the load has demand response capability, it can also be divided into controllable load and uncontrollable load. More specifically, according to the various uses of residential load in life, it can be specific to the combined cooling, heating and power load, electric vehicles, air conditioning, etc.. 18 The type and degree of response to different load demand are different. Generally speaking, residential load power consumption is concentrated during peak hours, but the overall power consumption characteristics are more flexible, and residential load power consumption is relatively small, and the response users are more dispersed. Therefore, compared with incentive demand response, considering their participation in price based demand response is higher, the effect of power saving is more obvious.In this paper, residential user load is divided into controllable load and uncontrollable load. Controllable load means that the load has the ability to participate in demand response, and can adjust the power consumption mode according to the electricity price or incentive. Uncontrolled load means basic fixed load, and does not participate in demand response. 19
The idea is to extract feature vectors from the daily load curves of many users obtained from the power consumption information acquisition system according to the needs of demand response measures, and then classify them according to a certain type of feature vectors. Each type of user will have a similar load characteristic. 20
Set the user side load resource set as
Set variable
Equation (2) is the objective function expression of I,
The extreme value
When
Among them,
When
The core idea of fuzzy C-means clustering algorithm is to minimize the value of the objective function through continuous iterative calculation formula (3).
22
Therefore, the solution steps are as follows:
Among them,
User side interactive transaction of resources is mainly reflected in the interactive transaction between electricity sellers and power users. This transaction is respectively reflected in the peak and valley price decision of electricity sellers and the power consumption mode decision of power users.In fact, the peak and valley price decision of electricity sellers is a typical master-slave game between electricity sellers and power users
23
; However, power users make decisions on power consumption in each period by comprehensively considering comfort and power cost; At the same time, the decision of either party will affect the decision of the other party, and there is a “sequential” master-slave relationship between the decision-making behavior of both parties. Therefore, this paper constructs the master-slave game problem as a bilevel programming model. From the perspective of sellers and buyers, this paper constructs the interactive transaction auxiliary decision-making model of the upper selling e-commerce and the demand response decision-making model of the lower user interaction. Among them, the demand response decision-making object of the lower user interaction is mainly aimed at the controllable load users
Assistant decision-making model for interactive transaction of upper layer selling e-commerce
The goal of interactive transaction auxiliary decision-making of electricity sellers is to maximize the expectation of comprehensive coordination of electricity sales revenue and minimize the transaction risk. Therefore, the objective function of peak and valley price pricing decision when electricity sellers sell electricity interactively to power users is expressed as:
Among them,
In the decision-making of electricity selling pricing, electricity sellers should also consider the competitive relationship with other electricity sellers in the electricity market environment. The competition among e-commerce sellers is more reflected in the price strategy. The high price will directly lead to the replacement of electricity sellers by electricity users, which will directly lead to the loss of electricity sellers and their users. Therefore, in order to ensure the market competitiveness of the electricity sellers, the maximum price and average price are proposed as two constraints for the peak and valley price provided by the electricity sellers. The constraints are:
Among them,
Power users will adjust their own electricity consumption mode according to the peak valley time of use price provided by the electricity seller, so as to achieve the goal of the lowest electricity cost. At the same time, changing the original electricity consumption habits of users will also affect the comfort of electricity users. Therefore, when considering the cost of electricity consumption, users will also comprehensively consider the impact of load transfer on electrical comfort.
The power consumption decision problem of users is to minimize the power consumption cost while ensuring comfort. Therefore, the objective function of the lower level problem is:
Among them,
Among them,
After the implementation of peak and valley electricity prices, users will be able to know the total change of power consumption in each period compared with the original power load in total decision cycle T to measure the user's electrical comfort
Among them,
The power load shall meet the following constraints. For each scenario
The controllable load must be positive, and the constraint conditions are expressed as:
In addition, excessive load reduction in a certain period of time may cause a series of negative effects such as reduced user comfort.In order to avoid such problems, limit the reduction of user power consumption, which can be expressed as:
The user side resource interactive transaction assistant decision-making problem studied in this paper is a hard problem. As we all know, it is very difficult to solve the hard problem, but the user side resource interactive transaction assistant decision-making problem studied in this paper belongs to the bilevel programming problem.For solving bilevel programming problems, many scholars have tried to design relevant algorithms according to the characteristics of the problem. In this paper, we try to use the genetic algorithm based on elite strategy to solve the interactive transaction assistant decision-making problem of upper tier e-commerce. The idea of this algorithm is to survive the fittest, maintain the optimal population in each evolution, and eliminate the population with low fitness; The demand response decision model of lower level user interaction is solved by scipy solver, because the genetic optimization algorithm is a random search algorithm, and its own time consumption is large, resulting in a long running time of the algorithm. Considering that this problem is a computationally intensive task, this paper uses the scipy solver for parallel operation in Python environment, which can speed up the operation.
The basic idea of the algorithm is to first calculate the demand response decision model scheme for user interaction at the lower level under the premise of satisfying the feasible scheme at the upper level, then calculate the objective function at the upper level, and determine the optimal scheme for user side resource interaction transaction auxiliary decision-making after repeated iterations.
The specific steps are as follows:
Set the population size representing the set of peak and valley price pricing decision schemes as N, the length of each chromosome (peak valley price pricing decision scheme) in the population is M, the maximum number of iterations is
Take
According to
According to step (2), calculate the fitness of each chromosome (the optimal scheme of user side resource interactive transaction auxiliary decision-making, including peak valley price pricing decision-making scheme and power consumption scheme of power users), and
For
After performing a full crossover operation, the new
Take
When using the scipy solver for parallel operations in the Python environment, it is mainly in the Python environment to use C/C++, C #, Java and other languages to program and solve the problems studied through the scipy solver. Figure 1 is the overall framework of parallel computing.

The overall framework diagram of the scipy solver for parallel operations.
(Figure 1).
In this framework, the solution steps of the scipy solver are:
Experimental environment
The experiment is aimed at a community micro network in Liaoning Province of China. Take five users of the community's micro network as an example. The specific information of these five users is shown in Table 1.
Specific quantity of different types of users.
Specific quantity of different types of users.
This paper constructs a simulated e-commerce environment, including multiple e-commerce sellers and users. In this environment, the resource transaction process on the user side is simulated, including the pricing strategy of e-commerce sellers and the power consumption decision of users. In order to better simulate the actual market situation, real data sets are used, including users ‘electricity consumption history data, e-commerce sellers ‘product information and market price data. In the experiment, different parameters are set, such as the number of e-commerce sellers, the number of users, and the fluctuation range of electricity price, in order to better study the factors affecting the interactive transaction of user-side resources. At the same time, considering the competition situation of the market, different competition strategies are set, in order to better study the influence of market competition on the interactive transaction of user side resources.
It should be noted that the user who installed the relevant device is assumed to have installed only one device in the experiment. Moreover, the power of the photovoltaic power generation device used in the experiment is 7 kW; The size of the electric energy storage device is 6 kW; The battery capacity of electric vehicles is 17 kW, but the upper limit of charging and discharging speed is 3.4 kW. In order to prevent overcharging, the battery status of electric vehicles is at least 40%.
In the experiment part, a Dell PowerEdge R740 server is used as the master node, and four Dell PowerEdge R640 nodes are used as computing nodes to build a high performance computer cluster for large-scale simulation experiments. These devices are equipped with sufficient memory and storage space to meet the needs of large-scale data analysis and computation. At the same time, the Red Hat Enterprise Linux 7.4 operating system was used as the operating system of the experimental environment, and the necessary scientific computing and data analysis software was installed.
In terms of parameter setting, 5000 users and 10 e-commerce sellers are set to participate in interactive resource trading, and the fluctuation range of electricity price is 0.5–2 yuan /kWh. The simulation has a time horizon of 1 year with one transaction per day. Using real data sets, including users’ electricity consumption history data, e-commerce sellers’ product information and market price data, the size of the data set is about 1TB. The setting of these parameters can better simulate the actual market situation, and provide help for better studying the influence factors of user-side resource interactive trading and the impact of market competition on trading.
To ensure the fairness and accuracy of the evaluation, we adopted a 70/30 dataset splitting criterion to divide the dataset into training and test sets. Of these, 70% of the data is used to train the model and 30% of the data is used to test the model. This split ensures that the model generalizes well and allows us to adequately train and evaluate the model on both the training and test sets. At the same time, we also use K-Fold cross validation method to further verify the performance of the model. In k-fold cross-validation, we split the dataset into K copies, and each time we use K-1 copies for training and the remaining one for testing. This process is repeated K times, with different data for each test, which allows us to more fully evaluate the performance of the model. We chose K = 5 for cross-validation, which provides a more stable and reliable evaluation.
In addition, it is also assumed that all users have the same load, and the load details are shown in Table 2. In the first stage of transaction volume adjustment, users can control the operation status of their controllable loads.In order to prevent some users’ behaviors from undermining market fairness, this paper sets that users can not exceed 15% of the electricity consumption of all controllable loads in one hour before and after adjusting the trading volume
Specific household load of each user.
Set the value of risk aversion factor as 1 and comfort coefficient as 400, calculate the optimal peak valley price, and the interaction relationship between the decision-making behaviors of both parties in the optimization iteration process is shown in Figure 4. The value of risk aversion factor is 0, and the optimal peak valley price is calculated by taking different comfort coefficients. The changes of the decision results of both parties are shown in Figure 2.

Decision behavior of both parties in the optimization iteration process.
(Figure 2).
(Figure 3).

Decision behavior of both parties under different comfort coefficients.
It can be clearly seen from Figure 2 that the peak-to-valley transmission power shows an upward trend as the comfort factor increases. This reflects a strategy adjustment of the seller. When the comfort factor increases, it means that the seller has more space and motivation to improve the peak price ratio. This is because by increasing this ratio, the seller can not only obtain higher profits, but also effectively reduce operational risks. However, such policy adjustments actually stimulate user behavior. As the peak-to-valley price ratio increases, users are more motivated and likely to shift more power load from peak to trough periods. In this way, users can save money on their electricity bills, while sellers can ensure a stable power supply and improve their income. However, this power transfer is not infinite. When there are too many power transfers and too much power supply in the trough period, the seller's revenue will be negatively affected. Because electricity is a commodity, its value is reflected in supply and demand. So, it's a dynamic balancing process. In this process, the seller and the user continuously adjust their strategies and play games, and finally reach a relatively stable equilibrium state. This equilibrium state not only ensures the reasonable profit of the seller, but also satisfies the power demand and cost considerations of the users.
From Figure 3, we can see that the calculated optimal peak-valley prices show an interesting trend under different comfort coefficient conditions. With the increase of user comfort factor, the peak and valley transfer energy shows a downward trend. The reason behind this is actually involved in the interactive decision-making game between the electricity seller and the power user. When the comfort demand of users increases, they are more willing to bear higher peak electricity price for better electricity experience. This is actually a rational decision, because for many users, comfortable electricity experience is an important goal they pursue. In the face of such user demand, e-commerce sellers may adopt the strategy of increasing the price ratio between peaks and valleys. However, this strategy has a relatively small impact on the user's power transfer. That is to say, although e-commerce sellers try to influence users’ electricity consumption behavior by adjusting the peak-valley price ratio, the comfort demand of users is still a key factor in determining the amount of electricity transferred. Therefore, the peak-to-valley power transfer will decrease with the increase of the comfort factor, because users pay more attention to the comfort of electricity consumption rather than the pure power transfer. This also reflects how user needs and preferences affect market dynamics in electricity markets.
Set the proportion of the call volume of the consumer side selling e-commerce in response to the user load demand in the total unbalanced load, that is, the balance degree between the demand response state and the unbalanced load

The method used in this article is to balance the market and optimize the trading effectiveness of pre and post electricity sales companies.
(Figure 4).
Analysis of Figure 4 shows that with the risk aversion factor
Before and after using this method, the transaction changes of power users on the user side are summarized in Table 3 and Table 4 respectively. It is worth noting that when the user conducts transactions with the grid, the purchase of electricity from the grid is recorded as positive, and the sale of electricity to the grid is recorded as negative.
User side resource transactions before the use of this method in this article.
User side resource transactions before the use of this method in this article.
User side resource transactions after the use of this method in this article.
By comparing Table 3 and Table 4, it is easy to see that this method can effectively improve the transaction volume of user side resources.
Since users are actively mobilized to participate in power grid dispatching management, their satisfaction index should also be taken into account. The user satisfaction index is different from the objective index of economy and autonomy. It is more subjective, and the content of the satisfaction index is different according to different connotations. Therefore, its measurement standard is not fixed. In this paper, comfort and reliability are integrated into the satisfaction index and quantified. Among them, the user's electrical comfort can be measured according to the actual power consumption curve and the relationship between the maximum comfort curve. Under the assumption of not participating in the demand side response in each period, the user's electrical comfort is considered to be the best; The reliability of power consumption can be reflected by load shedding. The user satisfaction index is defined by the following formula:
Where,
After using this method, the test results of user-side satisfaction index show that 5 users are satisfied with the effect of resource interaction transaction on assisting decision making within the satisfaction range of [0.95,0.99]. This data strongly demonstrates the effectiveness of the proposed method in improving the comfort and reliability of electricity users. Electricity customer satisfaction is an important index to measure the service quality of an electricity market. When users are satisfied with the comfort and reliability of the power supply, their electricity experience will be significantly improved, thus enhancing their sense of trust and loyalty to the power service. By using the method proposed in this paper, we can not only optimize the allocation of power resources, improve the operation efficiency of the power system, but also directly improve the satisfaction of users, thus further promoting the healthy development of the power market. This is not only a positive response to user needs, but also a sharp insight into market trends and forward thinking.
Based on the above experimental results, this paper introduces the framework of user-side energy trading market, the controllable load classification method based on fuzzy C-means clustering method, and the user-side interaction bi-level programming model based on scipy solver and genetic algorithm in detail in the section of user-side resource interaction transaction decision-making method. To further verify the superiority of the proposed method, the proposed method is compared with the state of the art optimization algorithms. The comparison with other optimization algorithms allows a more comprehensive evaluation of the performance and practicality of the proposed method and provides stronger support for its effect in practical applications.
In this paper, we propose an approach to assist decision-making in user-side resource interactive trading based on scipy solver and genetic algorithm. This method has a wide application prospect in the user-side energy trading market, and can effectively solve the complex problems in the user-side resource interactive trading. By establishing the user interaction bi-level programming model, it considered two levels: the upper level of sales e-commerce interaction transaction and the bottom level of user interaction demand response decision. The Scipy solver and genetic algorithm are used to solve the bi-level programming problem, which can realize the optimal allocation and efficient utilization of power resources under the premise of meeting the comfort of users. In the experimental analysis part, the experimental environment is constructed to deeply analyze the interaction between e-commerce sellers’ pricing and users’ electricity consumption decisions, and the e-commerce sellers’ optimal trading strategies in equilibrium market are discussed. The experimental results show that the proposed method has better performance and practicability in user-side resource interactive trading. Although this research has made some achievements in the user-side resource interactive transaction assisted decision-making method, there are still some limitations. For example, the model built in this paper still fails to fully cover market complex factors, and data collection and processing are limited, which will affect the accuracy of decision-making to a certain extent. Therefore, in the future, the application range of this method should be further expanded by considering more user types and needs, as well as more complex transaction scenarios, and the efficiency and accuracy of the algorithm should be improved.
Footnotes
Funding
This research was supported by Science and technology project of State Grid Shanxi Electric Power Company “Research and demonstration application of key technologies of user-side resource interactive trading for the spot market of electric power” (Grant number: 520531220002).
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
