Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
sparrowzz
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
sgool
sparrowzz
Commits
f34c0dac
Commit
f34c0dac
authored
Jul 20, 2025
by
Lian-runzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ext2int函数
parent
94bfd925
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
51 行增加
和
0 行删除
+51
-0
rspower/examples/test_ext2int.txt
+8
-0
rspower/lib/ext2int.txt
+43
-0
没有找到文件。
rspower/examples/test_ext2int.txt
0 → 100644
查看文件 @
f34c0dac
#include ../data/case14.txt
#include ../lib/idx_gen.txt
#include ../lib/idx_bus.txt
#include ../lib/idx_brch.txt
#include ../lib/ext2int.txt
return ext2int(bus, gen, branch, areas);
\ No newline at end of file
rspower/lib/ext2int.txt
查看文件 @
f34c0dac
fn ext2int(bus, gen, branch, areas){
//EXT2INT Converts external to internal indexing.
//
// [i2e, bus, gen, branch, areas] = ext2int(bus, gen, branch, areas);
// [i2e, bus, gen, branch] = ext2int(bus, gen, branch);
//
// If the first argument is a matrix, it simply converts from (possibly
// non-consecutive) external bus numbers to consecutive internal bus
// numbers which start at 1. Changes are made to BUS, GEN and BRANCH,
// which are returned along with a vector of indices I2E that can be
// passed to INT2EXT to perform the reverse conversion, where
// EXTERNAL_BUS_NUMBER = I2E(INTERNAL_BUS_NUMBER).
// AREAS is completely ignored and is only included here for backward
// compatibility of the API.
// create map of external bus numbers to bus indices
i2e = slice(bus, [0], [BUS_I-1,BUS_I] ); //得到bus矩阵的母线序号所在列
e2i = sparse(range(0,max(i2e))', zeros(max(i2e),1), zeros(max(i2e),1), max(i2e), 1); //创建(原bus矩阵母线最大序号值*1)的e2i全零稀疏矩阵
index_e2i = i2e - 1; //索引值=母线序号-1
e2i = set(e2i, index_e2i, range(1, size(bus, 0) + 1 )' ); //建立母线序号的映射,对应位置进行从1重新编号
// renumber buses consecutively
index_e2i_bus = slice(bus, [0], [BUS_I-1, BUS_I] ) - 1; //索引值=母线序号-1
e2i_bus = get_multi(e2i, index_e2i_bus )'; //得到e2i矩阵中,重新编号后对应的序号
output_bus = assign(bus, e2i_bus, [0], [BUS_I-1, BUS_I] ); //转换为映射后的母线编号
index_e2i_gen = slice(gen, [0], [GEN_BUS-1, GEN_BUS] ) - 1;
e2i_gen = get_multi(e2i, index_e2i_gen )';
output_gen = assign(gen, e2i_gen, [0], [GEN_BUS-1, GEN_BUS] );
index_e2i_fbus = slice(branch, [0], [F_BUS-1, F_BUS] ) - 1;
e2i_fbus = get_multi(e2i, index_e2i_fbus )';
output_branch1 = assign(branch, e2i_fbus, [0], [F_BUS-1, F_BUS] );
index_e2i_tbus = slice(branch, [0], [T_BUS-1, T_BUS] ) - 1;
e2i_tbus = get_multi(e2i, index_e2i_tbus )';
output_branch2 = assign(output_branch1, e2i_tbus, [0], [T_BUS-1, T_BUS] );
//return i2e, bus, gen, branch, areas;
//return output_branch2;
return e2i;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论