Online constraint reinforcement learning method and device for single-constraint to-be-controlled system
Optimizing the distribution of sampling volume through simulation and sampling data distribution algorithms solves the feasibility and poor performance problems of control strategies in multi-energy microgrid operation and scheduling, achieves efficient online optimization control, and improves data efficiency and decision-making speed.
Patent Information
- Application Number
- CN202410804230.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-09-20
AI Technical Summary
In the existing technology, for the operation and scheduling of multi-energy microgrids in complex systems, online learning algorithms are difficult to guarantee the feasibility and performance of the control strategy, especially in the case of multiple feasible solutions, it is difficult to effectively optimize.
Through simulation and sampling data allocation algorithm, the Q factor and constraint function QH factor of each action are determined, and the sampling amount allocation is optimized to ensure that the probability of correctly selecting the optimal feasible action is maximized in each state, thereby improving the feasibility and effectiveness of the control strategy. performance.
It improves the efficiency and effect of online optimization control of single-constraint to-be-controlled systems, ensures the estimability of optimal actions, improves the data efficiency and time efficiency of online decision-making, and reduces data usage.
Smart Images

Figure CN118674067A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of reinforcement learning, and in particular to an online constraint reinforcement learning method and device for a single-constraint controlled system. Background Art
[0002] In the prior art, the operation and scheduling of multi-energy microgrids of complex systems can be achieved by intelligent online learning (such as reinforcement learning). Specifically, the existing online learning algorithms mainly include the following two categories:
[0003] The first type of learning process includes: first establishing the objective function and constraints, then optimizing the objective function performance to obtain a solution that satisfies the constraints, and finally, judging the feasibility of the solution (i.e., performing feasibility processing of the strategy) to obtain all the feasible strategies in the end;
[0004] The second type of learning process includes: first establishing the objective function and constraints in advance, then establishing an alternative objective function that is compatible with the objective function performance and constraints, and then optimizing the alternative objective function.
[0005] The first type of method mentioned above solves feasibility first and then solves optimization. However, since there are often many feasible solutions, in practical applications, optimization is performed based on some feasible solutions, that is, the search range of feasible strategies is limited to a true subset of the feasible domain, so it is difficult to guarantee the performance of the final feasible strategy. The second type of method mentioned above replaces the constrained problem with an unconstrained problem, which makes it difficult to guarantee the feasibility of the strategy during the learning process and cannot be used online. Summary of the invention
[0006] The present invention is used to solve the problems of low control strategy determination efficiency and poor control effect in the online optimization control of a single-constraint controlled system in the prior art.
[0007] In order to solve the above technical problems, the present invention provides a method comprising:
[0008] Simulate each action, and sample the simulation results of each action according to a preset sampling amount, and determine the optimal action, feasible action, and infeasible action to be observed based on the sampled simulation results;
[0009] The Q factor and sample variance of each feasible action and the optimal action are calculated based on the simulation results of each feasible action and the optimal action; the constraint function Q of each inactive action is calculated based on the simulation results of each inactive action. H Factor and sample variance; record the sample size consumed by each action and the total sample size consumed;
[0010] The sampling data allocation algorithm is used to calculate the Q factor and sample variance of each possible action and the optimal action, and the constraint function Q of each inactive action. HThe factors, sample variance, and total consumed samples are analyzed to obtain the target sample size for each action; the sampling data allocation algorithm is determined according to the objective function and constraint function of the system to be controlled, and is used to asymptotically maximize the probability of correctly selecting the optimal feasible action in each state;
[0011] Determine the additional sampling amount for each action based on the target sample amount for each action and the consumed sample amount for each action;
[0012] Supplementary sampling is performed according to the supplementary sampling amount of each action, and the Q factor and sample variance of the feasible action and the optimal action, as well as the constraint function Q of each infeasible action are re-determined using the simulation results of the supplementary sampling. H Factor and sample variances;
[0013] Adjust the total amount of consumed samples to determine whether the total amount of consumed samples is less than the preset total sampling amount. If so, recalculate the target sample amount and the subsequent steps. If not, output the final optimal action to the system to be controlled.
[0014] As a further embodiment of the present invention, the sampling data allocation algorithm determination process includes:
[0015] According to the equipment information and load information of the system to be controlled, system status, control action, optimization target information and constraint requirement information, establish the objective function of the control strategy and the constraint conditions of the constraint function;
[0016] The objective function of the control strategy is converted to obtain the action Q factor of reinforcement learning, and the constraint condition of the constraint function is converted to obtain the constraint function Q of reinforcement learning. H Factor constraints;
[0017] According to the action Q factor and constraint function Q H Factor constraints, establish the objective function and action sampling constraints of the approximate optimal action selection probability function;
[0018] According to the objective function of the approximate optimal action selection probability function and the action sampling quantity constraint, the criteria of the sampling data allocation algorithm are determined.
[0019] As a further embodiment of the present invention, the constraint condition of the constraint function is converted to obtain the constraint function Q of reinforcement learning H The constraint conditions of the factors include obtaining the constraint function Q expressed by the following formula H Factor constraints:
[0020]
[0021] Among them, Q H k+1is the value function defined by the constraint function in the k+1th iteration; a is the action; D is π k (s), represents the steady-state probability of state s in the kth iteration; H0 is the preset value; π k (s') represents the steady-state probability of state s' in the kth iteration, Indicates that action d is taken in state s' in the kth iteration k The constraint function Q of (s′) H Factor value.
[0022] As a further embodiment of the present invention, according to the action Q factor and the constraint function Q H The constraints of the factors are used to establish the objective function of the approximate optimal action selection probability function and the constraints of the action sampling amount, including:
[0023] According to the action Q factor and constraint function Q H Factor constraints, establish the true optimal action selection probability function and action sampling quantity constraints;
[0024] The true optimal action selection probability function is transformed to obtain an approximate optimal action selection probability function.
[0025] As a further embodiment of the present invention, the objective function of the approximate optimal action selection probability function and the action sampling amount constraint condition are expressed by the following formula:
[0026] max APCS
[0027] st∑ i N i =N;
[0028]
[0029] Among them, APCS is the approximate optimal action selection probability function; N i is the sampling volume of action i; N is the total sampling volume; Q k+1 (s,a b ) means taking an action a in state s b The Q factor of the current iteration; Q k+1 (s,a i ) means taking an action a in state s i The Q factor of the current iteration; Indicates that an inaction is taken in state s i The constraint function Q of the next iteration is H factor; represents the boundary condition of the constraint function; D is π k(s), represents the steady-state probability of state s in the kth iteration; H0 is the preset value; π k (s') represents the steady-state probability of state s' in the kth iteration, Indicates that action d is taken in state s' in the kth iteration k The constraint function Q of (s′) H Factor value; Indicates taking any action a in state s b The constraint function Q of the next iteration is H factor.
[0030] As a further embodiment of the present invention, the sampling data allocation algorithm includes a criterion that satisfies the following conditions:
[0031] The larger the first noise-to-signal ratio of the actionable action, the larger the sampling amount of the actionable action, wherein the first noise-to-signal ratio is the ratio of the sample standard deviation of the action Q factor to the difference between the optimal action Q factor and the action Q factor;
[0032] The larger the second noise-to-signal ratio of the inactive action, the larger the sampling amount of the inactive action, where the second noise-to-signal ratio is the action constraint function Q H Sample variance of factors and optimal action constraint function Q H Factor and the action constraint function Q H The ratio of the factor differences;
[0033] The sampling amount of the optimal action is more than the sampling amount of the feasible action;
[0034] The sampling amount of the optimal action and the inaction action is proportional to the square of the second noise-to-signal ratio of the optimal action and the inaction action.
[0035] As a further embodiment of the present invention, the sampling data allocation algorithm includes the following criteria:
[0036] Criterion 1: When i and j represent observational actions,
[0037] Among them, N i and N j represents the sampling amount of observing the action i and j, σ i and σ j represents the sample standard deviation of the Q factor of the action i and j, δ b,i =Q k+1 (s,a b )-Q k+1 (s,a i ), δ b,j =Q k+1 (s,a b )-Q k+1 (s,aj );
[0038] Criterion 2: When i and j represent observations of inoperable actions,
[0039] Among them, N i and N j represents the sampling amount of observing the inoperable actions i and j, σ h,i and σ h,j The constraint function Q that represents the observation of the inactive actions i and j H The sample variance of the factor;
[0040]
[0041] Criterion 3: When i represents an observable action,
[0042] Among them, N b represents the sampling amount of the optimal action, N i represents the sampling amount of the observed action i, σ b represents the sample standard deviation of the Q factor of the optimal action b, σ i represents the sample standard deviation of the Q factor for action i, represents the best action to observe;
[0043] Criterion 4: When i represents an unobservable non-action,
[0044] Among them, N b represents the sampling amount of the optimal action, N i represents the number of samples to observe the inactive action i, σ h,b The constraint function Q representing the optimal action b H Sample variance of the factor, σ h,i is the constraint function Q for observing the inactive action i H The sample variance of the factor;
[0045]
[0046] k represents the number of iterations, Q k+1 (s,a) represents the Q factor value of taking action a in state s in the kth iteration, Represents the constraint function Q for taking action a in state s in the kth iteration H Factor value, H0 represents the preset value, D is π k (s), represents the steady-state probability of state s in the kth iteration, π k (s') represents the steady-state probability of state s' in the kth iteration, Indicates that action d is taken in state s' in the kth iteration k The constraint function Q of (s′) H Factor value.
[0047] As a further embodiment of the present invention, the Q factor and sample variance of each possible action and the optimal action, and the constraint function Q of each inactive action are calculated by using a sampling data allocation algorithm. H The factors, sample variance, and total consumed samples are analyzed to obtain the target sample size for each action, including:
[0048] According to the sampling data allocation algorithm and the action sampling quantity constraint conditions, the Q factor and sample variance of each observed action and the optimal action, and the constraint function Q of each observed inaction are calculated. H Analyze factors and sample variance and calculate the target sample size ratio for each action;
[0049] The number of samples that should be obtained for each action is obtained by multiplying the target sample number ratio of each action by the total number of consumed samples;
[0050] The larger of the number of samples that each action should obtain and the number of samples actually used by each action is selected as the target number of samples for each action.
[0051] A second aspect of the present invention provides an online constraint reinforcement learning device for a single-constraint system to be controlled, the device comprising:
[0052] A simulation unit, used to simulate each action, sample the simulation results of each action according to a preset sampling amount, and determine the optimal action, feasible action and infeasible action to be observed according to the sampled simulation results;
[0053] The first calculation unit is used to calculate the Q factor and sample variance of each movable action and the optimal action according to the simulation results of each movable action and the optimal action; calculate the constraint function Q of each inactive action according to the simulation results of each inactive action H Factor and sample variance; record the sample size consumed by each action and the total sample size consumed;
[0054] The second calculation unit is used to use the sampling data allocation algorithm to calculate the Q factor and sample variance of each possible action and the optimal action, and the constraint function Q of each inactive action. H The factors, sample variance, and total consumed samples are analyzed to obtain the target sample size for each action; the sampling data allocation algorithm is determined according to the objective function and constraint function of the system to be controlled, and is used to asymptotically maximize the probability of correctly selecting the optimal feasible action in each state;
[0055] A third calculation unit is used to determine the supplementary sampling amount of each action according to the target sample amount of each action and the consumed sample amount of each action;
[0056] The supplementary sampling unit is used to perform supplementary sampling according to the supplementary sampling amount of each action, and use the simulation results of the supplementary sampling to re-determine the Q factor and sample variance of the feasible action and the optimal action, and the constraint function Q of each infeasible action. H Factor and sample variances;
[0057] The control unit is used to adjust the total amount of consumed samples and determine whether the total amount of consumed samples is less than the preset total sampling amount. If so, recalculate the target sample amount and the subsequent steps. If not, output the final optimal action to the system to be controlled.
[0058] A third aspect of the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in any of the foregoing embodiments when executing the computer program.
[0059] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of a computer device, the method described in any of the above embodiments is implemented.
[0060] The online constrained reinforcement learning method and device for a single-constrained controlled system provided by the present invention are applicable to a single-constrained (i.e., one-constraint) controlled system. The sampling data allocation algorithm is predetermined according to the objective function and constraint function of the controlled system. With the help of the sampling data allocation algorithm, the probability of correctly selecting the optimal feasible action in each state can be asymptotically maximized, and the simulation resources can be concentrated on the actions that really need to be distinguished, so that the observation results of each action are more and more accurate, and the optimal action is finally obtained. Compared with the prior art, the full set of feasible strategies is considered, and the estimability of the selection of the optimal action can be guaranteed, which can improve the performance of the final determination of the action. At the same time, through the control of the sampling amount, this case can also improve the data efficiency of online reinforcement learning in the operation and scheduling process of the controlled system, significantly improve the time required for online decision-making, and reduce the amount of data used.
[0061] In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0063] Figure 1 A flow chart showing a sampling data allocation algorithm criterion determination process according to an embodiment of the present invention is shown;
[0064] Figure 2 A flowchart showing the objective function of the approximate optimal action selection probability function and the process of determining the action sampling amount constraint condition according to an embodiment of the present invention is shown;
[0065] Figure 3 A flow chart of an online constraint reinforcement learning method for a single-constraint controlled system according to an embodiment of the present invention is shown;
[0066] Figure 4 A flow chart showing a process for determining the sampling amount of each action target in an embodiment of the present invention is shown;
[0067] Figure 5 A structural diagram of an online constraint reinforcement learning device for a single-constraint controlled system according to an embodiment of the present invention is shown;
[0068] Figure 6 A structural diagram of a computer device according to an embodiment of the present invention is shown;
[0069] Figure 7 The flowchart of the program design of the online constraint reinforcement learning method for a single-constraint controlled system according to an embodiment of the present invention is shown.
[0070] Description of the accompanying symbols:
[0071] 501, simulation unit;
[0072] 502. a first computing unit;
[0073] 503, a second computing unit;
[0074] 504, a third computing unit;
[0075] 505. Supplementary sampling unit;
[0076] 506. Control unit;
[0077] 602. Computer equipment;
[0078] 604, processor;
[0079] 606. Memory;
[0080] 608, driving mechanism;
[0081] 610, input / output module;
[0082] 612. Input devices;
[0083] 614. Output devices;
[0084] 616. Presentation equipment;
[0085] 618. Graphical user interface;
[0086] 620, network interface;
[0087] 622, communication link;
[0088] 624. Communication bus. DETAILED DESCRIPTION
[0089] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0090] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0091] This specification provides method operation steps as described in the embodiments or flow charts, but more or fewer operation steps may be included based on routine or non-creative work. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only execution order. When the system or device product is executed in practice, it can be executed in the order of the method shown in the embodiments or the drawings or in parallel.
[0092] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0093] It should be noted that the online constraint reinforcement learning method and device for a single-constraint controlled system of the present invention can be used in the field of multi-energy microgrids, such as the scenario where a multi-energy microgrid charges electric vehicles through a charging pile, and can also be used in any field other than the power field, such as the field of automatic driving scheduling. The present invention does not limit the application field of the online constraint reinforcement learning method and device for a single-constraint controlled system. As long as a complex system with a single constraint and online control requirements can be controlled online by the method of the present invention.
[0094] For a single-constrained system to be controlled, before implementing the online constraint reinforcement learning method, a sampling data allocation algorithm needs to be established in advance. Specifically, Figure 1 As shown, including:
[0095] Step 101, based on the equipment information and load information of the system to be controlled, the system state, the control action, the optimization target information and the constraint requirement information, the constraint conditions of the objective function and the constraint function of the control strategy are established.
[0096] Step 102: convert the objective function to obtain the action Q factor of reinforcement learning, and convert the constraint condition of the constraint function to obtain the constraint function Q of reinforcement learning. H Factor constraints.
[0097] Step 103: Based on the action Q factor and the constraint function Q H The constraints of the factors are used to establish the objective function and action sampling quantity constraints of the approximate optimal action selection probability function.
[0098] Step 104, determining the criteria of the sampling data allocation algorithm according to the objective function of the approximate optimal action selection probability function and the action sampling quantity constraint condition.
[0099] In detail, the device information, load information, system state, control action, optimization target information and constraint requirement information in step 101 can be determined according to the specific situation of the system to be controlled, and the present invention does not limit the specific parameters included therein. An objective function is established according to the device information, load information, system state, control action and optimization target, and a constraint condition of the constraint function is established according to the device information, load information, system state, control action and constraint requirement information.
[0100] In one implementation, the constraints of the objective function and the constraint function can be expressed using the following formula:
[0101]
[0102] Among them, J is the objective function, s t is the state of the system to be controlled at time t, d is the strategy, d(s t ) is the strategy d in state st action under , c is the target object function, T is the length of the simulation period; h is the constraint function, and H0 is a given constant.
[0103] Taking the multi-energy microgrid as an example, the system to be controlled is a multi-energy microgrid with multiple energy sources (such as wind energy, solar energy, and urban power grid) and multiple equipment (such as power consumption equipment, energy storage equipment, and power generation equipment). In order to reduce costs, self-built wind energy, solar energy, fuel cell and other power generation equipment and energy storage equipment. Through reasonable scheduling of equipment, especially the charging and discharging scheduling of energy storage equipment, the multi-energy microgrid can charge electric vehicles through charging piles at a price lower than the electricity price of the urban power grid, and charge charging service fees. Although there is a certain flexibility in the completion time of electric vehicle charging, it cannot be postponed indefinitely, and charging and electricity demand that is not met in time will incur liquidated damages. Therefore, in the scenario of charging electric vehicles in a multi-energy microgrid, the optimization goal is to schedule each device (especially the charging power of energy storage equipment and charging piles) to minimize operating costs, and the constraint condition is that the liquidated damages are less than the predetermined value.
[0104] Correspondingly, the above J represents the multi-energy microgrid operation cost target, that is, the average cost of multi-energy microgrid operation should be minimized; s t represents the state of the multi-energy microgrid at time t, including but not limited to solar power generation, wind power generation, number of people in each room of the building, IT load, electric vehicle charging demand, energy storage level of energy storage equipment, real-time electricity price of the large power grid, etc.; d is the strategy; d(s t ) represents the control action of the system to be controlled, including charging, discharging, or neither charging nor discharging the energy storage device, the charging power of each charging pile, and the amount of electricity purchased from the city power grid; c represents the cost of purchasing electricity from the city power grid minus the charging income collected from electric vehicle users; h represents the penalty for failure to meet the electricity demand at time t; H(d) indicates that the average penalty should not exceed the given value H0.
[0105] When the above step 102 is implemented, the following action Q factor and action constraint function Q can be established according to the above formulas (1) and (2): H :
[0106]
[0107] Among them, Q(s,a) is the Q value function of the action in state s, Q H (s,a) is the action constraint function Q in state s H , c is the target object function, h is the constraint function, s' is the future state, P a (s, s') is the probability of transitioning to the next state s' when taking action a in state s, Q(s', d(s')) is the Q factor of the action in state s', Q H(s',d(s')) is the action constraint function Q under state s' H factor.
[0108] Furthermore, due to P a (s, s') is usually not available, the action value function of formula (3) and the action constraint function of formula (4) can be obtained using the following observation formula:
[0109]
[0110] in, is the estimated value of Q(s,a), Q H The estimated value of (s,a), k is the number of iterations, N a is the sampling times of action a.
[0111] According to the problem structure of online reinforcement learning and formula (5), the objective function and constraints expressed by formulas (1) and (2) are transformed to obtain the optimization model expressed by the following formula:
[0112]
[0113] H k+1 (d k+1 )≤H0 (8)
[0114] Where a represents an action. Taking multi-energy microgrid control as an example, the actions include charging, discharging, or neither charging nor discharging of energy storage equipment, the charging power of each charging pile, or whether it is charged or not, etc. A is the action space, which is a set of all possible actions. is the observed value of the Q factor, and k is the iteration number.
[0115] Compared with the problem in formula (1) (2), the problem form in formula (7) (8) decomposes the performance requirements for the entire strategy d into the requirements for optimizing actions under the current state s during online operation.
[0116] Convert formula (8) into constraint function Q H The constraints of the factors, the specific transformations include:
[0117]
[0118] When the strategy d of the k+1th iteration is obtained k+1 When the k+1th strategy d k+1 With the k-th strategy d k The difference between them is the state s, from which we can get:
[0119]
[0120] Among them, d k+1 (s)≠d k (s);
[0121] Further, we can get:
[0122]
[0123] make D=π k (s), so we can get the following formula:
[0124]
[0125] Combining the above formula with formula (8), we can infer the following constraint function Q H Factor constraints:
[0126]
[0127] Where D is π k (s), represents the steady-state probability of state s in the kth iteration; Q H k+1 (s,a) is the value of the value function defined by the constraint function in the k+1th iteration; a is the action, and H0 is the preset value;
[0128] π k (s') represents the steady-state probability of state s' in the kth iteration, Indicates that action d is taken in state s' in the kth iteration k The constraint function Q of (s′) H Factor value.
[0129] The corresponding objective function is expressed as:
[0130] This step explicitly transforms the feasibility determination problem of strategy d into the feasibility determination of different actions a. This decoupling decisively improves the data efficiency of the entire algorithm.
[0131] When the above step 103 is implemented, if Figure 2 As shown, including:
[0132] Step 201: Based on the action Q factor and the constraint function Q H Factor constraints, establish the true optimal action selection probability function and action sampling quantity constraints;
[0133] Specifically, the true optimal action selection probability function and action sampling constraint conditions are expressed as follows:
[0134] Max N1,...N|A|PCS, stN1+N2+...+N |A| =N (10)
[0135] Among them, N i is the amount of sampled data obtained for action i, |A| is the size of the discrete action space A, N represents the total amount of sampled data in each state during online reinforcement learning, and PCS (Probability of Correct Selection, i.e., the probability of selecting the best action) is defined as follows:
[0136]
[0137] PCS means the probability that the observed optimal action is indeed the true optimal action. For example, at a certain moment, the solar and wind power generation of the multi-energy microgrid is large, and the building electricity demand and the total charging demand of electric vehicles are relatively small. At this time, the true optimal action may be to charge the energy storage device and charge each charging pile. If the optimal action estimated based on the simulation observation data is also the same, then the true optimal action in the current state is correctly selected.
[0138] PCS describes the probability of this random event occurring.
[0139] Step 202: transform the true optimal action selection probability function to obtain an approximate optimal action selection probability function.
[0140] The objective function of the approximate optimal action selection probability function and the action sampling constraint are expressed using the following formula:
[0141] max APCS
[0142] st∑ i N i =N (12)
[0143]
[0144] Among them, APCS is the approximate optimal action selection probability function; N i is the sampling volume of action i; N is the total sampling volume; Q k+1 (s,a b ) means taking an action a in state s b The Q factor of the current iteration; Q k+1 (s,a i ) means taking an action a in state s i The Q factor of the current iteration; Indicates that an inaction is taken in state s i The constraint function Q of the next iteration is H factor; represents the boundary condition of the constraint function; D is π k (s), represents the steady-state probability of state s in the kth iteration; H0 is the preset value; Indicates taking any action a in state s b The constraint function Q of the next iteration is H factor.
[0145] The implementation process of step 104 includes:
[0146] When the total number of sampling times is set to N, the objective function of the approximate optimal action selection probability function and the action sampling quantity constraint condition are expressed by formula (12) as follows:
[0147]
[0148] According to formulas (13) and (14), the Lagrangian function is defined as:
[0149]
[0150] Here, λ is the Lagrange multiplier.
[0151] For the observed action i, the number of samples N i Considering it as a variable, the derivative of formula (15) can be obtained:
[0152]
[0153] in:
[0154]
[0155] Thus we can get:
[0156]
[0157] For the observation of an inactive action i, the number of samples N i Considered as a variable, based on formula (15), we can get:
[0158]
[0159] in,
[0160]
[0161] Thus we can get:
[0162]
[0163] The best action for observation Introduce two sampling variables Nb1 and N b2 To prove that it is feasible and optimal, based on formula (15), we can get:
[0164]
[0165] Transforming formula (18) can obtain the following formula:
[0166]
[0167] Substituting formula (23) into formula (22), we can obtain:
[0168]
[0169] Then we can get:
[0170]
[0171] Next, we study the number of samples N of the possible actions i and j. i With N j According to formula (18), we can get the relationship between
[0172]
[0173] Assume N b1 N i and N j Good, that is, N b1 >>N i ,N b1 >>N j , we can get:
[0174]
[0175]
[0176] Then formula (25) can be rewritten as:
[0177]
[0178] Further we get:
[0179]
[0180] Taking the natural logarithm of both sides of the previous formula gives:
[0181]
[0182] Let N i =α i N,N j =α jN, then ∑ i α i =1, when N→∞, the logarithmic term is obviously smaller than other terms, then we can get:
[0183]
[0184] Similarly, for the observation of the inactive actions i and j, we can obtain the conclusion similar to formula (26):
[0185]
[0186] Similarly, for observing the optimal action b2 and observing the infeasible action i, we can get a conclusion similar to formula (26):
[0187]
[0188] In summary, through the above analysis, we can get the criteria of the sampling data allocation algorithm:
[0189] Criterion 1: When i and j represent observational actions,
[0190] Among them, N i and N j represents the sampling amount of observing the action i and j, σ i and σ j is the sample standard deviation of the Q factor of the action i and j, δ b,i =Q k+1 (s,a b )-Q k+1 (s,a i ), δ b,j =Q k+1 (s,a b )-Q k+1 (s,a j );
[0191] b represents the optimal action;
[0192] Criterion 2: When i and j represent observations of inoperable actions,
[0193] Among them, N i and N j represents the sampling amount of observing the inoperable actions i and j, σ h,i and σ h,j The constraint function Q that represents the observation of the inactive actions i and j H The sample variance of the factor;
[0194]
[0195] Criterion 3: When i represents an observable action,
[0196] Among them, N b represents the sampling amount of the optimal action, N i represents the sampling amount of the observed action i, σ b represents the sample standard deviation of the Q factor of the optimal action b, σ i represents the sample standard deviation of the Q factor for action i, represents the best action to observe;
[0197] Criterion 4: When i represents an unobservable non-action,
[0198] Among them, N b represents the sampling amount of the optimal action, N i represents the number of samples to observe the inactive action i, σ h,b The constraint function Q representing the optimal action b H Sample variance of the factor, σ h,i is the constraint function Q for observing the inactive action i H The sample variance of the factor;
[0199]
[0200] k represents the number of iterations, Q k+1 (s,a) represents the Q factor value of taking action a in state s in the kth iteration, Represents the constraint function Q for taking action a in state s in the kth iteration H Factor value, H0 represents the preset value, D is π k (s), represents the steady-state probability of state s in the kth iteration.
[0201] Specifically, when a single letter x represents an action, where x is, for example, i, j, or b, it is x The meaning is the same, that is, a x It also indicates action.
[0202] Criterion 1 states that the number of samples of the observed feasible actions i and j should be proportional to the square of their respective "noise-to-signal ratios", where the noise image describes the sample standard deviation of a single observation of the Q factor of the action, and the signal image describes the difference between the Q factor performance of the action and the optimal action. When the "noise" of the action performance is greater, the action should receive a larger number of samples; when the action performance is significantly worse than the currently observed optimal action, it should receive fewer samples.
[0203] Criterion 2 states that the number of samples for actions i and j that are not feasible to observe should be proportional to the square of their respective "constraint noise-to-signal ratio". The "constraint noise" here vividly describes the constraint function Q of the action. H The sample standard deviation of a single observation of the factor, the signal image describes the constraint function Q between the action and the optimal action H Similar to criterion 1, criterion 2 distributes the sampling amount among actions for which observation is not feasible in a manner proportional to the square of the “constrained noise-to-signal ratio”.
[0204] Criterion 3 states that the best observed action should be sampled more often to ensure that its performance is indeed optimal. This criterion, together with Criterion 1, defines the number of samples between observed feasible actions.
[0205] Criterion 4 states that the amount of sampling between an infeasible action and the best action should be proportional to the square of its "constrained noise-to-signal ratio". This criterion, together with Criterion 2, defines the amount of sampling between infeasible actions and establishes a proportional relationship between the amount of sampling between infeasible actions and the amount of sampling between the best action.
[0206] The above four criteria calculate the proportional relationship of the sampling amount that all actions should obtain under the current state based on the current samples. In the multi-energy microgrid operation and scheduling application, the sampling computing resources are allocated in an iterative manner.
[0207] In one embodiment of the present invention, on the basis of establishing a sampling data allocation algorithm, online constrained reinforcement learning can be performed. Specifically, Figure 3 As shown, including:
[0208] Step 301 , simulate each action, and sample the simulation results of each action according to a preset sampling amount, and determine the observed optimal action, feasible actions, and infeasible actions according to the sampled simulation results.
[0209] The actions in this step can be determined according to the action space. For example, in a scenario where ten vehicles are charged, each vehicle has two actions: charging and not charging. Then, the ten vehicles combined will have 1024 actions.
[0210] The preset sampling amount (N0) can be set according to the preset total sampling amount N, the preset number of cycles, the action space and the newly added sampling amount △. Generally, the preset number of cycles is greater than 10, and the preset total sampling amount N is much greater than the preset sampling amount N0 multiplied by the action amount in the action space.
[0211] The actions in this step can directly act on the simulation model of the system to be controlled (such as a digital twin model), and the simulation results of each action can be determined by the simulation model. In specific implementation, the execution results of a preset sampling amount can also be obtained from historical data according to the state and action, and the obtained execution results can be used as simulation results.
[0212] Step 302: Calculate the Q factor and sample variance of each action and the optimal action according to the simulation results of each action and the optimal action; Calculate the constraint function Q of each action according to the simulation results of each inactive action. H Factor and sample variance; record the sample size consumed by each action and the total sample size consumed.
[0213] Specifically, the sample standard deviation of the Q factor of the feasible action / optimal action in this step is calculated based on the Q factor of each sampling number of the feasible action / optimal action. H The sample variance of the factor is based on the constraint function Q of each sampling number of the inaction action H The specific calculation method can refer to the existing variance calculation formula.
[0214] In this step, the total amount of consumed samples is the product of the preset sampling amount and the action space plus the newly added sampling amount △.
[0215] Step 303: Use the sampling data allocation algorithm to calculate the Q factor and sample variance of each possible action and the optimal action, and the constraint function Q of each inactive action. H The factors, sample variance and total consumed samples are analyzed to obtain the target sample size for each action.
[0216] The sample size of each action target obtained in this step can maximize the probability of selecting the approximate optimal action.
[0217] Step 304, determining the supplementary sampling amount for each action according to the target sample amount for each action and the consumed sample amount for each action.
[0218] When this step is implemented, the target sample size of each action is subtracted from the consumed sample size of each action to obtain the supplementary sampling size of each action.
[0219] Step 305: perform supplementary sampling according to the supplementary sampling amount of each action, and use the simulation results of the supplementary sampling to re-determine the Q factor and sample variance of the feasible action and the optimal action, and the constraint function Q of each infeasible action. H Factor and sample variance.
[0220] Step 306, adjust the total amount of consumed samples, determine whether the total amount of consumed samples is less than the preset total sampling amount, if so, return to re-execute step 303, if not, output the final optimal action to the system to be controlled.
[0221] When this step is implemented, the consumed sampling amount is increased by the newly added sampling amount △ to obtain the adjusted total consumed sampling amount. The action sampling amount constraint condition is the preset total sampling amount N, which can be set according to the preset sampling amount initial value and action space in step 301, as long as the preset number of steps 301 to 306 can be repeated.
[0222] In this step, if the total amount of consumed samples is less than or equal to the action sampling amount constraint, it means that the consumed sampling amount after the next iteration has not reached or is exactly equal to the preset total sampling amount, and the feasibility of the action can continue to be observed in a loop. If the total amount of consumed samples is greater than the action sampling amount constraint, it means that the consumed sampling amount after the next iteration exceeds the preset total sampling amount, and the feasibility of the action cannot be observed.
[0223] In a specific implementation manner, the algorithm flow of this embodiment is as follows Figure 7 shown. Figure 7 Where n0 is the preset sampling amount, a is the action, is the action space, are the sample standard deviation of the Q factor of each action, the constraint function Q H The sample variance of the factor, is the number of consumed samples, △ is the number of newly added samples, N is the preset total sample size, α i is the sample size ratio that action i should obtain, is the number of samples that action i should obtain, N i is the number of samples consumed by action i, N i ' is the target sample size for action i, N i '-N i Supplement the sampling amount for action i.
[0224] This embodiment predetermines the sampling data allocation algorithm based on the objective function and constraint function of the system to be controlled. With the help of the sampling data allocation algorithm, the probability of correctly selecting the optimal feasible action can be gradually maximized in each state. Compared with the prior art, it takes into account the full set of feasible strategies and can ensure the estimability of the selection of the optimal action. It concentrates simulation resources on the actions that really need to be distinguished, making the observation results of each action more and more accurate, and finally obtaining the optimal action, thereby improving the performance of the final determined action. At the same time, this case can also improve the data efficiency of online reinforcement learning during the operation and scheduling of the system to be controlled by controlling the sampling amount, significantly improve the time required for online decision-making, and reduce data usage.
[0225] In one embodiment of the present invention, Figure 4 As shown, the above step 303 calculates the Q factor and sample variance of each possible action and the optimal action, and the constraint function Q of each inactive action according to the sampling data allocation algorithm. HThe factors, sample variance, and total consumed samples are analyzed to obtain the target sample size for each action, including:
[0226] Step 401: According to the sampling data allocation algorithm and the action sampling amount constraint condition, the Q factor and sample variance of each possible action and the optimal action, and the constraint function Q of each inactive action are calculated. H Factors and sample variances are used to calculate the target sample size ratio for each action.
[0227] Step 402, the number of samples that should be obtained for each action is obtained by multiplying the target sample number ratio of each action by the total number of consumed samples.
[0228] Step 403: Select the larger of the number of samples that should be obtained for each action and the number of samples actually used for each action as the target number of samples for each action.
[0229] Based on the same inventive concept, the present invention also provides an online constraint reinforcement learning device for a single-constraint system to be controlled, as described in the following embodiments. Since the principle of solving the problem by the online constraint reinforcement learning device for a single-constraint system to be controlled is similar to the online constraint reinforcement learning method for a single-constraint system to be controlled, the implementation of the online constraint reinforcement learning device for a single-constraint system to be controlled can refer to the online constraint reinforcement learning method for a single-constraint system to be controlled, and the repeated parts will not be repeated.
[0230] Specifically, Figure 5 As shown, the online constraint reinforcement learning device for a single-constraint system to be controlled includes:
[0231] The simulation unit 501 is used to simulate each action, and sample the simulation results of each action according to a preset sampling amount, and determine the observed optimal action, feasible actions and infeasible actions according to the sampled simulation results.
[0232] The first calculation unit 502 is used to calculate the Q factor and sample variance of each movable action and the optimal action according to the simulation results of each movable action and the optimal action; calculate the constraint function Q of each inactive action according to the simulation results of each inactive action. H Factor and sample variance; record the sample size consumed by each action and the total sample size consumed.
[0233] The second calculation unit 503 is used to use the sampling data allocation algorithm to calculate the action sampling amount constraint conditions, the Q factor and sample variance of each feasible action and the optimal action, and the constraint function Q of each infeasible action. H Factor and sample variance, total sample consumed An analysis is performed to obtain the target sample size of each action; the sampling data allocation algorithm is determined according to the objective function and constraint function of the system to be controlled, and is used to gradually maximize the probability of correctly selecting the optimal feasible action in each state.
[0234] The third calculation unit 504 is used to determine the supplementary sampling amount of each action according to the target sample amount of each action and the consumed sample amount of each action.
[0235] The supplementary sampling unit 505 is used to perform supplementary sampling according to the supplementary sampling amount of each action, and use the simulation results of the supplementary sampling to re-determine the Q factor and sample variance of the feasible action and the optimal action, and the constraint function Q of each infeasible action. H Factor and sample variance.
[0236] The control unit 506 is used to adjust the total amount of consumed samples and determine whether the total amount of consumed samples is less than the preset total sampling amount. If so, recalculate the target sample amount and the subsequent steps. If not, output the final optimal action to the system to be controlled.
[0237] This embodiment predetermines the sampling data allocation algorithm based on the objective function and constraint function of the system to be controlled. With the help of the sampling data allocation algorithm, the probability of correctly selecting the optimal feasible action can be gradually maximized in each state. Compared with the prior art, it takes into account the full set of feasible strategies and can ensure the estimability of the selection of the optimal action. It concentrates simulation resources on the actions that really need to be distinguished, making the observation results of each action more and more accurate, and finally obtaining the optimal action, thereby improving the performance of the final determined action. At the same time, this case can also improve the data efficiency of online reinforcement learning during the operation and scheduling of the system to be controlled by controlling the sampling amount, significantly improve the time required for online decision-making, and reduce data usage.
[0238] In one embodiment of the present invention, a computer device is also provided. Figure 6As shown, the computer device 602 may include one or more processors 604, such as one or more central processing units (CPUs), each of which may implement one or more hardware threads. The computer device 602 may also include any memory 606, which is used to store any kind of information such as code, settings, data, etc. Non-limitingly, for example, the memory 606 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory may use any technology to store information. Further, any memory may provide volatile or non-volatile retention of information. Further, any memory may represent a fixed or removable component of the computer device 602. In one case, when the processor 604 executes an associated instruction stored in any memory or a combination of memories, the computer device 602 may perform any operation of the associated instruction. The computer device 602 also includes one or more drive mechanisms 608 for interacting with any memory, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.
[0239] The computer device 602 may also include an input / output module 610 (I / O) for receiving various inputs (via input device 612) and for providing various outputs (via output device 614). A specific output mechanism may include a presentation device 616 and an associated graphical user interface 618 (GUI). In other embodiments, the input / output module 610 (I / O), input device 612, and output device 614 may not be included, and the computer device 602 may be used as a computer device in a network. The computer device 602 may also include one or more network interfaces 620 for exchanging data with other devices via one or more communication links 622. One or more communication buses 624 couple the components described above together.
[0240] The communication link 622 may be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 622 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc. governed by any protocol or combination of protocols.
[0241] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described in any of the above embodiments is executed.
[0242] An embodiment of the present invention further provides a computer-readable instruction, wherein when a processor executes the instruction, the program therein causes the processor to execute the method described in any of the aforementioned embodiments.
[0243] It should be understood that in various embodiments of the present invention, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0244] It should also be understood that in the embodiments of the present invention, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present invention generally indicates that the associated objects before and after are in an "or" relationship.
[0245] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the present invention can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0246] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0247] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.
[0248] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.
[0249] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0250] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0251] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. An online constraint reinforcement learning method for a single-constraint controlled system, characterized in that: The method comprises: Simulate each action, sample the simulation results of each action according to a preset sampling amount, and determine the optimal action, feasible action, and infeasible action to be observed based on the sampled simulation results; The Q factor and sample variance of each feasible action and the optimal action are calculated based on the simulation results of each feasible action and the optimal action; the constraint function Q of each inactive action is calculated based on the simulation results of each inactive action. H Factor and sample variance; record the sample size consumed by each action and the total sample size consumed; The sampling data allocation algorithm is used to calculate the Q factor and sample variance of each possible action and the optimal action, and the constraint function Q of each inactive action. H The factors, sample variance, and total consumed samples are analyzed to obtain the target sample size for each action; the sampling data allocation algorithm is determined according to the objective function and constraint function of the system to be controlled, and is used to asymptotically maximize the probability of correctly selecting the optimal feasible action in each state; Determine the additional sampling amount for each action based on the target sample amount for each action and the consumed sample amount for each action; Supplementary sampling is performed according to the supplementary sampling amount of each action, and the Q factor and sample variance of the feasible action and the optimal action, as well as the constraint function Q of each infeasible action are re-determined using the simulation results of the supplementary sampling. H Factor and sample variances; Adjust the total amount of consumed samples to determine whether the total amount of consumed samples is less than the preset total sampling amount. If so, recalculate the target sample amount and the subsequent steps. If not, output the final optimal action to the system to be controlled.
2. The method according to claim 1, characterized in that The sampling data allocation algorithm determination process includes: According to the equipment information and load information of the system to be controlled, system status, control action, optimization target information and constraint requirement information, establish the objective function of the control strategy and the constraint conditions of the constraint function; The objective function of the control strategy is converted to obtain the action Q factor of reinforcement learning, and the constraint condition of the constraint function is converted to obtain the constraint function Q of reinforcement learning. H Factor constraints; According to the action Q factor and constraint function Q H Factor constraints, establish the objective function and action sampling constraints of the approximate optimal action selection probability function; According to the objective function of the approximate optimal action selection probability function and the action sampling quantity constraint, the criteria of the sampling data allocation algorithm are determined.
3. The method according to claim 2, characterized in that The constraint conditions of the constraint function are transformed to obtain the constraint function Q of reinforcement learning H The constraint conditions of the factors include obtaining the constraint function Q expressed by the following formula H Factor constraints: Among them, Q H k+1 is the value function defined by the constraint function in the k+1th iteration; a is the action; D is π k (s), represents the steady-state probability of state s in the kth iteration; H0 is the preset value; π k (s') represents the steady-state probability of state s' in the kth iteration, Indicates that action d is taken in state s' in the kth iteration k (s′) is the constraint function QH factor value.
4. The method according to claim 2, characterized in that According to the action Q factor and constraint function Q H The constraints of the factors are used to establish the objective function of the approximate optimal action selection probability function and the constraints of the action sampling amount, including: According to the action Q factor and constraint function Q H Factor constraints, establish the true optimal action selection probability function and action sampling quantity constraints; The true optimal action selection probability function is transformed to obtain an approximate optimal action selection probability function.
5. The method according to claim 4, characterized in that The objective function of the approximate optimal action selection probability function and the action sampling constraint are expressed using the following formula: max APCS s.t.∑ i N i =N; Among them, APCS is the approximate optimal action selection probability function; N i is the sampling volume of action i; N is the total sampling volume; Q k+1 (s,a b ) means taking an action a in state s b The Q factor of the current iteration; Q k+1 (s,a i ) means taking an action a in state s i The Q factor of the current iteration; Indicates that an inaction is taken in state s i The constraint function Q of the next iteration is H factor; represents the boundary condition of the constraint function; D is π k (s), represents the steady-state probability of state s in the kth iteration; H0 is the preset value; π k (s') represents the steady-state probability of state s' in the kth iteration, Indicates that action d is taken in state s' in the kth iteration k The constraint function Q of (s′) H Factor value; Indicates taking any action a in state s b The constraint function Q of the next iteration is H factor.
6. The method according to claim 1, characterized in that The sampling data allocation algorithm includes criteria that satisfy the following conditions: The larger the first noise-to-signal ratio of the actionable action, the larger the sampling amount of the actionable action, wherein the first noise-to-signal ratio is the ratio of the sample standard deviation of the action Q factor to the difference between the optimal action Q factor and the action Q factor; The larger the second noise-to-signal ratio of the inactive action, the larger the sampling amount of the inactive action, where the second noise-to-signal ratio is the action constraint function Q H Sample variance of factors and optimal action constraint function Q H Factor and the action constraint function Q H The ratio of the factor differences; The sampling amount of the optimal action is more than the sampling amount of the feasible action; The sampling amount of the optimal action and the inaction action is proportional to the square of the second noise-to-signal ratio of the optimal action and the inaction action.
7. The method according to claim 6, characterized in that The sampling data allocation algorithm includes the following criteria: Criterion 1: When i and j represent observational actions, Among them, N i and N j represents the sampling amount of observing the action i and j, σ i and σ j represents the sample standard deviation of the Q factor of the action i and j, δ b,i =Q k+1 (s,a b )-Q k+1 (s,a i )δ b,j =Q k+1 (s,a b )-Q k+1 (s,α j ); Criterion 2: When i and j represent observations of inoperable actions, Among them, N i and N j represents the sampling amount of observing the inoperable actions i and j, σ h,i and σ h,j The constraint function Q that represents the observation of the inactive actions i and j H The sample variance of the factor; Criterion 3: When i represents an observable action, Among them, N b represents the sampling amount of the optimal action, N i represents the sampling amount of the observed action i, σ b represents the sample standard deviation of the Q factor of the optimal action b, σ i represents the sample standard deviation of the Q factor for action i, represents the best action to observe; Criterion 4: When i represents an unobservable non-action, Among them, N b represents the sampling amount of the optimal action, N i represents the number of samples to observe the inactive action i, σ h,b The constraint function Q representing the optimal action b H Sample variance of the factor, σ h,i is the constraint function Q for observing the inactive action i H The sample variance of the factor; k represents the number of iterations, Q k+1 (s,a) represents the Q factor value of taking action a in state s in the kth iteration, Represents the constraint function Q for taking action a in state s in the kth iteration H Factor value, H0 represents the preset value, D is π k (s), represents the steady-state probability of state s in the kth iteration, π k (s') represents the steady-state probability of state s' in the kth iteration, Indicates that action d is taken in state s' in the kth iteration k The constraint function Q of (s′) H Factor value.
8. The method according to claim 7, characterized in that The sampling data allocation algorithm is used to calculate the Q factor and sample variance of each possible action and the optimal action, and the constraint function Q of each inactive action. H The factors, sample variance, and total consumed samples are analyzed to obtain the target sample size for each action, including: According to the sampling data allocation algorithm, the Q factor and sample variance of each observed action and the optimal action, and the constraint function Q of each observed inaction are calculated. H Analyze factors and sample variance and calculate the target sample size ratio for each action; The number of samples that should be obtained for each action is obtained by multiplying the target sample number ratio of each action by the total number of consumed samples; The larger of the number of samples that each action should obtain and the number of samples actually used by each action is selected as the target number of samples for each action.
9. An online constraint reinforcement learning device for a single-constraint controlled system, characterized in that: The device comprises: A simulation unit, used to simulate each action, sample the simulation results of each action according to a preset sampling amount, and determine the observed optimal action, feasible action, and infeasible action according to the sampled simulation results; The first calculation unit is used to calculate the Q factor and sample variance of each movable action and the optimal action according to the simulation results of each movable action and the optimal action; calculate the constraint function Q of each inactive action according to the simulation results of each inactive action H Factor and sample variance; record the sample size consumed by each action and the total sample size consumed; The second calculation unit is used to use the sampling data allocation algorithm to calculate the Q factor and sample variance of each possible action and the optimal action, and the constraint function Q of each inactive action. H The factors, sample variance, and total consumed samples are analyzed to obtain the target sample size for each action; the sampling data allocation algorithm is determined according to the objective function and constraint function of the system to be controlled, and is used to asymptotically maximize the probability of correctly selecting the optimal feasible action in each state; A third calculation unit is used to determine the supplementary sampling amount of each action according to the target sample amount of each action and the consumed sample amount of each action; The supplementary sampling unit is used to perform supplementary sampling according to the supplementary sampling amount of each action, and use the simulation results of the supplementary sampling to re-determine the Q factor and sample variance of the feasible action and the optimal action, and the constraint function Q of each infeasible action. H Factor and sample variances; The control unit is used to adjust the total amount of consumed samples and determine whether the total amount of consumed samples is less than the preset total sampling amount. If so, recalculate the target sample amount and the subsequent steps. If not, output the final optimal action to the system to be controlled.
10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.
