Home > matpower6.0 > most > t > t_most_fixed_res.m

t_most_fixed_res

PURPOSE ^

T_MOST_FIXED_RES Tests MOST with fixed reserve requirements.

SYNOPSIS ^

function t_most_fixed_res(quiet)

DESCRIPTION ^

T_MOST_FIXED_RES  Tests MOST with fixed reserve requirements.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_most_fixed_res(quiet)
0002 %T_MOST_FIXED_RES  Tests MOST with fixed reserve requirements.
0003 
0004 %   MOST
0005 %   Copyright (c) 2012-2016, Power Systems Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   This file is part of MOST.
0009 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0010 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0011 
0012 if nargin < 1
0013     quiet = 0;
0014 end
0015 
0016 t_begin(44, quiet);
0017 
0018 if quiet
0019     verbose = 0;
0020 else
0021     verbose = 0;
0022 end
0023 
0024 casefile = 't_case30_userfcns';
0025 mpopt = mpoption('opf.violation', 1e-6, 'mips.gradtol', 1e-8, ...
0026         'mips.comptol', 1e-8, 'mips.costtol', 1e-9);
0027 mpopt = mpoption(mpopt, 'out.all', 0, 'verbose', verbose, 'opf.ac.solver', 'MIPS');
0028 mpopt = mpoption(mpopt, 'model', 'DC');
0029 mpopt = mpoption(mpopt, 'most.solver', 'DEFAULT');
0030 if have_fcn('gurobi')
0031     mpopt = mpoption(mpopt, 'gurobi.method', 1);    %% dual-simplex
0032 end
0033 % if have_fcn('mosek')
0034 %     sc = mosek_symbcon;
0035 %     mpopt = mpoption(mpopt, 'mosek.lp_alg', sc.MSK_OPTIMIZER_DUAL_SIMPLEX);     %% dual simplex
0036 % end
0037 if have_fcn('linprog')
0038     if have_fcn('linprog_ds')
0039         mpopt = mpoption(mpopt, 'linprog.Algorithm', 'dual-simplex');
0040     else
0041         mpopt = mpoption(mpopt, 'linprog.Algorithm', 'simplex');
0042     end
0043 end
0044 % mpopt = mpoption(mpopt, 'verbose', 2);
0045 
0046 %% define named indices into data matrices
0047 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0048     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0049     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0050 [CT_LABEL, CT_PROB, CT_TABLE, CT_TBUS, CT_TGEN, CT_TBRCH, CT_TAREABUS, ...
0051     CT_TAREAGEN, CT_TAREABRCH, CT_ROW, CT_COL, CT_CHGTYPE, CT_REP, ...
0052     CT_REL, CT_ADD, CT_NEWVAL, CT_TLOAD, CT_TAREALOAD, CT_LOAD_ALL_PQ, ...
0053     CT_LOAD_FIX_PQ, CT_LOAD_DIS_PQ, CT_LOAD_ALL_P, CT_LOAD_FIX_P, ...
0054     CT_LOAD_DIS_P, CT_TGENCOST, CT_TAREAGENCOST, CT_MODCOST_F, ...
0055     CT_MODCOST_X] = idx_ct;
0056 
0057 t = 'runopf_w_res(''t_case30_userfcns'') : ';
0058 r1 = runopf_w_res(casefile, mpopt);
0059 t_is(r1.reserves.R, [25; 15; 0; 0; 20; 0], 6, [t 'R']);
0060 t_is(r1.reserves.prc, [2; 2; 2; 2; 5.33007; 5.33007], 5, [t 'prc']);
0061 t_is(r1.reserves.mu.l, [0; 0; 1; 2; 0; 0.169935], 6, [t 'mu.l']);
0062 t_is(r1.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0063 t_is(r1.reserves.mu.Pmax, [0; 0; 0; 0; 0.330065; 0], 6, [t 'mu.Pmax']);
0064 mpc = loadcase(casefile);
0065 [i2e, mpc.bus, mpc.gen, mpc.branch] = ext2int(mpc.bus, mpc.gen, mpc.branch);
0066 
0067 t_is(r1.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0068 t_is(r1.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0069 t_is(r1.reserves.totalcost, 177.5, 4, [t 'totalcost']);
0070 
0071 %%-----  set up data for DC run (most)  -----
0072 mpc.gen(:, RAMP_10) = Inf;
0073 mpc.gen(:, RAMP_30) = Inf;
0074 
0075 %% reserve and delta offers
0076 xgd_table.colnames = {
0077     'PositiveActiveReservePrice', ...
0078         'PositiveActiveReserveQuantity', ...
0079             'NegativeActiveReservePrice', ...
0080                 'NegativeActiveReserveQuantity', ...
0081                     'PositiveActiveDeltaPrice', ...
0082                         'NegativeActiveDeltaPrice', ...
0083 };
0084 xgd_table.data = [
0085     1    0    1    0    1    1;
0086     1    0    1    0    1    1;
0087     1    0    1    0    1    1;
0088     1    0    1    0    1    1;
0089     1    0    1    0    1    1;
0090     1    0    1    0    1    1;
0091 ];
0092 
0093 ng = size(mpc.gen, 1);      %% number of gens
0094 xgd = loadxgendata(xgd_table, mpc);
0095 mdi = loadmd(mpc, [], xgd);
0096 mdi.FixedReserves = mpc.reserves;
0097 
0098 %%-----  run most_fixed_res  -----
0099 %r1 = rundcopf(mpc);
0100 mdo = most(mdi, mpopt);
0101 
0102 %%-----  test it  -----
0103 t = 'success1';
0104 t_ok(r1.success, t);
0105 
0106 t = 'success2';
0107 t_ok(mdo.QP.exitflag, t);
0108 
0109 t = 'f';
0110 t_is(mdo.results.f, r1.f, 7, t);
0111 
0112 t = 'Pg';
0113 t_is(mdo.flow.mpc.gen(:, PG), r1.gen(:, PG), 8, t);
0114 
0115 t = 'R';
0116 t_is(mdo.flow.mpc.reserves.R, r1.reserves.R, 8, t);
0117 
0118 t = 'prc';
0119 t_is(mdo.flow.mpc.reserves.prc, r1.reserves.prc, 8, t);
0120 
0121 t = 'totalcost';
0122 t_is(mdo.flow.mpc.reserves.totalcost, r1.reserves.totalcost, 7, t);
0123 
0124 t = 'mu.l';
0125 t_is(mdo.flow.mpc.reserves.mu.l, r1.reserves.mu.l, 8, t);
0126 
0127 t = 'mu.u';
0128 t_is(mdo.flow.mpc.reserves.mu.u, r1.reserves.mu.u, 8, t);
0129 
0130 t = 'mu.Pmax';
0131 t_is(mdo.flow.mpc.reserves.mu.Pmax, r1.reserves.mu.Pmax, 8, t);
0132 
0133 
0134 %%-----  try again with 3 periods  -----
0135 nt = 3;
0136 profiles = struct( ...
0137     'type', 'mpcData', ...
0138     'table', CT_TLOAD, ...
0139     'rows', 0, ...
0140     'col', CT_LOAD_ALL_PQ, ...
0141     'chgtype', CT_REL, ...
0142     'values', [1.0; 1.1; 1.2] );
0143 mdi = loadmd(mpc, nt, xgd, [], [], profiles);
0144 
0145 for t = 1:nt
0146     mdi.FixedReserves(t,1,1) = mpc.reserves;
0147 end
0148 
0149 %%-----  run most  -----
0150 f = 0;
0151 for tt = 1:nt
0152     mpc1 = mpc;
0153     mpc1.bus = scale_load(profiles.values(tt), mpc1.bus);
0154     r(tt) = runopf_w_res(mpc1, mpopt);
0155     f = f + r(tt).f;
0156 end
0157 
0158 mdo = most(mdi, mpopt);
0159 
0160 %%-----  test it  -----
0161 t = 'success2';
0162 t_ok(mdo.QP.exitflag, t);
0163 
0164 t = 'f';
0165 t_is(mdo.results.f, f, 4, t);
0166 
0167 for tt = 1:nt
0168     t = 'success1';
0169     t_ok(r(tt).success, t);
0170 
0171     t = 'Pg';
0172     t_is(mdo.flow(tt,1,1).mpc.gen(:, PG), r(tt).gen(:, PG), 4, sprintf('(t=%d) : %s', tt, t));
0173     
0174     t = 'R';
0175     t_is(mdo.flow(tt,1,1).mpc.reserves.R, r(tt).reserves.R, 4, sprintf('(t=%d) : %s', tt, t));
0176     
0177     t = 'prc';
0178     t_is(mdo.flow(tt,1,1).mpc.reserves.prc, r(tt).reserves.prc, 5, sprintf('(t=%d) : %s', tt, t));
0179     
0180     t = 'totalcost';
0181     t_is(mdo.flow(tt,1,1).mpc.reserves.totalcost, r(tt).reserves.totalcost, 4, sprintf('(t=%d) : %s', tt, t));
0182     
0183     t = 'mu.l';
0184     t_is(mdo.flow(tt,1,1).mpc.reserves.mu.l, r(tt).reserves.mu.l, 5, sprintf('(t=%d) : %s', tt, t));
0185     
0186     t = 'mu.u';
0187     t_is(mdo.flow(tt,1,1).mpc.reserves.mu.u, r(tt).reserves.mu.u, 6, sprintf('(t=%d) : %s', tt, t));
0188     
0189     t = 'mu.Pmax';
0190     t_is(mdo.flow(tt,1,1).mpc.reserves.mu.Pmax, r(tt).reserves.mu.Pmax, 5, sprintf('(t=%d) : %s', tt, t));
0191 end
0192 
0193 t_end;

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005