(Article recurrence) Multi-objective optimization of microgrid operation considering load satisfaction matlab code

references:

[1] Zeng Jun, Xu Dongdong, Liu Junfeng, et al. Research on multi-objective optimization method of microgrid operation considering load satisfaction [J]. Chinese Journal of Electrical Engineering, 2016, 36(12): 3325 -3334.

[2] K. Deb, A. Pratap, S. Agarwal and T. Meyarivan, “A fast and elitist multiobjective genetic algorithm: NSGA-II,” in IEEE Transactions on Evolutionary Computation, vol. 6, no. 2, pp. 182-197, April 2002, doi: 10.1109/4235.996017.

This blog is based on actual calculation examples to analyze the method of the second-generation non-dominated sorting genetic algorithm (Non-dominated Sorting Genetic Algorithm-Ⅱ, NSGA-Ⅱ) in solving multi-objective optimization of power systems.

1. Basic principles

This paper expands on the existing wind and solar hybrid power generation system in the laboratory to establish a microgrid containing wind, solar, diesel storage and multiple loads. The structure is shown in Figure 1. As can be seen from Figure 1, the microgrid system consists of wind turbines, photovoltaic arrays, diesel generators, batteries, inverters and other physical units as well as an energy management system. The system supplies power to the load through the AC bus, and uses various controllers and control strategies to realize the voltage/current/power of the micro power supply and the charge and discharge control of the battery. The energy management system is mainly responsible for monitoring, collecting and processing entity node data and information, as well as energy optimization and scheduling.

1.1Objective function

Optimization goal: F1 is the lowest total cost; F2 is the highest load satisfaction. The unit is hour, equal time step optimization, and the time span is 24h.

Objective function F1: lowest operating cost

Objective function F2: maximum load satisfaction

1.2Device Modeling

1.3 Equipment Cost Model

Equipment costs in microgrids can be divided into fixed investment, equipment operation and maintenance costs, diesel generator fuel costs and environmental costs, and battery operating losses.

2. NSGA-Ⅱ< /strong>Algorithm and Matlab implementation

Kalyanmoy Deb’s paper “A fast and elitist multiobjective genetic algorithm: NSGA-II” published in the journal “IEEE Transactions on Evolutionary Computation” starts from fast nondominated sorting (fast nondominated sorting), elitist-preserving strategy (elitist-preserving), parameter-free The first-generation NSGA algorithm has been improved in three aspects, including the parameterless niching operator, and is currently one of the most widely used multi-objective intelligent optimization algorithms. The specific principles and implementation methods of the algorithm are in the original text and there are various blogs and notes on the Internet, so I will not repeat them here.

Matlab has integrated the NSGA-Ⅱ algorithm implementation. You can use the NSGA-Ⅱ algorithm by calling the gamultiobj function. The specific syntax is as follows:

[x,fval,exitflag,output,population,scores] = gamultiobj(fun,nvars,A,b,Aeq,beq,lb, ub,nonlcon,intcon,options)

The black fonts are necessary input/output parameters, and the red fonts are optional input/output parameters. The specific usage of each parameter is as follows:

2.1 Input parameters

1) Necessary input parameters fun and nvars

fun represents the fitness function, which can be a function name or a function handle, and nvars represents the dimensions of the variable. It should be noted that when using the gamultiobj function, the default optimization direction of the objective function is min. If the original objective function is max, just add a negative sign before the function. Here is a code example using only two input parameters:

clc
clear
 
fitnessfcn = @(x)[norm(x)^2,0.5*norm(x(:)-[2;-1])^2 + 2];
 
x = gamultiobj(fitnessfcn,2);
plot(x(:,1),x(:,2),'ko')
xlabel('x(1)')
ylabel('x(2)')
title('Pareto Points in Parameter Space')

2) Linear inequality constraint matrices A and b

Assume that the decision variable is x, and the parameters A and b represent that the variable x satisfies the constraint A*x≤b. For example, the following set of constraints:

x1 + 2×2 ≤ 10

3×1 + 4×2 ≤ 20

5×1 + 6×2 ≤ 30.

Expressed by matrix A and vector b: A = [1,2;3,4;5,6];b = [10;20;30]

3) Linear equality constraint matrices Aeq and beq

Assume that the decision variable is x, and the parameters Aeq and beq represent that the variable x satisfies the constraint Aeq*x≤beq. For example, the following set of constraints:

x1 + 2×2 + 3×3 = 10

4×1 + 5×2 + 6×3 = 20

Expressed by matrix Aeq and vector beq: Aeq = [1,2,3;4,5,6];b = [10;20]

4) The upper and lower bounds of the variable ub and lb

The parameters ub and lb represent the upper and lower limits of the variable respectively, and the data dimensions of both should be less than or equal to nvars. When the data dimension is equal to nvars, it means that x(i) satisfies the constraint x(i) ≤ ub(i), ?i=1,2,…,nvars; when the data dimension is k

5) Nonlinear constraints nonlcon

The parameter nonlcon represents the nonlinear constraints of the optimization problem, where nonlcon is the function handle or function name. The nonlinear constraint function needs to contain two output parameters, c and ceq, both of which are row vectors, representing the constraint c(x)<=0 and the constraint ceq(x)=0 respectively. Assume that the decision variables need to satisfy the following nonlinear constraints:

First, the constraints should be written in the form c(x)<=0 and ceq(x)=0:

Then write the defining function of the nonlinear constraints:

function [c,ceq] = nonlcon(x)
c(1) = (x(1)^2)/9 + (x(2)^2)/4 - 1;
c(2) = x(1)^2 - x(2) - 1;
ceq = x(1) - x(2)^5 - 1;
end

6) Definition of integer variables intcon

If you want to limit the k-th dimension in the decision variable x to an integer, just let intcon = k. If it is a 0-1 variable, on the basis of defining it as an integer variable, its upper and lower limits can be constrained to 0 and 1.

7) Optimization options options

Options are algorithm-related options in the form of a structure. The most commonly used options include the population size “PopulationSize” and the maximum number of iterations “Generations”. There are many other options, which will not be introduced in detail here. If you are interested, you can check the official documentation.

2.2 Output parameters

1) Necessary output parameter x

x represents the Pareto optimal solution set obtained through optimization, which is the value of the decision variable, not the value of the objective function.

2) The optimal objective function set fval

fval represents the optimal objective function set obtained through optimization.

3) Algorithm termination reason exitflag

exitflag indicates the reason why the algorithm terminates, where:

0 means the maximum number of iterations has been reached

1 indicates that the population change is relatively small during several consecutive iterations, so the algorithm is terminated.

-1 indicates that it was terminated by the drawing function or output function.

-2 means no feasible solution found

-5 means the algorithm ran beyond the maximum time limit

4) Information output of the optimization process

The output represents the information of the optimization process and has a lot of content. If you are interested, you can go to the official website for specific information.

5) Population and fitness scores

Population represents the population at the last iteration, and scores represents the population fitness at the last iteration.

2.3 Programming Example

The code to call the gamultiobj function and use NSGA-II to solve the above optimization problem is:

clc
clear

fitnessfcn = @my_first_multi; % fitness function handle
nvars = 2; % decision variable dimensions
lb = [-5,-5]; % variable lower limit
ub = [5,5]; % variable upper limit
A = []; b = []; % no linear inequality constraints
Aeq = []; beq = []; % No linear equality constraints
options = gaoptimset('ParetoFraction',0.3,'PopulationSize',100,'Generations',200,'StallGenLimit',200,'TolFun',1e-100,'PlotFcns',@gaplotpareto);
 
[x,fval] = gamultiobj(fitnessfcn,nvars, A,b,Aeq,beq,lb,ub,options);
 
function f = my_first_multi(x)
 
    f(1) = x(1)^4 - 10*x(1)^2 + x(1)*x(2) + x(2)^4 - (x(1)^2)*(x( 2)^2);
    f(2) = x(2)^4 - (x(1)^2)*(x(2)^2) + x(1)^4 + x(1)*x(2);
end

The running results are as follows:

3. Analysis of recurrence ideas

3.1Related parameters and decisionsVariable definitions

Table 1 Related Parameters

Table 2 Decision variables

3.2Programming Ideas

Based on the interpretation of the literature content, the following programming ideas can be designed:

Step 1: Enter required data

This step is relatively simple. Most of the data used in the case analysis can be found in the original text, and other data can be assumed by yourself. Then enter all the required data in the format defined in Table 1.

Step 2: Analysis of ambiguities in the description of the article /strong>

1) The initial state of charge of the battery is not set in the article, but from Figure 11 of the example analysis, it can be seen that the initial state of charge is approximately 60%, that is:

2) According to the description in the theoretical part of the article, the cost of a diesel generator should include fuel cost, operation and maintenance cost and environmental cost. In equation (10), CDG only includes fuel cost, but in equation (16), it is said that CDG is a diesel generator. Total cost, there is a contradiction.

3) The article mentions interruptible loads, but does not list the specific model of interruptible loads, that is, what is the maximum load reduction amount, and whether there is compensation for load reductions. In addition, the literature compares whether the load transferability is considered, but No mathematical model is given in the article. I will add the model here:

Step 3: Setting of decision variables

As shown in Table 2, the original text contains a total of 6 decision variables. Except for the output power of the diesel generator, they are all 1×24 variables. They need to be combined into a 1×192 variable to facilitate the use of the NSGA-Ⅱ algorithm. This means that the dimension of the optimization problem involved in Chinese is 192, and the specific variable settings are as follows:

Step 4: Setting upper and lower bounds for decision variables

According to the decision variables set in step 3, the upper bound UB and lower bound LB of each decision variable are given, as follows:

Step 5: Set constraints

In addition to the upper and lower bound constraints of the decision variables, this multi-objective optimization problem only has battery charging and discharging power and capacity constraints, among which the linear constraints need to be written in matrix form.

Linear equality constraints:

none

Nonlinear inequality constraints:

none

Nonlinear equality constraints:

none

Step 6: Set objective function

The optimization problem contains two objective functions, where F1 is min and F2 is max. Since the default is to find min, a negative sign needs to be added before F2 when solving.

Step 7: Apply NSGA-II algorithm to solve

Set the decision variable dimensions, population size, maximum number of iterations and other parameters of the algorithm, and then call the gamultiobj function to solve the above optimization problem.

Step 8: Output the running results

Refer to the format of the chart in the text and output the results.

4.Matlab code

(Note that the model in this document has relatively large problems. In addition to the problems I mentioned above, there are many problems that can be used to learn the use of non-dominated genetic algorithms. The microgrid dispatch model is for reference only) Matlab for reproduction of the complete paper The code can be obtained from this link:

(Article recurrence) Multi-objective optimization of microgrid operation considering load satisfaction matlab code

5. Operation result analysis

syntaxbug.com © 2021 All Rights Reserved.