Home > matpower7.1 > extras > misc > qcqp_opf_test.m

qcqp_opf_test

PURPOSE ^

QCQP_OPF_TEST Testing QCQP_OPF program with CVX 2.1 and SeDuMi 1.3

SYNOPSIS ^

function qcqp_opf_test(casedata)

DESCRIPTION ^

QCQP_OPF_TEST Testing QCQP_OPF program with CVX 2.1 and SeDuMi 1.3
   QCQP_OPF_TEST( CASEDATA )

   Input:
       CASEDATA : either a MATPOWER case struct or a string containing
           the name of the file with the case data
           (see also CASEFORMAT and LOADCASE)

   NOTE: Requires CVX and SeDuMi.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function qcqp_opf_test(casedata)
0002 %QCQP_OPF_TEST Testing QCQP_OPF program with CVX 2.1 and SeDuMi 1.3
0003 %   QCQP_OPF_TEST( CASEDATA )
0004 %
0005 %   Input:
0006 %       CASEDATA : either a MATPOWER case struct or a string containing
0007 %           the name of the file with the case data
0008 %           (see also CASEFORMAT and LOADCASE)
0009 %
0010 %   NOTE: Requires CVX and SeDuMi.
0011 
0012 %   MATPOWER
0013 %   Copyright (c) 2016, Power Systems Engineering Research Center (PSERC)
0014 %   by Cedric Josz, Jean Maeght, Stephane Fliscounakis, and Patrick Panciatici
0015 %
0016 %   This file is part of MATPOWER Extras.
0017 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0018 %   See https://github.com/MATPOWER/matpower-extras for more info.
0019 
0020 
0021 %% upload complex data using qcqp_opf (MODEL = 0)
0022 [nVAR, nEQ, nINEQ, C, c, A, a, B, b, S] = qcqp_opf(casedata);
0023 
0024 % compute convex relaxation of ACOPF using uploaded data
0025 cvx_begin sdp
0026     cvx_precision best
0027     cvx_solver sedumi
0028     variable Z(nVAR,nVAR) hermitian
0029     
0030     minimize( vec(C)'*vec(Z) + c ) % objective function
0031     
0032     for k = 1:nEQ
0033         vec((A{k}+A{k}')/2)'*vec(Z)      == real(a(k)); % real part
0034         vec((A{k}-A{k}')/(2*1i))'*vec(Z) == imag(a(k)); % imaginary part
0035     end
0036     
0037     for k = 1:nINEQ
0038         if B{k}' == B{k} % checking whether B{k} is Hermitian
0039             vec(B{k})'*vec(Z) <= b(k); % inequality constraints
0040         else
0041             vec((B{k}+B{k}')/2)'*vec(Z)      <= real(b(k)); % real part
0042             vec((B{k}-B{k}')/(2*1i))'*vec(Z) <= imag(b(k)); % imaginary part
0043         end
0044     end
0045     
0046     Z >= 0;
0047 cvx_end
0048 
0049 %% upload Hermitian data using qcqp_opf (MODEL = 1)
0050 [nVAR, nEQ, nINEQ, C, c, A, a, B, b, S] = qcqp_opf(casedata,1);
0051 
0052 % compute convex relaxation of ACOPF using uploaded data
0053 cvx_begin sdp
0054     cvx_precision best
0055     cvx_solver sedumi
0056     variable Z(nVAR,nVAR) hermitian
0057     
0058     minimize( vec(C)'*vec(Z) + c ) % objective function
0059     
0060     for k = 1:nEQ
0061         vec(A{k})'*vec(Z) == a(k); % equality constraints
0062     end
0063      
0064     for k = 1:nINEQ
0065         vec(B{k})'*vec(Z) <= b(k); % inequality constraints
0066     end
0067     
0068     Z >= 0;
0069 cvx_end
0070 
0071 %% upload symmetric data using qcqp_opf (MODEL = 2)
0072 [nVAR, nEQ, nINEQ, C, c, A, a, B, b, S] = qcqp_opf(casedata,2);
0073 
0074 % compute convex relaxation of ACOPF using uploaded data
0075 cvx_begin sdp
0076     cvx_precision best
0077     cvx_solver sedumi
0078     variable Z(nVAR,nVAR) symmetric
0079     
0080     minimize( vec(C)'*vec(Z) + c ) % objective function
0081     
0082     for k = 1:nEQ
0083         vec(A{k})'*vec(Z) == a(k); % equality constraints
0084     end
0085      
0086     for k = 1:nINEQ
0087         vec(B{k})'*vec(Z) <= b(k); % inequality constraints
0088     end
0089     
0090     Z >= 0;
0091 cvx_end

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005