当前位置: 首页 > news >正文

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

主要内容

该程序是完全复现《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 下载链接

相关文章:

【免费】基于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代码编译过程 在这篇文章中&#xff0c;我们将探讨C语言代码的编译流程以及进程在运行时的内存布局。编译过程通常包括几个关键步骤&#xff1a;预处理、编译、汇编和链接。 预处理阶段主要是处理源代码文件中的宏定义、头文件包含和条件编译指令。在此阶段&#xff0c;编译…...

Windows 部署ChatGLM3大语言模型

一、环境要求 硬件 内存&#xff1a;> 16GB 显存: > 13GB&#xff08;4080 16GB&#xff09; 硬盘&#xff1a;60G 软件 python 版本推荐3.10 - 3.11 transformers 库版本推荐为 4.36.2 torch 推荐使用 2.0 及以上的版本&#xff0c;以获得最佳的推理性能 二、部…...

JS相关八股之什么是事件循环

在JavaScript中&#xff0c;“事件循环”&#xff08;Event Loop&#xff09;是一个非常重要的概念&#xff0c;它是指JavaScript引擎如何在单线程中处理异步操作的机制。单线程意味着在任意时刻&#xff0c;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项目中&#xff0c;每部署一个服务时&#xff0c;就拷贝一份skywalking的agent文件到该服务器上并解压。不管是部署…...

大话软工笔记—需求分析概述

需求分析&#xff0c;就是要对需求调研收集到的资料信息逐个地进行拆分、研究&#xff0c;从大量的不确定“需求”中确定出哪些需求最终要转换为确定的“功能需求”。 需求分析的作用非常重要&#xff0c;后续设计的依据主要来自于需求分析的成果&#xff0c;包括: 项目的目的…...

黑马Mybatis

Mybatis 表现层&#xff1a;页面展示 业务层&#xff1a;逻辑处理 持久层&#xff1a;持久数据化保存 在这里插入图片描述 Mybatis快速入门 ![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/6501c2109c4442118ceb6014725e48e4.png //logback.xml <?xml ver…...

2025年能源电力系统与流体力学国际会议 (EPSFD 2025)

2025年能源电力系统与流体力学国际会议&#xff08;EPSFD 2025&#xff09;将于本年度在美丽的杭州盛大召开。作为全球能源、电力系统以及流体力学领域的顶级盛会&#xff0c;EPSFD 2025旨在为来自世界各地的科学家、工程师和研究人员提供一个展示最新研究成果、分享实践经验及…...

学校招生小程序源码介绍

基于ThinkPHPFastAdminUniApp开发的学校招生小程序源码&#xff0c;专为学校招生场景量身打造&#xff0c;功能实用且操作便捷。 从技术架构来看&#xff0c;ThinkPHP提供稳定可靠的后台服务&#xff0c;FastAdmin加速开发流程&#xff0c;UniApp则保障小程序在多端有良好的兼…...

【SQL学习笔记1】增删改查+多表连接全解析(内附SQL免费在线练习工具)

可以使用Sqliteviz这个网站免费编写sql语句&#xff0c;它能够让用户直接在浏览器内练习SQL的语法&#xff0c;不需要安装任何软件。 链接如下&#xff1a; sqliteviz 注意&#xff1a; 在转写SQL语法时&#xff0c;关键字之间有一个特定的顺序&#xff0c;这个顺序会影响到…...

JVM暂停(Stop-The-World,STW)的原因分类及对应排查方案

JVM暂停(Stop-The-World,STW)的完整原因分类及对应排查方案,结合JVM运行机制和常见故障场景整理而成: 一、GC相关暂停​​ 1. ​​安全点(Safepoint)阻塞​​ ​​现象​​:JVM暂停但无GC日志,日志显示No GCs detected。​​原因​​:JVM等待所有线程进入安全点(如…...

.Net Framework 4/C# 关键字(非常用,持续更新...)

一、is 关键字 is 关键字用于检查对象是否于给定类型兼容,如果兼容将返回 true,如果不兼容则返回 false,在进行类型转换前,可以先使用 is 关键字判断对象是否与指定类型兼容,如果兼容才进行转换,这样的转换是安全的。 例如有:首先创建一个字符串对象,然后将字符串对象隐…...

iOS性能调优实战:借助克魔(KeyMob)与常用工具深度洞察App瓶颈

在日常iOS开发过程中&#xff0c;性能问题往往是最令人头疼的一类Bug。尤其是在App上线前的压测阶段或是处理用户反馈的高发期&#xff0c;开发者往往需要面对卡顿、崩溃、能耗异常、日志混乱等一系列问题。这些问题表面上看似偶发&#xff0c;但背后往往隐藏着系统资源调度不当…...

return this;返回的是谁

一个审批系统的示例来演示责任链模式的实现。假设公司需要处理不同金额的采购申请&#xff0c;不同级别的经理有不同的审批权限&#xff1a; // 抽象处理者&#xff1a;审批者 abstract class Approver {protected Approver successor; // 下一个处理者// 设置下一个处理者pub…...

MySQL 知识小结(一)

一、my.cnf配置详解 我们知道安装MySQL有两种方式来安装咱们的MySQL数据库&#xff0c;分别是二进制安装编译数据库或者使用三方yum来进行安装,第三方yum的安装相对于二进制压缩包的安装更快捷&#xff0c;但是文件存放起来数据比较冗余&#xff0c;用二进制能够更好管理咱们M…...