当前位置: 首页 > 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文件到该服务器上并解压。不管是部署…...

HTTP 域名和主机是一回事吗?有了主机和域名,如何建站?

域名不等于主机名&#xff0c;例如baidu.com是一个权威域的域名&#xff0c;但是根本没有一个主机的名字叫做baidu.com,但是dns.baidu.com就是一个主机名&#xff0c;它就是负责baidu.com的服务器的主机名&#xff0c;www.baidu.com也是一个主机名,它是百度web服务器的主机名。…...

运营干货:四个技巧掌握爆款选题方法

在运营工作中&#xff0c;选题是一项至关重要的工作&#xff0c;选对了一个热门话题&#xff0c;就能吸引大量用户的关注和互动&#xff0c;从而取得更好的运营成果。 今天&#xff0c;就给大家分享四个爆款选题方法&#xff0c;让大家的运营更上一层楼&#xff01; 第一种&a…...

柯桥商务口语之怎么样说英语更加礼貌?十个礼貌用语get起来!

当你在国外需要帮助的时候&#xff0c;这些礼貌用语真的是能够帮到你的哦 1.Would/Could you help me? 你可帮助我吗&#xff1f; 相信有些人想请求帮助的时候&#xff0c;一开口就用Can you&#xff0c;这个用在朋友或者熟人上面当然是没有问题的&#xff0c;但是如果是向…...

嵌入式工程师如何摸鱼?

有老铁问我&#xff0c;做嵌入式开发要加班吗&#xff1f; 也不知道搞什么鬼&#xff0c;现在的年轻人对加班这么抵触。 我刚做开发那会&#xff0c;啥也不懂&#xff0c;每天基本都要加班到晚上7-9点不等&#xff0c;我并不抵触加班&#xff0c;因为早早回家&#xff0c;也没什…...

C++语言题库(一)—— 基本知识类

目录 1. Hello World! 2. 据说一个人的标准体重应该是其身高&#xff08;单位&#xff1a;厘米&#xff09;减去100、再乘以0.9所得到的公斤数。已知市斤的数值是公斤数值的两倍。现给定某人身高&#xff0c;请你计算其标准体重应该是多少&#xff1f; 3. 给定一个华氏温度F…...

gemini1.5 API调用

https://ai.google.dev/pricing?hlzh-cn 查询可用的model https://generativelanguage.googleapis.com/v1beta/models?keyxxx 使用postman调用 https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro-latest:generateContent?keyxxx https://ai.google…...

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

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

手写spring IOC底层源码来模拟spring如何利用多级缓存解决循环依赖的问题

在文章开始之前&#xff0c;先来看一张spring IOC加载过程的脑图吧 Spring IOC的加载过程 首先,当我们去new了一个applicationContext,它底层呢就会把我们配置的bean进行扫描,然后创建成一个一个的beanDefinition放在我们的beanDefinitionMap中,此时就有了一切创造bean的原料信…...

C++11 Thead线程和线程池

参考资料&#xff1a; 2、5.lock_guard 与 std::unique_lock-陈子青的编程学习课堂 (seestudy.cn) 3、C11 多线程编程-小白零基础到手撕线程池_哔哩哔哩_bilibili 一、 C11 Thead线程库的基本使用 # include <thread> std::thread t(function_name, args...); // 线…...

Windows版Apache 2.4.59解压直用(免安装-绿色-项目打包直接使用)

windows下Apache分类 Apache分为 安装版和解压版 安装版: 安装方便&#xff0c;下一步------下一步就OK了&#xff0c;但重装系统更换环境又要重新来一遍&#xff0c;会特别麻烦 解压版&#xff08;推荐&#xff09;&#xff1a; 这种方式&#xff08;项目打包特别方便&#x…...

怎么把网站地图上传/网络宣传

// 题2&#xff1a;数组去重,有三种方法&#xff1a;// // 方法一// 利用Array类型的方法&#xff1a;indexOf() 从头部向后查找返回参数的位置,找不到则返回-1; function a(arr){ var newArr[]; for(var i0;i<arr.length;i){ if(newArr.indexOf(arr[i])-1){ newArr.push(ar…...

微网站开发手机模拟器/十大引擎网址

将下面的文件弄成一个bat文件运行即可! 即&#xff0c;将下边这段批处理复制到txt文件后&#xff0c;保存为xx.bat文件&#xff0c;运行一下就就可以修复了&#xff01; echo 正在修复&#xff0c;这个过程可能需要几分钟&#xff0c;请稍候…… rundll32.exe advpack.dll …...

六灶网站建设/自己做seo网站推广

第一、打开&#xff23;&#xff2d;&#xff24;窗口右击 第二第三、重启电脑。...

青岛手机网站建设报价/东莞商城网站建设

SQLSERVER是怎麽通过索引和统计信息来找到目标数据的(第三篇) 最近真的没有什么精力写文章&#xff0c;天天加班&#xff0c;为了完成这个系列&#xff0c;硬着头皮上了 再看这篇文章之前请大家先看我之前写的第一篇和第二篇 第一篇&#xff1a;SQLSERVER是怎麽通过索引和统计信…...

兰州网站推广排名/郑州seo公司

题意&#xff1a;易理解... 分析&#xff1a;容易看出可以用指数型母函数来求解&#xff0c;但是由于结果太大&#xff0c;然后题目要求求出后面两位即可&#xff0c;于是我就在想应该会有周期性&#xff0c;与之我就用母函数求出了前20的值&#xff0c; 经过观察确实是有规律的…...

洪江市网站/seo管理系统培训运营

TITLE multiplication comment !This is two dword number make multiplication , and finally get a qword number中文解释&#xff1a;就是输入两个32位(十进制)有符号数&#xff08;-2147483648&#xff5e;2147483647&#xff09;[经计算器检验结果完全正确]"输出表达…...