0

これは私の最初の投稿です!

添付の画像で利用可能な QP アルゴリズムをコーディングしましたが、残念ながら解決策は得られませんでした。私が持っているエラーメッセージは「警告:ソルバーは適用できません(gurobi)」です。gurobi が QP を解決するため、どういうわけか QP を持っていないように見えます。誰でもコードを見ることができますか?

ありがとう!

% This function returns losses of the grid in addition to matrices of
% active power, reactive power, and status of the lines. Each element of
% each matrix represent the corresponding value for the (i,j) line
%
% Parameters:
% R: (i,j) element indicates resistance of line composed with bus i and j
% P_bus: element i indicates real power load or real power from substation
% Q_bus: same logic for reactive power
% B_F: contains subset of buses which are substations
% B_notF: contains subset of buses which are not substations
%
%
%-------------------------------------------------------------------------%

function [Losses, val_P, val_Q, val_Y] = Quadratic_Programming(R,P_bus,Q_bus,B_F,B_notF,switches,non_switches)

% Active_Power: matrix which its (i,j) elements correspond to active power 
% going from bus i to bus j
% Reactive_Power: same logic, but for reactive power
% Configuration: matrix indicating in which direction the power flow travels for each
% line

P = sdpvar(length(R),length(R));
Q = sdpvar(length(R),length(R));
Z = sdpvar(length(R),length(R));

Constraints = [];

% Constraints 5
Constraints = [Constraints, sum(P(:,B_notF),1)' - sum(P(B_notF,:),2) == P_bus(B_notF)];

% Constraints 6
Constraints = [Constraints, sum(Q(:,B_notF),1)' - sum(Q(B_notF,:),2) == Q_bus(B_notF)];

% Constraints 7
Constraints = [Constraints, sum(P(B_F,:),2) == P_bus(B_F)];

% Constraints 8
Constraints = [Constraints, sum(Q(B_F,:),2) == Q_bus(B_F)];

M = 5000; %big-M constraint : how to formulate this properly??

% Constraints 9
Constraints = [Constraints, 0 <= P <= M*Z];

% Constraints 10
Constraints = [Constraints, 0 <= Q <= M*Z];

% Constraints 11
Constraints = [Constraints, Z >= 0];

% Constraints 12
Constraints = [Constraints, Z(:,B_F) == 0];

% Constraints 13
if (length(non_switches)>=1)
    Constraints = [Constraints, Z(sub2ind(size(Z),non_switches(1,:),non_switches(2,:)))' + Z(sub2ind(size(Z),non_switches(2,:),non_switches(1,:)))' == 1];
end

% Constraints 14
Y = binvar(size(switches,2),1);
Constraints = [Constraints, (Z(sub2ind(size(Z),switches(1,:),switches(2,:)))' + Z(sub2ind(size(Z),switches(2,:),switches(1,:)))') == Y(:)];

% Constraints 15
Constraints = [Constraints, sum(Z(:,B_notF),1)' == ones(length(B_notF),1)];

% objective
obj = sum(sum(R.*(P.^2 + Q.^2)));

optimize(Constraints,obj,sdpsettings('solver','gurobi'));
4

0 に答える 0