├── LICENSE ├── README.md └── 微电网优化调度模型 ├── IDBO(改进蜣螂优化算法) └── IDBO(改进蜣螂优化算法) │ ├── Chebyshev.m │ ├── DBO.m │ ├── Get_Functions_details.m │ ├── IDBO.m │ ├── func_plot.m │ └── main.m ├── 微电网优化调度模型(整合版本VG-Tech) ├── PSOFUN.m ├── SSA.m ├── figures.m ├── gudao_main.m ├── initialization.m ├── objective.m ├── parameter.m ├── prob(环境成本附加程序).m └── tGSSA.m └── 微电网优化调度模型(原始版本) ├── PSOFUN.m ├── SSA.m ├── figures.m ├── gudao_main.m ├── initialization.m ├── objective.m ├── parameter.m ├── prob(环境成本附加程序).m └── tGSSA.m /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Microgrid-Optimization-Dispatch-Model 2 | 微电网优化调度模型 3 | ![17e07f7444befdb071f74556dc5f9de](https://github.com/VG-TechCenter/Microgrid-Optimization-Dispatch-Model/assets/109327979/93c88211-1aaa-4283-b9a3-83894b826b2d) 4 | -------------------------------------------------------------------------------- /微电网优化调度模型/IDBO(改进蜣螂优化算法)/IDBO(改进蜣螂优化算法)/Chebyshev.m: -------------------------------------------------------------------------------- 1 | function X=Chebyshev(N,dim,ub,lb) 2 | k = 4; 3 | X = rand(N,dim); 4 | for i = 1 : dim 5 | for j = 1 : N-1 6 | X(j+1,i) = cos(k.*acos(X(j,i))); 7 | end 8 | end 9 | for i=1:N 10 | X(i,:)=X(i,:).*(ub-lb)+lb; 11 | end 12 | end -------------------------------------------------------------------------------- /微电网优化调度模型/IDBO(改进蜣螂优化算法)/IDBO(改进蜣螂优化算法)/DBO.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VG-TechCenter/Microgrid-Optimization-Dispatch-Model/14bcd788647860156ec902c9c9bf397d5ca347cb/微电网优化调度模型/IDBO(改进蜣螂优化算法)/IDBO(改进蜣螂优化算法)/DBO.m -------------------------------------------------------------------------------- /微电网优化调度模型/IDBO(改进蜣螂优化算法)/IDBO(改进蜣螂优化算法)/Get_Functions_details.m: -------------------------------------------------------------------------------- 1 | function [lb,ub,dim,fobj] = Get_Functions_details(F) 2 | 3 | 4 | switch F 5 | case 'F1' 6 | fobj = @F1; 7 | lb=-100; 8 | ub=100; 9 | dim=30; 10 | 11 | case 'F2' 12 | fobj = @F2; 13 | lb=-10; 14 | ub=10; 15 | dim=30; 16 | 17 | case 'F3' 18 | fobj = @F3; 19 | lb=-100; 20 | ub=100; 21 | dim=30; 22 | 23 | case 'F4' 24 | fobj = @F4; 25 | lb=-100; 26 | ub=100; 27 | dim=30; 28 | 29 | case 'F5' 30 | fobj = @F5; 31 | lb=-30; 32 | ub=30; 33 | dim=30; 34 | 35 | case 'F6' 36 | fobj = @F6; 37 | lb=-100; 38 | ub=100; 39 | dim=30; 40 | 41 | case 'F7' 42 | fobj = @F7; 43 | lb=-1.28; 44 | ub=1.28; 45 | dim=30; 46 | 47 | case 'F8' 48 | fobj = @F8; 49 | lb=-500; 50 | ub=500; 51 | dim=30; 52 | 53 | case 'F9' 54 | fobj = @F9; 55 | lb=-5.12; 56 | ub=5.12; 57 | dim=30; 58 | 59 | case 'F10' 60 | fobj = @F10; 61 | lb=-32; 62 | ub=32; 63 | dim=30; 64 | 65 | case 'F11' 66 | fobj = @F11; 67 | lb=-600; 68 | ub=600; 69 | dim=30; 70 | 71 | case 'F12' 72 | fobj = @F12; 73 | lb=-50; 74 | ub=50; 75 | dim=30; 76 | 77 | case 'F13' 78 | fobj = @F13; 79 | lb=-50; 80 | ub=50; 81 | dim=30; 82 | 83 | case 'F14' 84 | fobj = @F14; 85 | lb=-65.536; 86 | ub=65.536; 87 | dim=2; 88 | 89 | case 'F15' 90 | fobj = @F15; 91 | lb=-5; 92 | ub=5; 93 | dim=4; 94 | 95 | case 'F16' 96 | fobj = @F16; 97 | lb=-5; 98 | ub=5; 99 | dim=2; 100 | 101 | case 'F17' 102 | fobj = @F17; 103 | lb=[-5,0]; 104 | ub=[10,15]; 105 | dim=2; 106 | 107 | case 'F18' 108 | fobj = @F18; 109 | lb=-2; 110 | ub=2; 111 | dim=2; 112 | 113 | case 'F19' 114 | fobj = @F19; 115 | lb=0; 116 | ub=1; 117 | dim=3; 118 | 119 | case 'F20' 120 | fobj = @F20; 121 | lb=0; 122 | ub=1; 123 | dim=6; 124 | 125 | case 'F21' 126 | fobj = @F21; 127 | lb=0; 128 | ub=10; 129 | dim=4; 130 | 131 | case 'F22' 132 | fobj = @F22; 133 | lb=0; 134 | ub=10; 135 | dim=4; 136 | 137 | case 'F23' 138 | fobj = @F23; 139 | lb=0; 140 | ub=10; 141 | dim=4; 142 | end 143 | 144 | end 145 | 146 | % F1 147 | 148 | function o = F1(x) 149 | o=sum(x.^2); 150 | end 151 | 152 | % F2 153 | 154 | function o = F2(x) 155 | o=sum(abs(x))+prod(abs(x)); 156 | end 157 | 158 | % F3 159 | 160 | function o = F3(x) 161 | dim=size(x,2); 162 | o=0; 163 | for i=1:dim 164 | o=o+sum(x(1:i))^2; 165 | end 166 | end 167 | 168 | % F4 169 | 170 | function o = F4(x) 171 | o=max(abs(x)); 172 | end 173 | 174 | % F5 175 | 176 | function o = F5(x) 177 | dim=size(x,2); 178 | o=sum(100*(x(2:dim)-(x(1:dim-1).^2)).^2+(x(1:dim-1)-1).^2); 179 | end 180 | 181 | % F6 182 | 183 | function o = F6(x) 184 | o=sum(abs((x+.5)).^2); 185 | end 186 | 187 | % F7 188 | 189 | function o = F7(x) 190 | dim=size(x,2); 191 | o=sum([1:dim].*(x.^4))+rand; 192 | end 193 | 194 | % F8 195 | 196 | function o = F8(x) 197 | o=sum(-x.*sin(sqrt(abs(x)))); 198 | end 199 | 200 | % F9 201 | 202 | function o = F9(x) 203 | dim=size(x,2); 204 | o=sum(x.^2-10*cos(2*pi.*x))+10*dim; 205 | end 206 | 207 | % F10 208 | 209 | function o = F10(x) 210 | dim=size(x,2); 211 | o=-20*exp(-.2*sqrt(sum(x.^2)/dim))-exp(sum(cos(2*pi.*x))/dim)+20+exp(1); 212 | end 213 | 214 | % F11 215 | 216 | function o = F11(x) 217 | dim=size(x,2); 218 | o=sum(x.^2)/4000-prod(cos(x./sqrt([1:dim])))+1; 219 | end 220 | 221 | % F12 222 | 223 | function o = F12(x) 224 | dim=size(x,2); 225 | o=(pi/dim)*(10*((sin(pi*(1+(x(1)+1)/4)))^2)+sum((((x(1:dim-1)+1)./4).^2).*... 226 | (1+10.*((sin(pi.*(1+(x(2:dim)+1)./4)))).^2))+((x(dim)+1)/4)^2)+sum(Ufun(x,10,100,4)); 227 | end 228 | 229 | % F13 230 | 231 | function o = F13(x) 232 | dim=size(x,2); 233 | o=.1*((sin(3*pi*x(1)))^2+sum((x(1:dim-1)-1).^2.*(1+(sin(3.*pi.*x(2:dim))).^2))+... 234 | ((x(dim)-1)^2)*(1+(sin(2*pi*x(dim)))^2))+sum(Ufun(x,5,100,4)); 235 | end 236 | 237 | % F14 238 | 239 | function o = F14(x) 240 | aS=[-32 -16 0 16 32 -32 -16 0 16 32 -32 -16 0 16 32 -32 -16 0 16 32 -32 -16 0 16 32;,... 241 | -32 -32 -32 -32 -32 -16 -16 -16 -16 -16 0 0 0 0 0 16 16 16 16 16 32 32 32 32 32]; 242 | 243 | for j=1:25 244 | bS(j)=sum((x'-aS(:,j)).^6); 245 | end 246 | o=(1/500+sum(1./([1:25]+bS))).^(-1); 247 | end 248 | 249 | % F15 250 | 251 | function o = F15(x) 252 | aK=[.1957 .1947 .1735 .16 .0844 .0627 .0456 .0342 .0323 .0235 .0246]; 253 | bK=[.25 .5 1 2 4 6 8 10 12 14 16];bK=1./bK; 254 | o=sum((aK-((x(1).*(bK.^2+x(2).*bK))./(bK.^2+x(3).*bK+x(4)))).^2); 255 | end 256 | 257 | % F16 258 | 259 | function o = F16(x) 260 | o=4*(x(1)^2)-2.1*(x(1)^4)+(x(1)^6)/3+x(1)*x(2)-4*(x(2)^2)+4*(x(2)^4); 261 | end 262 | 263 | % F17 264 | 265 | function o = F17(x) 266 | o=(x(2)-(x(1)^2)*5.1/(4*(pi^2))+5/pi*x(1)-6)^2+10*(1-1/(8*pi))*cos(x(1))+10; 267 | end 268 | 269 | % F18 270 | 271 | function o = F18(x) 272 | o=(1+(x(1)+x(2)+1)^2*(19-14*x(1)+3*(x(1)^2)-14*x(2)+6*x(1)*x(2)+3*x(2)^2))*... 273 | (30+(2*x(1)-3*x(2))^2*(18-32*x(1)+12*(x(1)^2)+48*x(2)-36*x(1)*x(2)+27*(x(2)^2))); 274 | end 275 | 276 | % F19 277 | 278 | function o = F19(x) 279 | aH=[3 10 30;.1 10 35;3 10 30;.1 10 35];cH=[1 1.2 3 3.2]; 280 | pH=[.3689 .117 .2673;.4699 .4387 .747;.1091 .8732 .5547;.03815 .5743 .8828]; 281 | o=0; 282 | for i=1:4 283 | o=o-cH(i)*exp(-(sum(aH(i,:).*((x-pH(i,:)).^2)))); 284 | end 285 | end 286 | 287 | % F20 288 | 289 | function o = F20(x) 290 | aH=[10 3 17 3.5 1.7 8;.05 10 17 .1 8 14;3 3.5 1.7 10 17 8;17 8 .05 10 .1 14]; 291 | cH=[1 1.2 3 3.2]; 292 | pH=[.1312 .1696 .5569 .0124 .8283 .5886;.2329 .4135 .8307 .3736 .1004 .9991;... 293 | .2348 .1415 .3522 .2883 .3047 .6650;.4047 .8828 .8732 .5743 .1091 .0381]; 294 | o=0; 295 | for i=1:4 296 | o=o-cH(i)*exp(-(sum(aH(i,:).*((x-pH(i,:)).^2)))); 297 | end 298 | end 299 | 300 | % F21 301 | 302 | function o = F21(x) 303 | aSH=[4 4 4 4;1 1 1 1;8 8 8 8;6 6 6 6;3 7 3 7;2 9 2 9;5 5 3 3;8 1 8 1;6 2 6 2;7 3.6 7 3.6]; 304 | cSH=[.1 .2 .2 .4 .4 .6 .3 .7 .5 .5]; 305 | 306 | o=0; 307 | for i=1:5 308 | o=o-((x-aSH(i,:))*(x-aSH(i,:))'+cSH(i))^(-1); 309 | end 310 | end 311 | 312 | % F22 313 | 314 | function o = F22(x) 315 | aSH=[4 4 4 4;1 1 1 1;8 8 8 8;6 6 6 6;3 7 3 7;2 9 2 9;5 5 3 3;8 1 8 1;6 2 6 2;7 3.6 7 3.6]; 316 | cSH=[.1 .2 .2 .4 .4 .6 .3 .7 .5 .5]; 317 | 318 | o=0; 319 | for i=1:7 320 | o=o-((x-aSH(i,:))*(x-aSH(i,:))'+cSH(i))^(-1); 321 | end 322 | end 323 | 324 | % F23 325 | 326 | function o = F23(x) 327 | aSH=[4 4 4 4;1 1 1 1;8 8 8 8;6 6 6 6;3 7 3 7;2 9 2 9;5 5 3 3;8 1 8 1;6 2 6 2;7 3.6 7 3.6]; 328 | cSH=[.1 .2 .2 .4 .4 .6 .3 .7 .5 .5]; 329 | 330 | o=0; 331 | for i=1:10 332 | o=o-((x-aSH(i,:))*(x-aSH(i,:))'+cSH(i))^(-1); 333 | end 334 | end 335 | 336 | function o=Ufun(x,a,k,m) 337 | o=k.*((x-a).^m).*(x>a)+k.*((-x-a).^m).*(x<(-a)); 338 | end -------------------------------------------------------------------------------- /微电网优化调度模型/IDBO(改进蜣螂优化算法)/IDBO(改进蜣螂优化算法)/IDBO.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VG-TechCenter/Microgrid-Optimization-Dispatch-Model/14bcd788647860156ec902c9c9bf397d5ca347cb/微电网优化调度模型/IDBO(改进蜣螂优化算法)/IDBO(改进蜣螂优化算法)/IDBO.m -------------------------------------------------------------------------------- /微电网优化调度模型/IDBO(改进蜣螂优化算法)/IDBO(改进蜣螂优化算法)/func_plot.m: -------------------------------------------------------------------------------- 1 | % This function draws the benchmark functions 2 | 3 | function func_plot(func_name) 4 | 5 | [lb,ub,dim,fobj]=Get_Functions_details(func_name); 6 | 7 | switch func_name 8 | case 'F1' 9 | x=-100:2:100; y=x; %[-100,100] 10 | 11 | case 'F2' 12 | x=-100:2:100; y=x; %[-10,10] 13 | 14 | case 'F3' 15 | x=-100:2:100; y=x; %[-100,100] 16 | 17 | case 'F4' 18 | x=-100:2:100; y=x; %[-100,100] 19 | case 'F5' 20 | x=-200:2:200; y=x; %[-5,5] 21 | case 'F6' 22 | x=-100:2:100; y=x; %[-100,100] 23 | case 'F7' 24 | x=-1:0.03:1; y=x %[-1,1] 25 | case 'F8' 26 | x=-500:10:500;y=x; %[-500,500] 27 | case 'F9' 28 | x=-5:0.1:5; y=x; %[-5,5] 29 | case 'F10' 30 | x=-20:0.5:20; y=x;%[-500,500] 31 | case 'F11' 32 | x=-500:10:500; y=x;%[-0.5,0.5] 33 | case 'F12' 34 | x=-10:0.1:10; y=x;%[-pi,pi] 35 | case 'F13' 36 | x=-5:0.08:5; y=x;%[-3,1] 37 | case 'F14' 38 | x=-100:2:100; y=x;%[-100,100] 39 | case 'F15' 40 | x=-5:0.1:5; y=x;%[-5,5] 41 | case 'F16' 42 | x=-1:0.01:1; y=x;%[-5,5] 43 | case 'F17' 44 | x=-5:0.1:5; y=x;%[-5,5] 45 | case 'F18' 46 | x=-5:0.06:5; y=x;%[-5,5] 47 | case 'F19' 48 | x=-5:0.1:5; y=x;%[-5,5] 49 | case 'F20' 50 | x=-5:0.1:5; y=x;%[-5,5] 51 | case 'F21' 52 | x=-5:0.1:5; y=x;%[-5,5] 53 | case 'F22' 54 | x=-5:0.1:5; y=x;%[-5,5] 55 | case 'F23' 56 | x=-5:0.1:5; y=x;%[-5,5] 57 | end 58 | 59 | 60 | 61 | L=length(x); 62 | f=[]; 63 | 64 | for i=1:L 65 | for j=1:L 66 | if strcmp(func_name,'F15')==0 && strcmp(func_name,'F19')==0 && strcmp(func_name,'F20')==0 && strcmp(func_name,'F21')==0 && strcmp(func_name,'F22')==0 && strcmp(func_name,'F23')==0 67 | f(i,j)=fobj([x(i),y(j)]); 68 | end 69 | if strcmp(func_name,'F15')==1 70 | f(i,j)=fobj([x(i),y(j),0,0]); 71 | end 72 | if strcmp(func_name,'F19')==1 73 | f(i,j)=fobj([x(i),y(j),0]); 74 | end 75 | if strcmp(func_name,'F20')==1 76 | f(i,j)=fobj([x(i),y(j),0,0,0,0]); 77 | end 78 | if strcmp(func_name,'F21')==1 || strcmp(func_name,'F22')==1 ||strcmp(func_name,'F23')==1 79 | f(i,j)=fobj([x(i),y(j),0,0]); 80 | end 81 | end 82 | end 83 | 84 | surfc(x,y,f,'LineStyle','none'); 85 | 86 | end 87 | 88 | -------------------------------------------------------------------------------- /微电网优化调度模型/IDBO(改进蜣螂优化算法)/IDBO(改进蜣螂优化算法)/main.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VG-TechCenter/Microgrid-Optimization-Dispatch-Model/14bcd788647860156ec902c9c9bf397d5ca347cb/微电网优化调度模型/IDBO(改进蜣螂优化算法)/IDBO(改进蜣螂优化算法)/main.m -------------------------------------------------------------------------------- /微电网优化调度模型/微电网优化调度模型(整合版本VG-Tech)/PSOFUN.m: -------------------------------------------------------------------------------- 1 | function [ bestPosition, fitValue ] = PSOFUN( CostFun,nVar,VarMin,VarMax,MaxIt,nPop ) 2 | %% PSO Parameters 3 | CostFunction=@(x) CostFun(x); % Cost Function 4 | w=1; % Inertia Weight 5 | wdamp=0.99; % Inertia Weight Damping Ratio 6 | c1=1.5; % Personal Learning Coefficient 7 | c2=2.0; % Global Learning Coefficient 8 | VarSize=[1 nVar]; % Size of Decision Variables Matrix说明了VarSize表示决策变量矩阵的大小 9 | % Velocity Limits 10 | VelMax=0.1*(VarMax-VarMin); 11 | VelMin=-VelMax; 12 | 13 | %% Initialization 14 | empty_particle.Position=[]; 15 | empty_particle.Cost=[]; 16 | empty_particle.Velocity=[]; 17 | empty_particle.Best.Position=[]; 18 | empty_particle.Best.Cost=[]; 19 | particle=repmat(empty_particle,nPop,1);%repmat(A,m,n) 表示将矩阵A复制m行n列 20 | GlobalBest.Cost=inf; 21 | 22 | for i=1:nPop 23 | % Initialize Position 24 | particle(i).Position=unifrnd(VarMin,VarMax,VarSize); 25 | % Initialize Velocity 26 | particle(i).Velocity=zeros(VarSize); 27 | % Evaluation 28 | particle(i).Cost=CostFunction(particle(i).Position); 29 | % Update Personal Best 30 | particle(i).Best.Position=particle(i).Position; 31 | particle(i).Best.Cost=particle(i).Cost; 32 | % Update Global Best 33 | if particle(i).Best.CostVarMax); 53 | particle(i).Velocity(IsOutside)=-particle(i).Velocity(IsOutside); 54 | % Apply Position Limits 55 | particle(i).Position = max(particle(i).Position,VarMin); 56 | particle(i).Position = min(particle(i).Position,VarMax); 57 | % Evaluation 58 | particle(i).Cost = CostFunction(particle(i).Position); 59 | % Update Personal Best 60 | if particle(i).Cost