COMBINECOST Calculate the cost of combining two maximal cliques. [COST] = COMBINECOST(MAXCLIQUES,MAXCLIQUEIDX) Calculate the cost of combining two maximal cliques in terms of the number of scalar variables and linking constraints that will be required after combining the maximal cliques specified in maxcliquesidx. This is the clique combination heuristic described in [1]. Negative costs indicate that the heuristic predicts decreased computational costs after combining the specified maximal cliques. Inputs: MAXCLIQUES : Cell array containing the buses contained in each maximal clique. MAXCLIQUESIDX : Vector of length two with elements corresponding to the candidate maximal cliques. Outputs: COST : Scalar indicating the cost, as defined by the heuristic in [1] of combining the specified maximal cliques. [1] D.K. Molzahn, J.T. Holzer, B.C. Lesieutre, and C.L. DeMarco, "Implementation of a Large-Scale Optimal Power Flow Solver Based on Semidefinite Programming," IEEE Transactions on Power Systems, vol. 28, no. 4, pp. 3987-3998, November 2013.
0001 function [cost] = combineCost(maxcliques,maxcliquesidx) 0002 %COMBINECOST Calculate the cost of combining two maximal cliques. 0003 % [COST] = COMBINECOST(MAXCLIQUES,MAXCLIQUEIDX) 0004 % 0005 % Calculate the cost of combining two maximal cliques in terms of the 0006 % number of scalar variables and linking constraints that will be 0007 % required after combining the maximal cliques specified in 0008 % maxcliquesidx. This is the clique combination heuristic described in 0009 % [1]. Negative costs indicate that the heuristic predicts 0010 % decreased computational costs after combining the specified maximal 0011 % cliques. 0012 % 0013 % Inputs: 0014 % MAXCLIQUES : Cell array containing the buses contained in each 0015 % maximal clique. 0016 % MAXCLIQUESIDX : Vector of length two with elements corresponding to 0017 % the candidate maximal cliques. 0018 % 0019 % Outputs: 0020 % COST : Scalar indicating the cost, as defined by the heuristic in 0021 % [1] of combining the specified maximal cliques. 0022 % 0023 % [1] D.K. Molzahn, J.T. Holzer, B.C. Lesieutre, and C.L. DeMarco, 0024 % "Implementation of a Large-Scale Optimal Power Flow Solver Based on 0025 % Semidefinite Programming," IEEE Transactions on Power Systems, 0026 % vol. 28, no. 4, pp. 3987-3998, November 2013. 0027 0028 % MATPOWER 0029 % Copyright (c) 2013-2019, Power Systems Engineering Research Center (PSERC) 0030 % by Daniel Molzahn, PSERC U of Wisc, Madison 0031 % 0032 % This file is part of MATPOWER/mx-sdp_pf. 0033 % Covered by the 3-clause BSD License (see LICENSE file for details). 0034 % See https://github.com/MATPOWER/mx-sdp_pf/ for more info. 0035 0036 %% define undocumented MATLAB function ismembc() if not available (e.g. Octave) 0037 if exist('ismembc') 0038 ismembc_ = @ismembc; 0039 else 0040 ismembc_ = @ismembc_octave; 0041 end 0042 0043 maxcliques1 = maxcliques{maxcliquesidx(1)}; 0044 maxcliques2 = maxcliques{maxcliquesidx(2)}; 0045 nintersect = sum(ismembc_(maxcliques1, maxcliques2)); 0046 0047 elimmaxcliques(1) = length(maxcliques1); 0048 elimmaxcliques(2) = length(maxcliques2); 0049 lnewmaxcliques = sum(elimmaxcliques) - nintersect; 0050 0051 nvarafter = (lnewmaxcliques)*(2*lnewmaxcliques+1) - sum((elimmaxcliques).*(2*elimmaxcliques+1)); 0052 0053 ocostbefore = (nintersect)*(2*nintersect+1); 0054 0055 cost = nvarafter - ocostbefore;