Matlab|【免费】基于SOE算法的多时段随机配电网重构方法

目录

1 主要内容

2 部分程序

3 部分模型级文献结果

4 下载链接


主要内容

该程序是完全复现《Switch Opening and Exchange Method for Stochastic Distribution Network Reconfiguration》,也是一个开源代码,网上有些人卖的还挺贵,本次免费分享给大家,代码主要做的是一个通过配电网重构获取最优网络拓扑的问题,从而有效降低网损,提高经济效益,同时考虑了光伏和负荷的随机性,构建了多时段随机配电网重构模型,考虑到大型网络中计算较为耗时,采用一种基于开断和交换的SOE方法,已获得良好的径向拓扑,采用IEEE多个标准算例进行了测试,更加创新,而且求解的效果更好,结果和论文基本是一致,代码质量非常高,但是子程序比较多,适合有编程经验的同学学习!

部分程序

% core programme in decrese_reconfig_33.m   already obtain optimal solution, no need to execute tabu
clear all, clc, close all
addpath('./code')
%% basic setting
tic
fprintf('decrease_reconfig_33_tabu.m \n')
warning('off')
addpath(pathdef)
mpopt = mpoption;
mpopt.out.all = 0; % do not print anything
mpopt.verbose = 0;
version_LODF = 0 % 1: use decrease_reconfig_algo_LODF.m% 0: use decrease_reconfig_algo.m
​
candi_brch_bus = []; % candidate branch i added to bus j
% mpc0 = case33;
casei=4
d33zhu_v2
substation_node = 1;        n_bus = 33;
​
n1 = 3
n2 = 5
n1_down_substation = n1+1;    n2_up_ending = n2;
​
Branch0 = Branch;
brch_idx_in_loop0 = unique(brch_idx_in_loop(:));
​
%% original network's power flow (not radial)
% show_biograph(Branch, Bus)
from_to = show_biograph_not_sorted(Branch, substation_node, 0); 
mpc = generate_mpc(Bus, Branch, n_bus);
res_orig = runpf(mpc, mpopt);
losses = get_losses(res_orig.baseMVA, res_orig.bus, res_orig.branch);
loss0 = sum(real(losses));
fprintf('case33_tabu: original loop network''s loss is %.5f \n\n', loss0)
​
% for each branch in a loop, 
% if open that branch does not cause isolation, check the two ending buses 
% of that branch for connectivity, realized by shortestpath or conncomp
% calculate the lowest loss increase, print out the sorted loss increase 
% open the branch with lowest loss increase
% stop criterion: number of buses - number of branches = 1
​
%% ------------------------ Core algorithm ------------------------%%
ff0 = Branch(:, 1);   ff = ff0;
tt0 = Branch(:, 2);   tt = tt0;
t1 = toc;
if version_LODF[Branch] = decrease_reconfig_algo_LODF(Bus, Branch, brch_idx_in_loop, ...ff0, tt0, substation_node, n_bus, loss0); %%%  core algorithm
else[Branch] = decrease_reconfig_algo(Bus, Branch, brch_idx_in_loop, ff0, tt0, ...substation_node, n_bus, loss0); %%%  core algorithm
end
t2 = toc;
time_consumption.core = t2 - t1
​
% output of core algorithm
show_biograph = 0;
from_to = show_biograph_not_sorted(Branch(:, [1 2]), substation_node, ...0);
from_to0 = from_to;
mpc = generate_mpc(Bus, Branch, n_bus);
res_pf_dec = runpf(mpc, mpopt);
losses = get_losses(res_pf_dec.baseMVA, res_pf_dec.bus, res_pf_dec.branch);
loss0_dec = sum(real(losses));  % 
fprintf('case33_tabu: radial network obtained by my core algorithm''s loss is %.5f \n\n', loss0_dec)
​
Branch_loss_record = [];
% record Branch and loss
Branch_loss_record.core.Branch = Branch;
Branch_loss_record.core.loss = loss0_dec;
​
%% prepare force open branches for tabu: branch_idx_focused
[branch_idx_focused] = get_branch_idx_focused_for_tabu( ...from_to, Branch0, Branch, substation_node, brch_idx_in_loop0, n_bus, ...n1_down_substation, n2_up_ending);
​
%% ------------------------ Tabu algorithm ------------------------%%
% run the core program for each upstream branch connected to the idx_force_open
% idx_considered = [35 69]
% for iter = idx_considered
for iter = 1:length(branch_idx_focused)fprintf('iter=%d/%d\n', iter, length(branch_idx_focused));Branch = Branch0;Branch(branch_idx_focused(iter), :) = [];ff0 = Branch(:, 1);   ff = ff0;tt0 = Branch(:, 2);   tt = tt0;brch_idx_in_loop = brch_idx_in_loop0;idx_tmp = find(brch_idx_in_loop == branch_idx_focused(iter));if isempty(idx_tmp)elsebrch_idx_in_loop(idx_tmp) = [];brch_idx_in_loop(idx_tmp:end) = brch_idx_in_loop(idx_tmp:end)-1;end
​t1 = toc;%%------------------- core algorithm in Tabu loop--------------------%%    if version_LODF[Branch] = decrease_reconfig_algo_LODF(Bus, Branch, brch_idx_in_loop, ...ff0, tt0, substation_node, n_bus, loss0); %%%  core algorithmelse[Branch] = decrease_reconfig_algo(Bus, Branch, brch_idx_in_loop, ff0, tt0, ...substation_node, n_bus, loss0); %%%  core algorithmendt2 = toc;    time_consumption.tabu(iter) = t2-t1;
​from_to = show_biograph_not_sorted(Branch(:, [1 2]), substation_node, ...show_biograph); %%% show figure, take timempc = generate_mpc(Bus, Branch, n_bus);t1 = toc;res_pf = runpf(mpc, mpopt);t2 = toc;    losses = get_losses(res_pf.baseMVA, res_pf.bus, res_pf.branch);lossi = sum(real(losses)) % loss = 0.5364loss_tabu(iter,1) = lossi;yij_dec = generate_yij_from_Branch(Branch, Branch0);
​% record Branch and lossBranch_loss_record.tabu(iter,1).Branch = Branch; Branch_loss_record.tabu(iter,1).loss = lossi;[PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
%     Vm = res_pf.bus(:, VM)';
%     Va = res_pf.bus(:, VA)';
%     ending_bus = find_ending_node(Branch, substation_node);
%     [ending_bus'; Vm(ending_bus)]; %% ---------------------one open and one close---------------------%%   % prepare nodes_focused for one_open_one_closet1 = toc;[nodes_focused] = get_nodes_focused_o1c1( ...from_to, Branch, Branch0, substation_node, brch_idx_in_loop, ...n1_down_substation, n2_up_ending);
​loss_before_switch0 = lossi;[record_o1c1_loss_dec, loss_after_switch_combine_two_o1c1, Branch_loss] = ...one_open_one_close(nodes_focused, Bus, Branch0, Branch, from_to, ...substation_node, n_bus, loss_before_switch0);t2 = toc;time_consumption.tabu_o1c1(iter) = t2-t1;
​% record Branch and lossBranch_loss_record.tabu_o1c1_dec{iter}.Branch = Branch_loss.Branch_o1c1_dec; 
%     Branch_loss_record.tabu_o1c1_dec(iter,1).Branch = Branch_loss.Branch_o1c1_dec; Branch_loss_record.tabu_o1c1_dec{iter}.loss = Branch_loss.loss_o1c1_dec; Branch_loss_record.tabu_combine_2_o1c1_dec{iter}.Branch = ...Branch_loss.Branch_after_switch_combine_two_o1c1; Branch_loss_record.tabu_combine_2_o1c1_dec{iter}.loss = ...Branch_loss.loss_after_switch_combine_two_o1c1;  
​min_loss_o1c1 = min(record_o1c1_loss_dec(:,1));fprintf('case33_tabu: minimum loss obtained after ''one open and one close'': %.5f\n', ...min_loss_o1c1);
​min_loss_combine_two_o1c1 = 1e9;fprintf('case33_tabu: loss obtained after combine two ''one open and one close'': \n')for i = 1:length(loss_after_switch_combine_two_o1c1)temp = min(loss_after_switch_combine_two_o1c1{i});if temp %.5f \n', temp);end    fprintf('case33_tabu: minimum loss obtained after combine two ''one open and one close'': %.5f \n', ...min_loss_combine_two_o1c1)  %% ---------------------two open and two close---------------------%%flag_2o2c = 0if flag_2o2c == 1t1 = toc;loss_before_switch0 = lossi;[record_o2c2_loss_dec, loss_after_switch_combine_two_o2c2] = ...two_open_two_close(nodes_focused, Bus, Branch0, Branch, from_to, ...substation_node, n_bus, loss_before_switch0);t2 = toc;time_consumption.tabu_o2c2(iter) = t2-t1;min_loss_o2c2 = min(record_o2c2_loss_dec(:,1));fprintf('case33_tabu: minimum loss obtained after ''two open and two close'': %.5f\n', ...min_loss_o2c2);
​min_loss_combine_two_o2c2 = 1e9;fprintf('case33_tabu: loss obtained after combine two ''two open and two close'': \n')for i = 1:length(loss_after_switch_combine_two_o2c2)temp = min(loss_after_switch_combine_two_o2c2{i});if temp %.5f \n', temp);endfprintf('case33_tabu: minimum loss obtained after combine two ''two open and two close'': %.5f \n', ...min_loss_combine_two_o2c2)  res_save{iter}.min_loss_o2c2 = min_loss_o2c2;res_save{iter}.min_loss_combine_two_o2c2 = min_loss_combine_two_o2c2;end
​res_save{iter}.yij_dec = yij_dec;res_save{iter}.Branch = Branch;res_save{iter}.lossi = lossi;    res_save{iter}.record_o1c1_loss_dec = record_o1c1_loss_dec;res_save{iter}.min_loss_o1c1 = min_loss_o1c1;res_save{iter}.min_loss_combine_two_o1c1 = min_loss_combine_two_o1c1;%     file_name = ['case33_yij_Branch_', num2str(idx_force_open(iter)), '.mat'];
%     save(file_name, 'yij_dec', 'Branch', 'lossi');file_name = ['id1_case33_yij_Branch', '.mat'];save(file_name, 'res_save', 'branch_idx_focused', 'Branch_loss_record', ...'time_consumption');   end
file_name = ['id1_case33_yij_Branch', '.mat'];
save(file_name, 'res_save', 'branch_idx_focused', 'Branch_loss_record', ...'time_consumption');
​
% find_all_losses(Branch_loss_record);
​
fprintf('case33_tabu: losses obtained after applying tabu strategy: \n') % 0.28343  zjp 2018-1-18
fprintf('%.5f \n', loss_tabu)
fprintf('----- min: %.5f -----\n', min(loss_tabu))
​
min_loss = 1e9;
for i = 1:length(res_save)if min_loss>res_save{i}.min_loss_o1c1 min_loss = res_save{i}.min_loss_o1c1 ;endif min_loss>res_save{i}.min_loss_combine_two_o1c1 min_loss = res_save{i}.min_loss_combine_two_o1c1 ;end
end  
min_loss_o1c1 = min_loss
​
if flag_2o2c == 1min_loss = 1e9;for i = 1:length(res_save)if min_loss>res_save{i}.min_loss_o2c2 min_loss = res_save{i}.min_loss_o2c2 ;endif min_loss>res_save{i}.min_loss_combine_two_o2c2 min_loss = res_save{i}.min_loss_combine_two_o2c2 ;endend  min_loss_o2c2 = min_loss
end
​

部分模型级文献结果

4 下载链接

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/312775.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Web前端 Javascript笔记1

为什么学习 JavaScript? JavaScript 是 web 开发人员必须学习的 3 门语言中的一门: HTML 定义了网页的内容CSS 描述了网页的布局JavaScript 控制了网页的行为 JavaScript 是可插入 HTML 页面的编程代码。 JavaScript 插入 HTML 页面后,可由所有的现代浏…

野生动物保护视频AI智能监管方案,撑起智能保护伞,守护野生动物

一、背景 在当今世界,野生动物保护已经成为全球性的重要议题。然而,由于野生动物生存环境的不断恶化以及非法狩猎等活动的盛行,保护野生动物变得尤为迫切。为了更有效地保护野生动物,利用视频智能监管技术成为一种可行的方案。 …

服务器数据恢复—ext3文件系统下raid5数据恢复案例

服务器数据恢复环境&故障情况: 某企业光纤存储上有一组由16块硬盘组建的raid5阵列。管理员发现该光纤存储上的卷无法挂载,经过检查发现raid5阵列中有2块硬盘离线,于是联系我们数据恢复中心要求数据恢复工程师到现场恢复服务器存储上的数据…

Vue3从入门到实战:深度掌握组件通信(下部曲)

5.组件通信方式5-$attrs $attrs的概念: 在Vue中,$attrs 是一个特殊的属性,用于访问父组件向子组件传递的非特定属性。它可以让子组件轻松地获取父组件传递的属性,而无需在子组件中显式声明这些属性。 想象一下你有一个父组件和…

pycharm debug 的时候 waiting for process detach

当你使用pycharm debug或者run的时候,突然出现了点不动,然后一直显示:waiting for process detach 可能是以下问题: 1、需要设置Gevent compatible pycharm一直没显示运行步骤,只是出现waiting for process detach-C…

算法练习第18天|111.二叉树的最小深度

111.二叉树的最小深度 111. 二叉树的最小深度 - 力扣(LeetCode)https://leetcode.cn/problems/minimum-depth-of-binary-tree/description/ 题目描述: 给定一个二叉树,找出其最小深度。 最小深度是从根节点到最近叶子节点的最…

RocketMQ 10 面试题FAQ

RocketMQ 面试FAQ 说说你们公司线上生产环境用的是什么消息中间件? 为什么要使用MQ? 因为项目比较大,做了分布式系统,所有远程服务调用请求都是同步执行经常出问题,所以引入了mq 解耦 系统耦合度降低,没有强依赖…

基于Copula函数的风光功率联合场景生成_任意修改生成的场景数目(附带Matlab代码)

基于Copula函数的风光功率联合场景生成 削减为6个场景 部分展示削减为5个场景 部分展示 风光等可再生能源出力的不确定性和相关性给系统的设计带来了极大的复杂性,若忽略这些因素,势必会在系统规划阶段引入次优决策风险。因此,在确定系统最佳…

c语言,单链表的实现----------有全代码!!!!

1.单链表的定义和结构 单链表是一种链式的数据结构,它用一组不连续的储存单元存反线性表中的数据元素。链表中的数据是以节点的形式来表示的,节点和节点之间相互连接 一般来说节点有两部分组成 1.数据域 :数据域用来存储各种类型的数据&…

Node Version Manager(nvm):轻松管理 Node.js 版本的利器

文章目录 前言一、名词解释1、node.js是什么?2、nvm是什么? 二、安装1.在 Linux/macOS 上安装2.在 Windows 上安装 二、使用1.查看可安装的node版本2.安装node3. 查看已安装node4.切换node版本5.其它 总结 前言 Node.js 是现代 Web 开发中不可或缺的一部…

不说成为Linux高级工程师,但成为合格的软件开发人员还是够了,一文深入浅出的精炼总结Linux核心知识点,掌握Linux的使用与高阶技巧

不说成为Linux高级工程师,但成为合格的软件开发人员还是够了,一文深入浅出的精炼总结Linux核心知识点,掌握Linux的使用与高阶技巧。 Linux 的学习对于一个程序员的重要性是不言而喻的。前端开发相比后端开发,接触 Linux 机会相对…

MyBatis-Plus详解(2.5W字+)

说明:该文档是鄙人学习记录的笔记,用于日常翻阅、复习、以及和朋友们讨论学习,如果广大读者朋友发现文章的纰漏、错误,请在评论区或私信提出,本人将积极探讨纠正!!! 一、MyBatis-Plu…

Git回滚版本并push到远端master

1、查看日志 git log 2、还原最近的版本 () --git reset --hard commit-id 如:git reset --hard d84da14bf2743683eca7a015f56114faaa344f42 3、覆盖分支版本 git push -f origin dev 回滚本地master完成后,将回滚后的代码push到远端master&#xf…

Redis(Windows版本下载安装和使用)

天行健,君子以自强不息;地势坤,君子以厚德载物。 每个人都有惰性,但不断学习是好好生活的根本,共勉! 文章均为学习整理笔记,分享记录为主,如有错误请指正,共同学习进步。…

mac配置Jmeter环境

mac配置Jmeter环境 一、安装jmeter二、Jmeter目录结构三、汉化Jmeter四、改变主题外观五、jmeter安装第三方插件六、jmeter基础入门案例 一、安装jmeter 第一步先自行配置好电脑的jdk环境 1、官网下载jar包 https://jmeter.apache.org/download_jmeter.cgi 2、解压到软件你自己…

Git 安装和配置

下载 Git 网址: https://git-scm.com/download 安装 Git 双击安装包, 开始安装. 修改安装路径, 选择非中文无空格路径: 开始安装: 安装成功: 配置 Git 安装完成后, 在任意文件夹内, 右键, 可以显示两个 Git 选项, 就说明安装成功了.

JavaSE-13笔记【集合2(+2024新)】

文章目录 3.Map3.1 Map继承结构3.2 Map接口的常用方法3.3 遍历Map3.4 HashMap集合3.4.1 HashMap集合key的特点3.4.2 HashMap集合的key存储自定义类型3.4.3 哈希表3.4.3.1 哈希表的介绍3.4.3.2 哈希表的存储原理 3.4.4 存放在HashMap和HashSet集合key部分的元素必须同时重写hash…

Elasticsearch:从 ES|QL 到 PHP 对象

作者:来自 Elastic Enrico Zimuel 从 elasticsearch-php v8.13.0 开始,你可以执行 ES|QL 查询并将结果映射到 stdClass 或自定义类的 PHP 对象。 ES|QL ES|QL 是 Elasticsearch 8.11.0 中引入的一种新的 Elasticsearch 查询语言。 目前,它在…

【环境搭建】(五)Ubuntu22.04安装cuda_11.8.0+cudnn_8.6.0

一个愿意伫立在巨人肩膀上的农民...... 设备配置: 一、安装GCC 安装cuda之前,首先应该安装GCC,安装cuda需要用到GCC,否则报错。可以先使用下方指令在终端查看是否已经安装GCC。 gcc --version 如果终端打印如下则说明已经安装…

解构 和 展开运算符

解构 {name,age}obj 1. 数组解构 数组解构是将数组的单元值快速批量赋值给一系列变量的简洁语法&#xff0c;如下代码所示&#xff1a; <script>// 普通的数组let arr [1, 2, 3];// 批量声明变量 a b c// 同时将数组单元值 1 2 3 依次赋值给变量 a b clet [a, b, c] …