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

2 部分程序
% 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
3 部分模型级文献结果


4 下载链接
相关文章:
【免费】基于SOE算法的多时段随机配电网重构方法
1 主要内容 该程序是完全复现《Switch Opening and Exchange Method for Stochastic Distribution Network Reconfiguration》,也是一个开源代码,网上有些人卖的还挺贵,本次免费分享给大家,代码主要做的是一个通过配电网重构获取…...
Swift面向对象编程
类的定义与实例化: Swift中定义一个类使用class关键字,类的属性和方法都写在大括号内。示例代码如下: class MyClass {var property1: Intvar property2: Stringinit(property1: Int, property2: String) {self.property1 property1self.pr…...
IEDA 的各种常用插件汇总
目录 IEDA 的各种常用插件汇总1、 Alibaba Java Coding Guidelines2、Translation3、Rainbow Brackets4、MyBatisX5、MyBatis Log Free6、Lombok7、Gitee IEDA 的各种常用插件汇总 1、 Alibaba Java Coding Guidelines 作用:阿里巴巴代码规范检查插件,…...
浅谈C语言中异或运算符的10种妙用
目录 1、前言 2、基本准则定律 3、妙用归纳 4、总结 1、前言 C语言中异或运算符^作为一个基本的逻辑运算符,相信大家都知道其概念:通过对两个相同长度的二进制数进行逐位比较,若对应位的值不同,结果为 1, 否则结果为 0。 但是…...
Canal--->准备MySql主数据库---->安装canal
一、安装主数据库 1.在服务器新建文件夹 mysql/data,新建文件 mysql/conf.d/my.cnf 其中my.cnf 内容如下 [mysqld] log_timestampsSYSTEM default-time-zone8:00 server-id1 log-binmysql-bin binlog-do-db mall # 要监听的库 binlog_formatROW2.启动数据库 do…...
vs配置opencv运行时“发生生成错误,是否继续并运行上次的成功生成”BUG解决办法
vs“发生生成错误,是否继续并运行上次的成功生成” 新手在用vs配置opencv时遇到这个错误时,容易无从下手解决。博主亲身经历很有可能是release/debug模式和配置文件不符的问题。 在配置【链接器】→【输入】→【附加依赖项】环节,编辑查看选择…...
Dryad Girl Fawnia
一个可爱的Dryad Girl Fawnia的三维模型。她有ARKit混合形状,人形装备,多种颜色可供选择。她将是一个完美的角色,幻想或装扮游戏。 🔥 Dryad Girl | Fawnia 一个可爱的Dryad Girl Fawnia的三维模型。她有ARKit混合形状,人形装备,多种颜色可供选择。她将是一个完美的角色…...
内存相关知识(新)
基本概念 内存层次结构:内存层次结构是一种层次化的存储设备结构,它包括寄存器、缓存、主存和辅助存储器。每一层次的存储设备都有不同的速度、容量和成本。 内存单元:内存被划分为一系列连续的内存单元,每个单元都有一个唯一的地…...
C++从入门到精通——static成员
static成员 前言一、static成员概念例题 二、 static成员的特性特性例题静态成员函数可以调用非静态成员函数吗非静态成员函数可以调用类的静态成员函数吗 前言 一、static成员 概念 声明为static的类成员称为类的静态成员,用static修饰的成员变量,称之…...
【K8S:初始化】:执行kubeadm显示:connection refused.
文章目录 [root10 kubernetes]# kubeadm init --kubernetes-versionv1.23.0 --image-repositoryregistry.aliyuncs.com/google_containers --apiserver-advertise-address192.168.56.104 [init] Using Kubernetes version: v1.23.0 [preflight] Running pre-flight checks [pre…...
msvcp140_1.dll是什么?找不到msvcp140_1.dll丢失解决方法
msvcp140_1.dll 文件是一个与 Microsoft Visual C 2015 Redistributable 相关的动态链接库(DLL),它在 Windows 系统中扮演着重要角色,尤其对于那些依赖于 Visual C 运行时环境的应用程序和游戏来说。以下是关于 msvcp140_1.dll 文…...
【Java探索之旅】掌握数组操作,轻松应对编程挑战
🎥 屿小夏 : 个人主页 🔥个人专栏 : Java编程秘籍 🌄 莫道桑榆晚,为霞尚满天! 文章目录 📑前言一、数组巩固练习1.1 数组转字符串1.2 数组拷贝1.3 求数组中的平均值1.4 查找数组中指…...
深入理解同步与异步编程及协程管理在Python中的应用
文章目录 1. 同步与异步函数的对比1.1 同步函数1.2 异步函数1.3 对比 2. 管理多个协程与异常处理2.1 并发执行多个协程2.2 错误处理2.3 任务取消 本文将探索Python中同步与异步编程的基本概念及其区别。还会详细介绍如何使用asyncio库来有效管理协程,包括任务的创建…...
Win10本地更新无法升级win11 的0x80080005解决方法
Win10本地更新无法升级win11 Visual Studio 2022 运行项目时,本文提供了错误“指定的程序需要较新版本的 Windows”的解决方法。 更新时提示:0x80080005 解决方法 1、下载Windows11InstallationAssistant.exe 【免费】Windows11InstallationAssista…...
互联网轻量级框架整合之MyBatis核心组件
在看本篇内容之前,最好先理解一下Hibernate和MyBatis的本质区别,这篇Hibernate和MyBatis使用对比实例做了实际的代码级对比,而MyBatis作为更适合互联网产品的持久层首选必定有必然的原因 MyBatis核心组件 MyBatis能够成为数据持久层首选框&a…...
springboot websocket 持续打印 pod 日志
springboot 整合 websocket 和 连接 k8s 集群的方式参考历史 Java 专栏文章 修改前端页面 <!DOCTYPE html> <html><head><meta charset"utf-8"><title>Java后端WebSocket的Tomcat实现</title><script type"text/javasc…...
C代码编译过程与进程内存分布
C代码编译过程 在这篇文章中,我们将探讨C语言代码的编译流程以及进程在运行时的内存布局。编译过程通常包括几个关键步骤:预处理、编译、汇编和链接。 预处理阶段主要是处理源代码文件中的宏定义、头文件包含和条件编译指令。在此阶段,编译…...
Windows 部署ChatGLM3大语言模型
一、环境要求 硬件 内存:> 16GB 显存: > 13GB(4080 16GB) 硬盘:60G 软件 python 版本推荐3.10 - 3.11 transformers 库版本推荐为 4.36.2 torch 推荐使用 2.0 及以上的版本,以获得最佳的推理性能 二、部…...
JS相关八股之什么是事件循环
在JavaScript中,“事件循环”(Event Loop)是一个非常重要的概念,它是指JavaScript引擎如何在单线程中处理异步操作的机制。单线程意味着在任意时刻,JavaScript代码只能执行一个任务。 一.事件循环的工作流程大致如下&…...
SpringCloud集成Skywalking链路追踪和日志收集
1. 下载Agents https://archive.apache.org/dist/skywalking/java-agent/9.0.0/apache-skywalking-java-agent-9.0.0.tgz 2. 上传到服务器解压 在Spring Cloud项目中,每部署一个服务时,就拷贝一份skywalking的agent文件到该服务器上并解压。不管是部署…...
最新SpringBoot+SpringCloud+Nacos微服务框架分享
文章目录 前言一、服务规划二、架构核心1.cloud的pom2.gateway的异常handler3.gateway的filter4、admin的pom5、admin的登录核心 三、code-helper分享总结 前言 最近有个活蛮赶的,根据Excel列的需求预估的工时直接打骨折,不要问我为什么,主要…...
零基础设计模式——行为型模式 - 责任链模式
第四部分:行为型模式 - 责任链模式 (Chain of Responsibility Pattern) 欢迎来到行为型模式的学习!行为型模式关注对象之间的职责分配、算法封装和对象间的交互。我们将学习的第一个行为型模式是责任链模式。 核心思想:使多个对象都有机会处…...
k8s业务程序联调工具-KtConnect
概述 原理 工具作用是建立了一个从本地到集群的单向VPN,根据VPN原理,打通两个内网必然需要借助一个公共中继节点,ktconnect工具巧妙的利用k8s原生的portforward能力,简化了建立连接的过程,apiserver间接起到了中继节…...
Caliper 配置文件解析:config.yaml
Caliper 是一个区块链性能基准测试工具,用于评估不同区块链平台的性能。下面我将详细解释你提供的 fisco-bcos.json 文件结构,并说明它与 config.yaml 文件的关系。 fisco-bcos.json 文件解析 这个文件是针对 FISCO-BCOS 区块链网络的 Caliper 配置文件,主要包含以下几个部…...
MySQL账号权限管理指南:安全创建账户与精细授权技巧
在MySQL数据库管理中,合理创建用户账号并分配精确权限是保障数据安全的核心环节。直接使用root账号进行所有操作不仅危险且难以审计操作行为。今天我们来全面解析MySQL账号创建与权限分配的专业方法。 一、为何需要创建独立账号? 最小权限原则…...
Ubuntu系统多网卡多相机IP设置方法
目录 1、硬件情况 2、如何设置网卡和相机IP 2.1 万兆网卡连接交换机,交换机再连相机 2.1.1 网卡设置 2.1.2 相机设置 2.3 万兆网卡直连相机 1、硬件情况 2个网卡n个相机 电脑系统信息,系统版本:Ubuntu22.04.5 LTS;内核版本…...
论文阅读:Matting by Generation
今天介绍一篇关于 matting 抠图的文章,抠图也算是计算机视觉里面非常经典的一个任务了。从早期的经典算法到如今的深度学习算法,已经有很多的工作和这个任务相关。这两年 diffusion 模型很火,大家又开始用 diffusion 模型做各种 CV 任务了&am…...
LeetCode - 148. 排序链表
目录 题目 思路 基本情况检查 复杂度分析 执行示例 读者可能出的错误 正确的写法 题目 148. 排序链表 - 力扣(LeetCode) 思路 链表归并排序采用"分治"的策略,主要分为三个步骤: 分割:将链表从中间…...
Spring Boot 与 Kafka 的深度集成实践(二)
3. 生产者实现 3.1 生产者配置 在 Spring Boot 项目中,配置 Kafka 生产者主要是配置生产者工厂(ProducerFactory)和 KafkaTemplate 。生产者工厂负责创建 Kafka 生产者实例,而 KafkaTemplate 则是用于发送消息的核心组件&#x…...
Java + Spring Boot + Mybatis 插入数据后,获取自增 id 的方法
在 MyBatis 中使用 useGeneratedKeys"true" 获取新插入记录的自增 ID 值,可通过以下步骤实现: 1. 配置 Mapper XML 在插入语句的 <insert> 标签中设置: xml 复制 下载 运行 <insert id"insertUser" para…...
