【EI复现】风-水电联合优化运行分析(Matlab代码实现)

本文探讨了如何通过粒子群优化算法对风-水电联合供电进行仿真分析,以优化风电场的效益并平滑功率输出。文中提到的水力蓄能方案有助于提高风电供电质量和经济效益,通过Matlab代码展示了优化过程。
摘要由CSDN通过智能技术生成

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码、数据、文章


💥1 概述

摘要:以风-水电联合运行后的风电场效益最大为目标,利用粒子群优化算法来进行风-水电联合优化运行的仿真分析。仿真结果表明风-水电联合供电不但提高了风电场的收益,同时也平滑了风电场的功率输出,这将有利于提高风电在电力系统中的份额。促进我国风电产业的发展。

  为提高风电场的供电质量同时增加其发电效益,利用储能技术为风电场配置一个蓄能系统是比较重要的解决措施之一。风电的蓄能技术有水力蓄能、压缩空气蓄能、超导磁力蓄能、流体电池组、电解水制氢等,其中水力蓄能是技术较成熟的一种蓄能方式,且小型的水力发电系统投资也不大,因此为采用风-水电联合供电模式不失为一种优选的方案"。
本文提出的基于遗传算法的风-水电联合优化运行就是采用水力蓄能的方式,为风电场配置一个水力发电系统,当可利用风能数值较大时,将一部分风能通过水泵以水能的形式储存于水库中,然后在可利用风能数值较小或上网电价较高时再经过水电发电机组将存储的能量输送到电网中去,以此实现风电场功率的优化输出,这样一方面平滑了风电场的输出波动,另一方面也充分利用了风能,增加了风电场的效益。数学模型见第4部分。

📚2 运行结果

部分代码:

%% 优化
F=fun(P_w,P_h,P_p,sizepop,NVAR,C,C_p);             %计算目标函数(适应度值)
E=zeros(sizepop,NVAR+1);
%---------对不符合条件的解(粒子)加上惩罚因子----------------------------%
%判断哪些解需要加入惩罚因子
P=P_h+P_w;
M=1000;                 %惩罚因子     
for j=1:sizepop
% 约束条件(2)            
    for nvar=1:NVAR
        if P(j,nvar)>P_max                              %flag=1时表示不满足约束条件
            F(j)=F(j)-M;          %加上惩罚因子
        end
        if P(j,nvar)<P_min                              %flag=1时表示不满足约束条件
            F(j)=F(j)-M;          %加上惩罚因子
        end
% 约束条件(3)
        if P_p(j,nvar)+P_w(j,nvar)>P_gmax
            F(j)=F(j)-M;
        end
        if P_p(j,nvar)+P_w(j,nvar)<P_gmin
            F(j)=F(j)-M;
        end
% 约束条件(4)
        if P_h(j,nvar)>min(P_hmax,E(j,nvar)*eta_h/t)
            F(j)=F(j)-M;
        end
         E(j,nvar+1)=E(j,nvar)+t*(eta_p*P_p(j,nvar)-P_h(j,nvar)/eta_h);         %下一时刻水库储能
         %E(j,nvar+1)=max(0,E(j,nvar+1));      %若E小于0,应加以约束
        if P_h(j,nvar)<P_hmin
           F(j)=F(j)-M;
        end
% 约束条件(6)        
         if E(j,nvar)<0
            F(j)=F(j)-M;
         end
         if E(j,nvar)>E_max
            F(j)=F(j)-M;
         end
% 约束条件(5)
        if P_p(j,nvar)>P_pmax
            F(j)=F(j)-M;
        end
        if P_p(j,nvar)<P_pmin
            F(j)=F(j)-M;
        end 
% 约束条件(7)
        if P_v(nvar)-P_w(j,nvar)-P_p(j,nvar)<0
            F(j)=F(j)-M;
        end
%附加约束条件(1)
%{
         if P_h(j,nvar)*P_p(j,nvar)~=0
            F(j)=F(j)-M*(P_h(j,nvar)*P_p(j,nvar));
        end
%}
    end
end
% 个体极值和群体极值(初始情况)
[bestfitness,I]=max(F);                %找出最大的惩罚函数:bestfitness为惩罚函数值;I为序号数
zbest=Vary(I,:);                       %全局最佳
gbest=Vary;                            %个体最佳

🎉3 参考文献

文章中一些内容引自网络,会注明出处或引用为参考文献,难免有未尽之处,如有不妥,请随时联系删除。

[1]潘文霞,范永威,杨威.风-水电联合优化运行分析[J].太阳能学报,2008(01):80-84.

🌈4 Matlab代码、数据、文章

  • 20
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个使用贝叶斯优化的示例函数的Matlab代码: ```matlab function [xopt,fopt] = bayesopt_fun(f,x0,lb,ub,opts) % BAYESOPT_FUN: Bayesian optimization of a function % [XOPT,FOPT] = BAYESOPT_FUN(F,X0,LB,UB,OPTS) finds the minimum of a % function F using Bayesian optimization. X0 is the initial guess, % LB and UB are the lower and upper bounds of the variables, and OPTS % is an options structure created using BAYESOPT_OPTIONS. The function % F should take a vector of variables as input and return a scalar % output. % % Example usage: % f = @(x) sin(3*x) + x.^2 - 0.7*x; % opts = bayesopt_options('AcquisitionFunctionName','expected-improvement-plus'); % [xopt,fopt] = bayesopt_fun(f,0,0,1,opts); % % See also BAYESOPT_OPTIONS. % Check inputs narginchk(4,5); if nargin < 5, opts = bayesopt_options(); end assert(isa(f,'function_handle'),'F must be a function handle'); assert(isvector(x0) && isnumeric(x0),'X0 must be a numeric vector'); assert(isvector(lb) && isnumeric(lb),'LB must be a numeric vector'); assert(isvector(ub) && isnumeric(ub),'UB must be a numeric vector'); assert(all(size(x0)==size(lb)) && all(size(x0)==size(ub)), ... 'X0, LB, and UB must have the same size'); opts = bayesopt_options(opts); % ensure opts has all fields % Initialize X = x0(:); % column vector Y = f(X); n = numel(X); Xbest = X; Ybest = Y; fmin = min(Y); fmax = max(Y); % Loop over iterations for i = 1:opts.MaxIterations % Train surrogate model model = fitrgp(X,Y,'Basis','linear','FitMethod','exact', ... 'PredictMethod','exact','Standardize',true, ... 'KernelFunction',opts.KernelFunction,'KernelParameters',opts.KernelParameters); % Find next point to evaluate if strcmp(opts.AcquisitionFunctionName,'expected-improvement-plus') % Use expected improvement with small positive improvement threshold impThreshold = 0.01*(fmax-fmin); acqFcn = @(x) expected_improvement_plus(x,model,fmin,impThreshold); else % Use acquisition function specified in options acqFcn = str2func(opts.AcquisitionFunctionName); end xnext = bayesopt_acq(acqFcn,model,lb,ub,opts.AcquisitionSamples); % Evaluate function at next point ynext = f(xnext); % Update data X = [X; xnext(:)]; Y = [Y; ynext]; if ynext < Ybest Xbest = xnext; Ybest = ynext; end fmin = min(Y); fmax = max(Y); % Check stopping criterion if i >= opts.MaxIterations || (i > 1 && abs(Y(end)-Y(end-1))/Ybest <= opts.TolFun) break; end end % Return best point found xopt = Xbest; fopt = Ybest; end function EI = expected_improvement_plus(X,model,fmin,impThreshold) % EXPECTED_IMPROVEMENT_PLUS: Expected improvement with small positive improvement threshold % EI = EXPECTED_IMPROVEMENT_PLUS(X,MODEL,FMIN,IMPTHRESHOLD) computes % the expected improvement (EI) of a surrogate model at the point X. % The input MODEL is a regression model, FMIN is the current minimum % value of the function being modeled, and IMPTHRESHOLD is a small % positive improvement threshold. % % The expected improvement is defined as: % EI = E[max(FMIN - Y, 0)] % where Y is the predicted value of the surrogate model at X. % The expected value is taken over the posterior distribution of Y. % % However, if the predicted value Y is within IMPTHRESHOLD of FMIN, % then EI is set to IMPTHRESHOLD instead. This is done to encourage % exploration of the search space, even if the expected improvement % is very small. % % See also BAYESOPT_ACQ. % Check inputs narginchk(4,4); % Compute predicted value and variance at X [Y,~,sigma] = predict(model,X); % Compute expected improvement z = (fmin - Y - impThreshold)/sigma; EI = (fmin - Y - impThreshold)*normcdf(z) + sigma*normpdf(z); EI(sigma==0) = 0; % avoid division by zero % Check if improvement is small if Y >= fmin - impThreshold EI = impThreshold; end end function opts = bayesopt_options(varargin) % BAYESOPT_OPTIONS: Create options structure for Bayesian optimization % OPTS = BAYESOPT_OPTIONS() creates an options structure with default % values for all parameters. % % OPTS = BAYESOPT_OPTIONS(P1,V1,P2,V2,...) creates an options structure % with parameter names and values specified in pairs. Any unspecified % parameters will take on their default values. % % OPTS = BAYESOPT_OPTIONS(OLDOPTS,P1,V1,P2,V2,...) creates a copy of % the OLDOPTS structure, with any parameters specified in pairs % overwriting the corresponding values. % % Available parameters: % MaxIterations - Maximum number of iterations (default 100) % TolFun - Tolerance on function value improvement (default 1e-6) % KernelFunction - Name of kernel function for Gaussian process % regression (default 'squaredexponential') % KernelParameters - Parameters of kernel function (default []) % AcquisitionFunctionName - Name of acquisition function for deciding % which point to evaluate next (default % 'expected-improvement-plus') % AcquisitionSamples - Number of samples to use when evaluating the % acquisition function (default 1000) % % See also BAYESOPT_FUN, BAYESOPT_ACQ. % Define default options opts = struct('MaxIterations',100,'TolFun',1e-6, ... 'KernelFunction','squaredexponential','KernelParameters',[], ... 'AcquisitionFunctionName','expected-improvement-plus','AcquisitionSamples',1000); % Overwrite default options with user-specified options if nargin > 0 if isstruct(varargin{1}) % Copy old options structure and overwrite fields with new values oldopts = varargin{1}; for i = 2:2:nargin fieldname = validatestring(varargin{i},fieldnames(opts)); oldopts.(fieldname) = varargin{i+1}; end opts = oldopts; else % Overwrite fields of default options with new values for i = 1:2:nargin fieldname = validatestring(varargin{i},fieldnames(opts)); opts.(fieldname) = varargin{i+1}; end end end end function xnext = bayesopt_acq(acqFcn,model,lb,ub,nSamples) % BAYESOPT_ACQ: Find next point to evaluate using an acquisition function % XNEXT = BAYESOPT_ACQ(ACQFCN,MODEL,LB,UB,NSAMPLES) finds the next point % to evaluate using the acquisition function ACQFCN and the regression % model MODEL. LB and UB are the lower and upper bounds of the variables, % and NSAMPLES is the number of random samples to use when maximizing % the acquisition function. % % The input ACQFCN should be a function handle that takes a regression % model and a set of input points as inputs, and returns a vector of % acquisition function values. The set of input points is a matrix with % one row per point and one column per variable. % % The output XNEXT is a vector containing the next point to evaluate. % % See also BAYESOPT_FUN, EXPECTED_IMPROVEMENT_PLUS. % Check inputs narginchk(4,5); assert(isa(acqFcn,'function_handle'),'ACQFCN must be a function handle'); assert(isa(model,'RegressionGP'),'MODEL must be a regressionGP object'); assert(isvector(lb) && isnumeric(lb),'LB must be a numeric vector'); assert(isvector(ub) && isnumeric(ub),'UB must be a numeric vector'); assert(all(size(lb)==size(ub)),'LB and UB must have the same size'); if nargin < 5, nSamples = 1000; end % Generate random samples X = bsxfun(@plus,lb,bsxfun(@times,rand(nSamples,numel(lb)),ub-lb)); % Evaluate acquisition function acq = acqFcn(model,X); % Find maximum of acquisition function [~,imax] = max(acq); xnext = X(imax,:); end ``` 该示例代码实现了一个使用贝叶斯优化的函数优化器。该优化器使用高斯过程回归模型来近似目标函数,并使用期望改进加上(EI+)作为获取函数。您可以将此代码用作自己的优化问题的起点,并根据需要进行修改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值