I_line = sdpvar(length(lineParameters),2,'full');I_line_com = sdpvar(length(lineParameters),1,'full','complex');I_line_norm = sdpvar(length(lineParameters),1,'full');I_contactline = sdpvar(length(contactLine)*2,1,'full');I_sqr = sdpvar(length(contactLine)*2,1,'full');
k = binvar(length(lineParameters),1,'full');
% k is the decision variables
assign(k,lineParameters(:,6));
Constraints = [];
Constraints = [Constraints, sum(k)==numberOfNodes - 2];
for i = 2:numberOfNodes/2 keyIn = find(keyBranch(:,2)==i); keyOut = find(keyBranch(:,1)==i); Constraints = [Constraints, sum(I_line(keyIn,1)) - sum(I_line(keyOut,1)) == real(Iload(i))]; Constraints = [Constraints, sum(I_line(keyIn,2)) - sum(I_line(keyOut,2)) == imag(Iload(i))];endfor i = numberOfNodes/2 + 2:numberOfNodes keyIn = find(keyBranch(:,2)==i); keyOut = find(keyBranch(:,1)==i); Constraints = [Constraints, sum(I_line(keyIn,1)) - sum(I_line(keyOut,1)) == real(Iload(i))]; Constraints = [Constraints, sum(I_line(keyIn,2)) - sum(I_line(keyOut,2)) == imag(Iload(i))];end
for i = 1:length(I_line) I_line_com(i,1) = I_line(i,1) + sqrt(-1)*I_line(i,2); I_line_norm(i,1) = norm(I_line_com(i,1),2); Constraints = [Constraints, (I_line_norm(i,1) <= Imax(i)*k(i)):['transmission power' num2str(i)]]; if feasibleLine(i) == 1 Constraints = [Constraints, k(i) == feasibleLine(i)]; endendQ_Imax = zeros(length(contactLine)*2);for i = 1:length(contactLine) Constraints = [Constraints, I_line_norm(contactLine(i,1)) + I_line_norm(contactLine(i,2)) <= min(Imax(contactLine(i,1)),Imax(contactLine(i,2)))]; I_contactline(i*2-1,1) = I_line_norm(contactLine(i,1)); I_contactline(i*2,1) = I_line_norm(contactLine(i,2)); Q_Imax(i*2-1,i*2-1) = 1/Imax(contactLine(i,1)); Q_Imax(i*2,i*2) = 1/Imax(contactLine(i,2));end
Objective = I_contactline'*Q_Imax*I_contactline;
options = sdpsettings('solver','gurobi');tic;optimize(Constraints, Objective, options)
Dear Professor
I have a problem with my code, that bothers me about a month.Initially, my model is an LP model, I could solve it with YALMIP + Gurobi. However, that problem occurs when I change the objective function to quadratic without changing any constraints.Here is my code.
I am a YALMIP & Optimization beginner, thanks for your times. I'm looking forward to receiving your reply.
Best wishes
When the objection is linear, the problem could be solved, and get the right answer
But when the objection is quadratic, it warns me "'Solver not applicable (gurobi)'"
So I didn't specify any solver
It warned me "'Infeasible problem (BNB)'"
I read "debugging infeasible models", but I cannot deal with the problem
I wonder why gurobi cannot solve the problem?
In my opinion, this is a QP or QCP problem
And how to deal with the infeasible problem?
Because I think it must have a feasible solution, it's truly a simple example