⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t_auction_fmincopf.m

📁 可进行电力系统多节点系统的优化潮流计算
💻 M
📖 第 1 页 / 共 2 页
字号:
function t_auction_fmincopf(quiet)%T_AUCTION  Tests for code in auction.m.%% Currently fails many, many tests due to fmincon's incorrect lambdas.%   MATPOWER%   $Id: t_auction_fmincopf.m,v 1.7 2005/01/25 14:43:59 ray Exp $%   by Ray Zimmerman, PSERC Cornell%   Copyright (c) 2004 by Power System Engineering Research Center (PSERC)%   See http://www.pserc.cornell.edu/matpower/ for more info.if nargin < 1    quiet = 0;endn_tests = 181;t_begin(n_tests, quiet);[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;[GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, ...    GEN_STATUS, PMAX, PMIN, MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN] = idx_gen;if ~have_fcn('smartmarket')    t_skip(n_tests, 'smartmarket code not available');elseif ~have_fcn('fmincon')    t_skip(n_tests, 't_auction_fmincopf requires fmincon');else    mpopt = mpoption('OPF_ALG', 520, 'OUT_ALL_LIM', 1, 'OUT_BRANCH', 0, 'OUT_SYS_SUM', 0, 'OUT_ALL', 0, 'VERBOSE', 1);    q = [        12 24 24;         12 24 24;         12 24 24;         12 24 24;         12 24 24;         12 24 24;         10 10 10;        10 10 10;        10 10 10;    ];    u0 = [1; 1; 1; 1; 1; 1; 1; 1; 1];            %%-----  one offer block marginal @ $50  -----    p = [        20 50 60;        20 40 70;        20 42 80;        20 44 90;        20 46 75;        20 48 60;        100 70 60;        100 50 20;        100 60 50;    ];        t = 'one marginal offer @ $50, auction_type = 5';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1150, 100, u0, []/60, mpopt);    cq5 = cq;    cp5 = cp;    G = find( ~isload(gen) );   %% real generators    L = find(  isload(gen) );   %% dispatchable loads    Gbus = gen(G,GEN_BUS);    Lbus = gen(L,GEN_BUS);    Qfudge =  zeros(size(p));    Qfudge(L,:) = diag(gen(L,QG) ./ gen(L,PG) .* bus(Lbus, LAM_Q)) * ones(size(p(L,:)));        t_is( cq(G(1),2:3), [23.32 0], 1, t );    t_is( cp(G(1),:), 50, 2, t );    t_is( cq(L(2),1:2), [10 0], 1, t );    t_is( cp(L(2),:), 54.0312, 2, t );    t_is( cp(G,1), bus(Gbus, LAM_P), 2, [t ' : gen prices'] );    t_is( cp(L,1), bus(Lbus, LAM_P) + Qfudge(L,1), 3, [t ' : load prices'] );        lao_gap   = p(G(1),2) - bus(Gbus(1), LAM_P);    fro_gap   = p(G(6),3) - bus(Gbus(6), LAM_P);    lab_p_gap = p(L(3),2) - (bus(Lbus(3), LAM_P) + Qfudge(L(3),1));    frb_p_gap = p(L(2),2) - (bus(Lbus(2), LAM_P) + Qfudge(L(2),1));        t_is( lao_gap, 0, 2, 'lao_gap');    t_is( fro_gap, 7.0168, 2, 'fro_gap');    t_is( lab_p_gap, 4.3792, 2, 'lab_p_gap');    t_is( frb_p_gap, -4.0312, 2, 'frb_p_gap');        t = 'one marginal offer @ $50, auction_type = 1';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1110, 100, u0, []/60, mpopt);    cp1 = cp;    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp, cp5, 3, [t ' : prices'] );        t = 'one marginal offer @ $50, auction_type = 2';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1120, 100, u0, []/60, mpopt);    cp2 = cp;    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp(G,:), cp5(G,:)+fro_gap, 3, [t ' : gen prices'] );    t_is( cp(L(1:2),:), cp5(L(1:2),:)+fro_gap, 3, [t ' : load 1,2 prices'] );    t_is( cp(L(3),:), 60, 3, [t ' : load 3 price'] );        t = 'one marginal offer @ $50, auction_type = 3';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1130, 100, u0, []/60, mpopt);    cp3 = cp;    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp, cp5+lab_p_gap, 3, [t ' : prices'] );        t = 'one marginal offer @ $50, auction_type = 4';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1140, 100, u0, []/60, mpopt);    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp(G(1),:), p(G(1),2), 4, [t ' : gen 1 price'] );    t_is( cp(G(2:6),:), cp5(G(2:6),:)+frb_p_gap, 3, [t ' : gen 2-6 prices'] );    t_is( cp(L,:), cp5(L,:)+frb_p_gap, 3, [t ' : load prices'] );        t = 'one marginal offer @ $50, auction_type = 6';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1160, 100, u0, []/60, mpopt);    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp, cp3, 3, [t ' : prices'] );    p2 = p;    p2(L,:) = [ 100 100 100;                100   0   0;                100 100   0 ];    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p2, 1160, 100, u0, []/60, mpopt);    t_is( cq, cq5, 3, [t ' : quantities'] );    t_is( cp(G), cp2(G), 2, [t ' : gen prices'] );    t_is( cp(L(1:2),:), cp2(L(1:2),:), 2, [t ' : load 1,2 prices'] );    t_is( cp(L(3),:), 62.6376, 2, [t ' : load 3 price'] );  %% not clipped as in FRO        t = 'one marginal offer @ $50, auction_type = 7';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1170, 100, u0, []/60, mpopt);    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp, cp5 + lab_p_gap/2, 3, [t ' : prices'] );    t_is( cp, (cp1 + cp3) / 2, 3, [t ' : prices'] );        t = 'one marginal offer @ $50, auction_type = 8';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1180, 100, u0, []/60, mpopt);    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp(G,:), cp1(G,:), 3, [t ' : gen prices'] );    t_is( cp(L,:), cp3(L,:), 3, [t ' : load prices'] );        t = 'one marginal offer @ $50, auction_type = 0';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1100, 100, u0, []/60, mpopt);    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp, p, 3, [t ' : prices'] );            %%-----  one bid block marginal @ $55  -----    p(L(2),2) = 55;    t = 'one marginal bid @ $55, auction_type = 5';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1150, 100, u0, []/60, mpopt);    cq5 = cq;    cp5 = cp;    Qfudge =  zeros(size(p));    Qfudge(L,:) = diag(gen(L,QG) ./ gen(L,PG) .* bus(Lbus, LAM_Q)) * ones(size(p(L,:)));        t_is( cq(G(1),2:3), [24 0], 1, t );    t_is( cp(G(1),:), 50.016, 2, t );    t_is( cq(L(2),1:2), [10 0.63], 1, t );    t_is( cp(L(2),:), 55, 2, t );    t_is( cp(G,1), bus(Gbus, LAM_P), 3, [t ' : gen prices'] );    t_is( cp(L,1), bus(Lbus, LAM_P) + Qfudge(L,1), 3, [t ' : load prices'] );        lao_gap   = p(G(1),2) - bus(Gbus(1), LAM_P);    fro_gap   = p(G(6),3) - bus(Gbus(6), LAM_P);    lab_p_gap = p(L(2),2) - (bus(Lbus(2), LAM_P) + Qfudge(L(2),1));    frb_p_gap = p(L(3),3) - (bus(Lbus(3), LAM_P) + Qfudge(L(3),1));        t_is( lao_gap, -0.0156, 2, 'lao_gap');    t_is( fro_gap, 5.9998, 2, 'fro_gap');    t_is( lab_p_gap, 0, 2, 'lab_p_gap');    t_is( frb_p_gap, -5.8052, 2, 'frb_p_gap');        t = 'one marginal bid @ $55, auction_type = 1';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1110, 100, u0, []/60, mpopt);    cp1 = cp;    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp, cp5+lao_gap, 3, [t ' : prices'] );        t = 'one marginal bid @ $55, auction_type = 2';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1120, 100, u0, []/60, mpopt);    cp2 = cp;    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp(G,:), cp5(G,:)+fro_gap, 3, [t ' : gen prices'] );    t_is( cp(L(1),:), cp5(L(1),:)+fro_gap, 3, [t ' : load 1 price'] );    t_is( cp(L(2),:), 55, 3, [t ' : load 2 price'] );    t_is( cp(L(3),:), 60, 3, [t ' : load 3 price'] );        t = 'one marginal bid @ $55, auction_type = 3';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1130, 100, u0, []/60, mpopt);    cp3 = cp;    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp, cp5, 2, [t ' : prices'] );        t = 'one marginal bid @ $55, auction_type = 4';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1140, 100, u0, []/60, mpopt);    cp4 = cp;    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp(G(1),:), 50, 3, [t ' : gen 1 price'] );    t_is( cp(G(2:6),:), cp5(G(2:6),:)+frb_p_gap, 3, [t ' : gen 2-6 prices'] );    t_is( cp(L,:), cp5(L,:)+frb_p_gap, 3, [t ' : load prices'] );        t = 'one marginal bid @ $55, auction_type = 6';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1160, 100, u0, []/60, mpopt);    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp, cp1, 1, [t ' : prices'] );        p2 = p;    p2(G,:) = [ 0 0 100;                0 0 100;                0 0 100;                0 0 100;                0 0 100;                0 0 100 ];    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p2, 1160, 100, u0, []/60, mpopt);    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp(G(1),:), 44.2104, 2, [t ' : gen 1 prices'] );  %% not clipped this time    t_is( cp(G(2:6),:), cp4(G(2:6),:), 2, [t ' : gen 2-6 prices'] );    t_is( cp(L,:), cp4(L,:), 2, [t ' : load prices'] );        t = 'one marginal bid @ $55, auction_type = 7';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1170, 100, u0, []/60, mpopt);    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp, cp5 + lao_gap/2, 2, [t ' : prices'] );    t_is( cp, (cp1 + cp3) / 2, 3, [t ' : prices'] );        t = 'one marginal bid @ $55, auction_type = 8';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1180, 100, u0, []/60, mpopt);    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp(G,:), cp1(G,:), 3, [t ' : gen prices'] );    t_is( cp(L,:), cp3(L,:), 3, [t ' : load prices'] );        t = 'one marginal bid @ $55, auction_type = 0';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1100, 100, u0, []/60, mpopt);    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp, p, 3, [t ' : prices'] );            %%-----  one bid block marginal @ $54.50 and one offer block marginal @ $50  -----    p(L(2),2) = 54.5;    t = 'marginal offer @ $50, bid @ $54.50, auction_type = 5';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1150, 100, u0, []/60, mpopt);    cq5 = cq;    cp5 = cp;    Qfudge =  zeros(size(p));    Qfudge(L,:) = diag(gen(L,QG) ./ gen(L,PG) .* bus(Lbus, LAM_Q)) * ones(size(p(L,:)));        t_is( cq(G(1),2:3), [23.74 0], 1, t );    t_is( cp(G(1),:), 50, 2, t );    t_is( cq(L(2),1:2), [10 0.39], 1, t );    t_is( cp(L(2),:), 54.5, 2, t );    t_is( cp(G,1), bus(Gbus, LAM_P), 4, [t ' : gen prices'] );    t_is( cp(L,1), bus(Lbus, LAM_P) + Qfudge(L,1), 3, [t ' : load prices'] );        lao_gap   = p(G(1),2) - bus(Gbus(1), LAM_P);    fro_gap   = p(G(6),3) - bus(Gbus(6), LAM_P);    lab_p_gap = p(L(2),2) - (bus(Lbus(2), LAM_P) + Qfudge(L(2),1));    frb_p_gap = p(L(3),3) - (bus(Lbus(3), LAM_P) + Qfudge(L(3),1));        t_is( lao_gap, 0, 2, 'lao_gap');    t_is( fro_gap, 6.5306, 2, 'fro_gap');    t_is( lab_p_gap, 0, 2, 'lab_p_gap');    t_is( frb_p_gap, -5.7040, 2, 'frb_p_gap');        t = 'marginal offer @ $50, bid @ $54.50, auction_type = 1';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1110, 100, u0, []/60, mpopt);    cp1 = cp;    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp, cp5, 3, [t ' : prices'] );        t = 'marginal offer @ $50, bid @ $54.50, auction_type = 2';    [MVAbase, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...        runmkt('t_auction_case', q, p, 1120, 100, u0, []/60, mpopt);    cp2 = cp;    t_is( cq, cq5, 4, [t ' : quantities'] );    t_is( cp(G,:), cp5(G,:)+fro_gap, 3, [t ' : gen prices'] );    t_is( cp(L(1),:), cp5(L(1),:)+fro_gap, 3, [t ' : load 1 price'] );    t_is( cp(L(2),:), 54.5, 3, [t ' : load 2 price'] );    t_is( cp(L(3),:), 60, 3, [t ' : load 3 price'] );    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -