├── MaintenanceGithub.zip ├── MaintenanceGithub ├── Maintenance.m ├── Maintenance │ ├── Add_Huodian_GenCost.m │ ├── Add_Huodian_Startup.m │ ├── Add_Huodian_UnitOutput.m │ ├── Add_MaintenanceBranch.m │ ├── Add_MaintenanceGen.m │ ├── Add_MinUpDownTime.m │ ├── Add_ObjMaintenanceCost.m │ ├── Add_ObjMinReserve.m │ ├── Add_PowerBalance.m │ ├── Add_PowerFlow.m │ ├── Add_Ramp.m │ ├── Add_SecurityConstraints.m │ ├── Add_SpinningReserve.m │ └── test.m ├── README.txt ├── example │ ├── ReMS_118bus_168.xls │ └── case_RTS_GMLC.m ├── functions │ ├── idx_brch.m │ ├── idx_bus.m │ ├── initial_Maintenance.m │ ├── initial_Maintenance_excel.m │ ├── initial_Maintenance_matpower.m │ ├── initial_SCUC.m │ ├── makeBdc.m │ └── makeYbus.m └── result │ └── ReMS_118bus_168_balance.mat └── README.md /MaintenanceGithub.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub.zip -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/Add_Huodian_GenCost.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/Add_Huodian_GenCost.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/Add_Huodian_Startup.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/Add_Huodian_Startup.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/Add_Huodian_UnitOutput.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/Add_Huodian_UnitOutput.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/Add_MaintenanceBranch.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/Add_MaintenanceBranch.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/Add_MaintenanceGen.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/Add_MaintenanceGen.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/Add_MinUpDownTime.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/Add_MinUpDownTime.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/Add_ObjMaintenanceCost.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/Add_ObjMaintenanceCost.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/Add_ObjMinReserve.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/Add_ObjMinReserve.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/Add_PowerBalance.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/Add_PowerBalance.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/Add_PowerFlow.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/Add_PowerFlow.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/Add_Ramp.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/Add_Ramp.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/Add_SecurityConstraints.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/Add_SecurityConstraints.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/Add_SpinningReserve.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/Add_SpinningReserve.m -------------------------------------------------------------------------------- /MaintenanceGithub/Maintenance/test.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/Maintenance/test.m -------------------------------------------------------------------------------- /MaintenanceGithub/README.txt: -------------------------------------------------------------------------------- 1 | 包含了两个算例 2 | 118节点算例数据来自http://motor.ece.iit.edu/data/ 3 | 96rts算例来自IEEE论文 4 | 数据格式在m文件注释中给出 5 | 6 | 添加约束的脚本在Maintenance文件夹内 7 | 8 | 目标函数包括三个 9 | 1.最小检修费用 10 | 2.最大化最小备用率 11 | 3.平均备用(最小方差) 12 | 但是3需要很长的计算时间 13 | 14 | 直接运行Maintence.m 15 | 16 | 自用基于matlab及yalmip的机组检修计划模型 17 | 王砚平 18 | 2020.04 -------------------------------------------------------------------------------- /MaintenanceGithub/example/ReMS_118bus_168.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/example/ReMS_118bus_168.xls -------------------------------------------------------------------------------- /MaintenanceGithub/example/case_RTS_GMLC.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/example/case_RTS_GMLC.m -------------------------------------------------------------------------------- /MaintenanceGithub/functions/idx_brch.m: -------------------------------------------------------------------------------- 1 | function [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, ... 2 | RATE_C, TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ... 3 | ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch 4 | %IDX_BRCH Defines constants for named column indices to branch matrix. 5 | % Example: 6 | % 7 | % [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ... 8 | % TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ... 9 | % ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch; 10 | % 11 | % Some examples of usage, after defining the constants using the line above, 12 | % are: 13 | % 14 | % branch(4, BR_STATUS) = 0; % take branch 4 out of service 15 | % Ploss = branch(:, PF) + branch(:, PT); % compute real power loss vector 16 | % 17 | % The index, name and meaning of each column of the branch matrix is given 18 | % below: 19 | % 20 | % columns 1-11 must be included in input matrix (in case file) 21 | % 1 F_BUS f, from bus number 22 | % 2 T_BUS t, to bus number 23 | % 3 BR_R r, resistance (p.u.) 24 | % 4 BR_X x, reactance (p.u.) 25 | % 5 BR_B b, total line charging susceptance (p.u.) 26 | % 6 RATE_A rateA, MVA rating A (long term rating) 27 | % 7 RATE_B rateB, MVA rating B (short term rating) 28 | % 8 RATE_C rateC, MVA rating C (emergency rating) 29 | % 9 TAP ratio, transformer off nominal turns ratio 30 | % 10 SHIFT angle, transformer phase shift angle (degrees) 31 | % 11 BR_STATUS initial branch status, 1 - in service, 0 - out of service 32 | % 12 ANGMIN minimum angle difference, angle(Vf) - angle(Vt) (degrees) 33 | % 13 ANGMAX maximum angle difference, angle(Vf) - angle(Vt) (degrees) 34 | % (The voltage angle difference is taken to be unbounded below 35 | % if ANGMIN < -360 and unbounded above if ANGMAX > 360. 36 | % If both parameters are zero, it is unconstrained.) 37 | % 38 | % columns 14-17 are added to matrix after power flow or OPF solution 39 | % they are typically not present in the input matrix 40 | % 14 PF real power injected into "from" end of branch (MW) 41 | % 15 QF reactive power injected into "from" end of branch (MVAr) 42 | % 16 PT real power injected into "to" end of branch (MW) 43 | % 17 QT reactive power injected into "to" end of branch (MVAr) 44 | % 45 | % columns 18-21 are added to matrix after OPF solution 46 | % they are typically not present in the input matrix 47 | % (assume OPF objective function has units, u) 48 | % 18 MU_SF Kuhn-Tucker multiplier on MVA limit at "from" bus (u/MVA) 49 | % 19 MU_ST Kuhn-Tucker multiplier on MVA limit at "to" bus (u/MVA) 50 | % 20 MU_ANGMIN Kuhn-Tucker multiplier lower angle difference limit (u/degree) 51 | % 21 MU_ANGMAX Kuhn-Tucker multiplier upper angle difference limit (u/degree) 52 | % 53 | % See also DEFINE_CONSTANTS. 54 | 55 | % MATPOWER 56 | % Copyright (c) 1996-2016, Power Systems Engineering Research Center (PSERC) 57 | % by Ray Zimmerman, PSERC Cornell 58 | % 59 | % This file is part of MATPOWER. 60 | % Covered by the 3-clause BSD License (see LICENSE file for details). 61 | % See https://matpower.org for more info. 62 | 63 | %% define the indices 64 | F_BUS = 1; %% f, from bus number 65 | T_BUS = 2; %% t, to bus number 66 | BR_R = 3; %% r, resistance (p.u.) 67 | BR_X = 4; %% x, reactance (p.u.) 68 | BR_B = 5; %% b, total line charging susceptance (p.u.) 69 | RATE_A = 6; %% rateA, MVA rating A (long term rating) 70 | RATE_B = 7; %% rateB, MVA rating B (short term rating) 71 | RATE_C = 8; %% rateC, MVA rating C (emergency rating) 72 | TAP = 9; %% ratio, transformer off nominal turns ratio 73 | SHIFT = 10; %% angle, transformer phase shift angle (degrees) 74 | BR_STATUS = 11; %% initial branch status, 1 - in service, 0 - out of service 75 | ANGMIN = 12; %% minimum angle difference, angle(Vf) - angle(Vt) (degrees) 76 | ANGMAX = 13; %% maximum angle difference, angle(Vf) - angle(Vt) (degrees) 77 | 78 | %% included in power flow solution, not necessarily in input 79 | PF = 14; %% real power injected at "from" bus end (MW) (not in PTI format) 80 | QF = 15; %% reactive power injected at "from" bus end (MVAr) (not in PTI format) 81 | PT = 16; %% real power injected at "to" bus end (MW) (not in PTI format) 82 | QT = 17; %% reactive power injected at "to" bus end (MVAr) (not in PTI format) 83 | 84 | %% included in opf solution, not necessarily in input 85 | %% assume objective function has units, u 86 | MU_SF = 18; %% Kuhn-Tucker multiplier on MVA limit at "from" bus (u/MVA) 87 | MU_ST = 19; %% Kuhn-Tucker multiplier on MVA limit at "to" bus (u/MVA) 88 | MU_ANGMIN = 20; %% Kuhn-Tucker multiplier lower angle difference limit (u/degree) 89 | MU_ANGMAX = 21; %% Kuhn-Tucker multiplier upper angle difference limit (u/degree) 90 | -------------------------------------------------------------------------------- /MaintenanceGithub/functions/idx_bus.m: -------------------------------------------------------------------------------- 1 | function [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ... 2 | VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus 3 | %IDX_BUS Defines constants for named column indices to bus matrix. 4 | % Example: 5 | % 6 | % [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ... 7 | % VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus; 8 | % 9 | % Some examples of usage, after defining the constants using the line above, 10 | % are: 11 | % 12 | % Pd = bus(4, PD); % get the real power demand at bus 4 13 | % bus(:, VMIN) = 0.95; % set the min voltage magnitude to 0.95 at all buses 14 | % 15 | % The index, name and meaning of each column of the bus matrix is given 16 | % below: 17 | % 18 | % columns 1-13 must be included in input matrix (in case file) 19 | % 1 BUS_I bus number (positive integer) 20 | % 2 BUS_TYPE bus type (1 = PQ, 2 = PV, 3 = ref, 4 = isolated) 21 | % 3 PD Pd, real power demand (MW) 22 | % 4 QD Qd, reactive power demand (MVAr) 23 | % 5 GS Gs, shunt conductance (MW demanded at V = 1.0 p.u.) 24 | % 6 BS Bs, shunt susceptance (MVAr injected at V = 1.0 p.u.) 25 | % 7 BUS_AREA area number, (positive integer) 26 | % 8 VM Vm, voltage magnitude (p.u.) 27 | % 9 VA Va, voltage angle (degrees) 28 | % 10 BASE_KV baseKV, base voltage (kV) 29 | % 11 ZONE zone, loss zone (positive integer) 30 | % 12 VMAX maxVm, maximum voltage magnitude (p.u.) 31 | % 13 VMIN minVm, minimum voltage magnitude (p.u.) 32 | % 33 | % columns 14-17 are added to matrix after OPF solution 34 | % they are typically not present in the input matrix 35 | % (assume OPF objective function has units, u) 36 | % 14 LAM_P Lagrange multiplier on real power mismatch (u/MW) 37 | % 15 LAM_Q Lagrange multiplier on reactive power mismatch (u/MVAr) 38 | % 16 MU_VMAX Kuhn-Tucker multiplier on upper voltage limit (u/p.u.) 39 | % 17 MU_VMIN Kuhn-Tucker multiplier on lower voltage limit (u/p.u.) 40 | % 41 | % additional constants, used to assign/compare values in the BUS_TYPE column 42 | % 1 PQ PQ bus 43 | % 2 PV PV bus 44 | % 3 REF reference bus 45 | % 4 NONE isolated bus 46 | % 47 | % See also DEFINE_CONSTANTS. 48 | 49 | % MATPOWER 50 | % Copyright (c) 1996-2016, Power Systems Engineering Research Center (PSERC) 51 | % by Ray Zimmerman, PSERC Cornell 52 | % 53 | % This file is part of MATPOWER. 54 | % Covered by the 3-clause BSD License (see LICENSE file for details). 55 | % See https://matpower.org for more info. 56 | 57 | %% define bus types 58 | PQ = 1; 59 | PV = 2; 60 | REF = 3; 61 | NONE = 4; 62 | 63 | %% define the indices 64 | BUS_I = 1; %% bus number (1 to 29997) 65 | BUS_TYPE = 2; %% bus type (1 - PQ bus, 2 - PV bus, 3 - reference bus, 4 - isolated bus) 66 | PD = 3; %% Pd, real power demand (MW) 67 | QD = 4; %% Qd, reactive power demand (MVAr) 68 | GS = 5; %% Gs, shunt conductance (MW at V = 1.0 p.u.) 69 | BS = 6; %% Bs, shunt susceptance (MVAr at V = 1.0 p.u.) 70 | BUS_AREA = 7; %% area number, 1-100 71 | VM = 8; %% Vm, voltage magnitude (p.u.) 72 | VA = 9; %% Va, voltage angle (degrees) 73 | BASE_KV = 10; %% baseKV, base voltage (kV) 74 | ZONE = 11; %% zone, loss zone (1-999) 75 | VMAX = 12; %% maxVm, maximum voltage magnitude (p.u.) (not in PTI format) 76 | VMIN = 13; %% minVm, minimum voltage magnitude (p.u.) (not in PTI format) 77 | 78 | %% included in opf solution, not necessarily in input 79 | %% assume objective function has units, u 80 | LAM_P = 14; %% Lagrange multiplier on real power mismatch (u/MW) 81 | LAM_Q = 15; %% Lagrange multiplier on reactive power mismatch (u/MVAr) 82 | MU_VMAX = 16; %% Kuhn-Tucker multiplier on upper voltage limit (u/p.u.) 83 | MU_VMIN = 17; %% Kuhn-Tucker multiplier on lower voltage limit (u/p.u.) 84 | -------------------------------------------------------------------------------- /MaintenanceGithub/functions/initial_Maintenance.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/functions/initial_Maintenance.m -------------------------------------------------------------------------------- /MaintenanceGithub/functions/initial_Maintenance_excel.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/functions/initial_Maintenance_excel.m -------------------------------------------------------------------------------- /MaintenanceGithub/functions/initial_Maintenance_matpower.m: -------------------------------------------------------------------------------- 1 | mpc = feval(casename); 2 | 3 | %% 4 | bus = mpc.bus; 5 | branch = mpc.branch; 6 | gen = mpc.gen; 7 | gencost = mpc.gencost; 8 | PeriodLoad = mpc.PeriodLoad; 9 | MaintGen = mpc.MaintGen; 10 | MaintBranch = mpc.MaintBranch; 11 | crew = mpc.crew; 12 | baseMVA = mpc.baseMVA; 13 | 14 | %% 15 | % --- convert bus numbering to internal bus numbering 16 | i2e = bus(:, BUS_I); 17 | e2i = zeros(max(i2e), 1); 18 | e2i(i2e) = [1:size(bus, 1)]'; 19 | bus(:, BUS_I) = e2i( bus(:, BUS_I) ); 20 | gen(:, GEN_BUS) = e2i( gen(:, GEN_BUS) ); 21 | branch(:, F_BUS)= e2i( branch(:, F_BUS) ); 22 | branch(:, T_BUS)= e2i( branch(:, T_BUS) ); 23 | branch_f_bus = branch(:, F_BUS); 24 | branch_t_bus = branch(:, T_BUS); 25 | 26 | -------------------------------------------------------------------------------- /MaintenanceGithub/functions/initial_SCUC.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/functions/initial_SCUC.m -------------------------------------------------------------------------------- /MaintenanceGithub/functions/makeBdc.m: -------------------------------------------------------------------------------- 1 | function [Bbus, Bf, Pbusinj, Pfinj] = makeBdc(baseMVA, bus, branch) 2 | %MAKEBDC Builds the B matrices and phase shift injections for DC power flow. 3 | % [BBUS, BF, PBUSINJ, PFINJ] = MAKEBDC(MPC) 4 | % [BBUS, BF, PBUSINJ, PFINJ] = MAKEBDC(BASEMVA, BUS, BRANCH) 5 | % 6 | % Returns the B matrices and phase shift injection vectors needed for 7 | % a DC power flow. The bus real power injections are related to bus 8 | % voltage angles by 9 | % P = BBUS * Va + PBUSINJ 10 | % The real power flows at the from end the lines are related to the bus 11 | % voltage angles by 12 | % Pf = BF * Va + PFINJ 13 | % Does appropriate conversions to p.u. 14 | % Bus numbers must be consecutive beginning at 1 (i.e. internal ordering). 15 | % 16 | % Example: 17 | % [Bbus, Bf, Pbusinj, Pfinj] = makeBdc(baseMVA, bus, branch); 18 | % 19 | % See also DCPF. 20 | 21 | % MATPOWER 22 | % Copyright (c) 1996-2016, Power Systems Engineering Research Center (PSERC) 23 | % by Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Nacional de Colombia 24 | % and Ray Zimmerman, PSERC Cornell 25 | % 26 | % This file is part of MATPOWER. 27 | % Covered by the 3-clause BSD License (see LICENSE file for details). 28 | % See https://matpower.org for more info. 29 | 30 | %% extract from MPC if necessary 31 | if nargin < 3 32 | mpc = baseMVA; 33 | baseMVA = mpc.baseMVA; 34 | bus = mpc.bus; 35 | branch = mpc.branch; 36 | end 37 | 38 | %% constants 39 | nb = size(bus, 1); %% number of buses 40 | nl = size(branch, 1); %% number of lines 41 | 42 | %% define named indices into bus, branch matrices 43 | [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ... 44 | VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus; 45 | [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ... 46 | TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ... 47 | ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch; 48 | 49 | %% check that bus numbers are equal to indices to bus (one set of bus numbers) 50 | if any(bus(:, BUS_I) ~= (1:nb)') 51 | error('makeBdc: buses must be numbered consecutively in bus matrix; use ext2int() to convert to internal ordering') 52 | end 53 | 54 | %% for each branch, compute the elements of the branch B matrix and the phase 55 | %% shift "quiescent" injections, where 56 | %% 57 | %% | Pf | | Bff Bft | | Vaf | | Pfinj | 58 | %% | | = | | * | | + | | 59 | %% | Pt | | Btf Btt | | Vat | | Ptinj | 60 | %% 61 | stat = branch(:, BR_STATUS); %% ones at in-service branches 62 | b = stat ./ branch(:, BR_X); %% series susceptance 63 | tap = ones(nl, 1); %% default tap ratio = 1 64 | i = find(branch(:, TAP)); %% indices of non-zero tap ratios 65 | tap(i) = branch(i, TAP); %% assign non-zero tap ratios 66 | b = b ./ tap; 67 | 68 | %% build connection matrix Cft = Cf - Ct for line and from - to buses 69 | f = branch(:, F_BUS); %% list of "from" buses 70 | t = branch(:, T_BUS); %% list of "to" buses 71 | i = [(1:nl)'; (1:nl)']; %% double set of row indices 72 | Cft = sparse(i, [f;t], [ones(nl, 1); -ones(nl, 1)], nl, nb); %% connection matrix 73 | 74 | %% build Bf such that Bf * Va is the vector of real branch powers injected 75 | %% at each branch's "from" bus 76 | Bf = sparse(i, [f; t], [b; -b], nl, nb); % = spdiags(b, 0, nl, nl) * Cft; 77 | 78 | %% build Bbus 79 | Bbus = Cft' * Bf; 80 | 81 | %% build phase shift injection vectors 82 | Pfinj = b .* (-branch(:, SHIFT) * pi/180); %% injected at the from bus ... 83 | % Ptinj = -Pfinj; %% ... and extracted at the to bus 84 | Pbusinj = Cft' * Pfinj; %% Pbusinj = Cf * Pfinj + Ct * Ptinj; 85 | -------------------------------------------------------------------------------- /MaintenanceGithub/functions/makeYbus.m: -------------------------------------------------------------------------------- 1 | function [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch) 2 | %MAKEYBUS Builds the bus admittance matrix and branch admittance matrices. 3 | % [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch) returns the full 4 | % bus admittance matrix (i.e. for all buses) and the matrices Yf and Yt 5 | % which, when multiplied by a complex voltage vector, yield the vector 6 | % currents injected into each line from the "from" and "to" buses 7 | % respectively of each line. Does appropriate conversions to p.u. 8 | 9 | % MATPOWER Version 2.0 10 | % by Ray Zimmerman, PSERC Cornell 12/19/97 11 | % Copyright (c) 1996, 1997 by Power System Engineering Research Center (PSERC) 12 | % See http://www.pserc.cornell.edu/ for more info. 13 | 14 | %% constants 15 | j = sqrt(-1); 16 | nb = size(bus, 1); %% number of buses 17 | nl = size(branch, 1); %% number of lines 18 | 19 | %% ----- define named indices into bus, branch matrices 20 | PQ=1; PV=2; REF=3; NONE=4; BUS_I=1; BUS_TYPE=2; PD=3; QD=4; GS=5; BS=6; BUS_AREA=7; 21 | VM=8; VA=9; BASE_KV=10; ZONE=11; VMAX=12; VMIN=13; LAM_P=14; LAM_Q=15; MU_VMAX=16; MU_VMIN=17; 22 | 23 | F_BUS=1; T_BUS=2; BR_R=3; BR_X=4; BR_B=5; RATE_A=6; RATE_B=7; RATE_C=8;% standard notation (in input) 24 | TAP=9; SHIFT=10; BR_STATUS=11; BR_angmin=12; BR_angmax=13;% standard notation (in input) 25 | PF=12; QF=13; PT=14; QT=15; MU_SF=16; MU_ST=17; % MU_SF: idx of MU on MVA lim at "f" bus (in opf) 26 | 27 | %% ----- check that bus numbers are equal to indices to bus (one set of bus numbers) 28 | if any(bus(:, BUS_I) ~= [1:nb]') 29 | error('buses must appear in order by bus number') 30 | end 31 | 32 | %% for each branch, compute the elements of the branch admittance matrix where 33 | %% 34 | %% | If | | Yff Yft | | Vf |; 35 | %% | | = | | * | |; 36 | %% | It | | Ytf Ytt | | Vt |; 37 | %% 38 | stat = branch(:, BR_STATUS); %% ones at in-service branches 39 | Ys = stat ./ (branch(:, BR_R) + j * branch(:, BR_X)); %% series admittance 40 | Bc = stat .* branch(:, BR_B); %% line charging susceptance 41 | tap = ones(nl, 1); %% default tap ratio = 1 42 | i = find(branch(:, TAP)); %% indices of non-zero tap ratios 43 | tap(i) = branch(i, TAP); %% assign non-zero tap ratios 44 | tap = tap .* exp(j*pi/180 * branch(:, SHIFT)); %% add phase shifters 45 | Ytt = Ys + j*Bc/2; 46 | Yff = Ytt ./ (tap .* conj(tap)); 47 | Yft = - Ys ./ conj(tap); 48 | Ytf = - Ys ./ tap; 49 | 50 | %% compute shunt admittance 51 | %% if Ps is the real power consumed by the shunt at V = 1.0 p.u. 52 | %% and Qs is the reactive power injected by the shunt at V = 1.0 p.u. 53 | %% then Ps - j Qs = V * conj(Ys * V) = conj(Ys) = Gs - j Bs, 54 | %% i.e. Ys = Ps + j Qs, so ... 55 | Ys = (bus(:, GS) + j * bus(:, BS)) / baseMVA; %% vector of shunt admittances 56 | 57 | %% build Ybus 58 | f = branch(:, F_BUS); %% list of "from" buses 59 | t = branch(:, T_BUS); %% list of "to" buses 60 | Cf = sparse(f, 1:nl, ones(nl, 1), nb, nl); %% connection matrix for line & from buses 61 | Ct = sparse(t, 1:nl, ones(nl, 1), nb, nl); %% connection matrix for line & to buses 62 | Ybus = spdiags(Ys, 0, nb, nb) + ... %% shunt admittance 63 | Cf * spdiags(Yff, 0, nl, nl) * Cf' + ... %% Yff term of branch admittance 64 | Cf * spdiags(Yft, 0, nl, nl) * Ct' + ... %% Yft term of branch admittance 65 | Ct * spdiags(Ytf, 0, nl, nl) * Cf' + ... %% Ytf term of branch admittance 66 | Ct * spdiags(Ytt, 0, nl, nl) * Ct'; %% Ytt term of branch admittance 67 | 68 | %% Build Yf and Yt such that Yf * V is the vector of complex branch currents injected 69 | %% at each branch's "from" bus, and Yt is the same for the "to" bus end 70 | if nargout > 1 71 | i = [[1:nl]'; [1:nl]']; %% double set of row indices 72 | Yf = sparse(i, [f; t], [Yff; Yft]); 73 | Yt = sparse(i, [f; t], [Ytf; Ytt]); 74 | end 75 | 76 | return; 77 | 78 | -------------------------------------------------------------------------------- /MaintenanceGithub/result/ReMS_118bus_168_balance.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wang-Yanping1996/Maintenance-Model-of-Power-System/0dfa6ddc835fa18472c16d51131e66acd4603805/MaintenanceGithub/result/ReMS_118bus_168_balance.mat -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Maintenance-Model-of-Power-System 2 | Maintenance Model of Power System with Matlab and Yalmip, including the maintenance of branches and generators, and a partial mantenance is allowed for branches. The Object Functions are 1.Maximize the minimum reserve rate, 2.Minimize the cost, 3. Minimize the Variance of reserve rate(resulting in a long solution time) 3 | 使用Matlab和Yalmip进行电力系统维护的模型,包括分支机构和发电机的维护,并且分支机构可以进行部分维护。 对象函数是1.最大化最小储备率,2.最小化成本,3.最小化储备率的差异(导致较长的求解时间) 4 | 5 | Besides, note that the model is based on the Matlab, Yalmip, and the solver is Gurobi. It can be changed to other solvers, such as Cplex, by modifying the parameter 'gurobi' in sentence 'ops = settings('solver','gurobi''. 6 | 此外,请注意,该模型基于Matlab,Yalmip,求解器为Gurobi。 通过修改句子'ops = settings('solver','gurobi'中的参数'gurobi',可以将其更改为其他求解器,例如Cplex。 7 | 8 | If you have any idea on improving this model, please contact me. 9 | 如果您有任何改进此模型的想法,请联系我. 10 | 11 | 注:matlab上传github,中文注释乱码的问题,暂时没找到解决办法,如果您有,可以告诉我。目前我的解决方法是,上传了一个.zip的压缩包,下载后解压应该不会乱码。 12 | Note that: when I upload the .m files to github, its Chinese notes will be error codes, I didn't find any way to solve it, if you know, please tell me. Now my solution is that a .zip file is uploaded, upzip it seems to avoid the error codes problem. 13 | --------------------------------------------------------------------------------