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

news2024/12/22 9:32:26

主要内容

该程序是完全复现《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)
    else
        brch_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 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.tabu(iter) = t2-t1;
​
    from_to = show_biograph_not_sorted(Branch(:, [1 2]), substation_node, ...
        show_biograph); %%% show figure, take time
    mpc = 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.5364
    loss_tabu(iter,1) = lossi;
    yij_dec = generate_yij_from_Branch(Branch, Branch0);
​
    % record Branch and loss
    Branch_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_close
    t1 = 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 loss
    Branch_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 = 0
    if flag_2o2c == 1
        t1 = 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);
        end
        fprintf('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 ;
    end
    if 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 == 1
    min_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 ;
        end
        if min_loss>res_save{i}.min_loss_combine_two_o2c2 
            min_loss = res_save{i}.min_loss_combine_two_o2c2 ;
        end
    end  
    min_loss_o2c2 = min_loss
end
​

部分模型级文献结果

4 下载链接

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

“面包板”是什么?有啥用?

同学们大家好,今天我们继续学习杨欣的《电子设计从零开始》,这本书从基本原理出发,知识点遍及无线电通讯、仪器设计、三极管电路、集成电路、传感器、数字电路基础、单片机及应用实例,可以说是全面系统地介绍了电子设计所需的知识…

一种范围可调式测径仪 满足生产各规格检测!

摘要:范围可调式测径仪,满足各种外径尺寸的产品检测,囊括产线的所有规格,性价比更高的测径仪。 关键词:测径仪,范围可调测径仪,在线测径仪 引言 生产线中,各种外径尺寸的线材、棒材、管材都有生产&#xff…

【SAP NWDI】服务开启:SLD,CM,CMS(二)

一、启用System Landscape Directory 二、启用 NWDI using CMS

CAN的底层驱动

框架图 拆解链路模型 CAN子系统 can_controller Core 包含协议控制器和接收/发送移位寄存器。它可处理所有 ISO 11898-1: 2015 协议功能,并支持 11 位和 29 位标识符。

一、基础算法-快速排序

1.快速排序 快速排序主要利用了分治的思想,具体步骤为: step1 确定分界点,常用为q[left],q[right],q[mid],也可以是随机的 step2 调整区间,将比分界点小的放左边,大的放右边 step3 利用递归处理左右两端 …

嵌入式Linux串口通信

嵌入式板子就和普通用的单片机比如stm32开发板,51开发板差不多,他们的串口都很类似,都是直接连上然后在PC机器上用串口软件打开就好了。 我使用的嵌入式开发板上面有8个rs485串口,2个rs232串口以及一个网口,刚开始开发…

代码随想录算法训练营第三十七天| LeetCode 738.单调递增的数字、总结

一、LeetCode 738.单调递增的数字 题目链接/文章讲解/视频讲解:https://programmercarl.com/0738.%E5%8D%95%E8%B0%83%E9%80%92%E5%A2%9E%E7%9A%84%E6%95%B0%E5%AD%97.html 状态:已解决 1.思路 如何求得小于等于N的最大单调递增的整数?98&am…

<计算机网络自顶向下> 多路复用与解复用

多路复用/解复用 端口号区分进程到进程多路解复用工作原理 解复用作用:TCP或者UDP实体采用哪些信息,将报文段的数据部分交给正确的socket,从而交给正确的进程主机收到IP数据报 每个数据报有源IP地址和目标地址每个数据报承载一个传输层报文段…

C++从入门到精通——const与取地址重载

const与取地址重载 前言一、const正常用法const成员函数问题const对象可以调用非const成员函数吗非const对象可以调用const成员函数吗const成员函数内可以调用其它的非const成员函数吗非const成员函数内可以调用其它的const成员函数吗总结 二、取地址及const取地址操作符重载概…

PPTX与PPT文件有什么区别?这2个办公技巧一定要知道!

每一次点击鼠标,每一次敲击键盘,我们都在与各种软件进行互动。其中,PPTX 和 PPT 无疑是职场中最常见的两种办公文档格式。那么,你是否清楚 PPTX 和 PPT 这两者之间的区别呢? 或许你会说,这不过是文件后缀名…

通过抖音短视频获客 只需要六步

抖音是当前最受欢迎的短视频平台之一,拥有庞大的用户群体和强大的社交矩阵,已经成为企业打造品牌口碑和快速获客的一种有效方式。那么,如何利用抖音短视频快速获客,打造品牌口碑呢?小马识途营销顾问简要分析如下&#…

【已解决】html页面刷新后css样式消失

登录失败后显示主页面时样式消失&#xff0c;如&#xff1a; 原因&#xff1a;index的样式引入css前面没有加斜杠 解决办法&#xff1a;添加斜杠 <link th:href"{/asserts/css/bootstrap.min.css}" rel"stylesheet"><link th:href"{/a…

【Git教程】(十四)基于特性分支的开发 — 概述及使用要求,执行过程及其实现,替代方案 ~

Git教程 基于特性分支的开发 1️⃣ 概述2️⃣ 使用要求3️⃣ 执行过程及其实现3.1 创建特性分支3.2 在 master 分支上集成某一特性3.3 将 master 分支上所发生的修改传递给特性分支 4️⃣ 替代方案4.1 直接在部分交付后的合并版本上继续后续工作4.2 到发行版即将成型时再集成特…

AI实践与学习4_大模型之检索增强生成RAG实践

背景 针对AI解题业务场景&#xff0c;靠着ToT、CoT等提示词规则去引导模型的输出答案&#xff0c;一定程度相比Zero-shot解答质量更高&#xff08;正确率、格式&#xff09;等。但是针对某些测试CASE&#xff0c;LLM仍然不能输出期望的正确结果&#xff0c;将AI解题应用生产仍…

Python接口自动化 —— Web接口!

1.2.1 web接口的概念 这里用一个浏览器调试工具捕捉课程管理页面请求作为例子&#xff1a; 当请求页面时&#xff0c;服务器会返回资源&#xff0c;将协议看做是路的话&#xff0c;http可以看做高速公路&#xff0c;soap看做铁路传输的数据有html&#xff0c;css&#xff0…

新游戏-开箱H5游戏【无限贝拉/疯狂骑士团】最新整理Linux手工服务端+详细搭建教程

小编教大家搭建游戏啦 一款H5奉上 先上图 然后再看教程 90GM基地&#xff1a;www.t1gm.com 默认解压密码&#xff1a;www.t1gm.com 本教程只限于技术研究使用&#xff0c;请勿用于商业用途。 本资源由90GM基地独家提供 90GM基地交流群&#xff1a;639140260 ★★★★…

Vue2 —— 学习(七)

目录 一、TodoList 案例&#xff08;第一版&#xff09; &#xff08;一&#xff09;组件化编码流程 1.实现静态组件 2.显示动态数据 &#xff08;二&#xff09;增加元素 &#xff08;三&#xff09;多选框状态确定 &#xff08;四&#xff09;删除元素 &#xff08;五…

Boost电感的作用

Boost电感在Boost升压电路中起着关键的作用。Boost电路是一种DC-DC电源转换器&#xff0c;其主要功能是将低电压直流&#xff08;DC&#xff09;信号转换为高电压直流&#xff08;DC&#xff09;信号。Boost电感在这个过程中起着平滑电流、储存能量和提高电路效率的作用。 具体…

【yolo数据集合并方法】

yolo数据集合并方法 1.数据集容2.数据集合并 1.数据集容 包含训练集、验证集和测试集。 每一个数据集中包含图像文件夹和标签文件夹。 yaml文件中定义了配置参数&#xff0c;包括目标识别的class类别&#xff1a; 2.数据集合并 需要修改labels文件夹下txt文件class信息&…

Vision Pro 零基础教程:1.机器视觉概述

文章目录 机器视觉简介机器视觉的发展历史机器视觉的结构组成机器视觉的应用工业相机分类1. 按传感器类型分类&#xff1a;2. 按分辨率分类&#xff1a;3. 按扫描方式分类&#xff1a;4. 按输出信号类型分类&#xff1a;5. 按应用领域分类&#xff1a;6. 按接口类型分类&#x…