Info

此问题已关闭。 请重新打开它进行编辑或回答。

why does this says converged to an infeasible point

1 次查看(过去 30 天)
i am running below code. it is still to be able to output matrix of x, and fval. but it says this. then im not sure if the values makes sense.
Converged to an infeasible point.
fmincon stopped because the size of the current step is less than
the value of the step size tolerance but constraints are not
satisfied to within the value of the constraint tolerance.
<stopping criteria details>
Consider enabling the interior point method feasibility mode.
Converged to an infeasible point.
fmincon stopped because the size of the current step is less than
the value of the step size tolerance but constraints are not
satisfied to within the value of the constraint tolerance.
<stopping criteria details>
Optimization stopped because the relative changes in all elements of x are
less than options.StepTolerance = 1.000000e-10, but the relative maximum constraint
violation, 9.267884e-01, exceeds options.ConstraintTolerance = 1.000000e-06.
a = 0.001;
b = 10;
c = 0.01;
d = 0.01;
e = 0.05;
f = 0.005;
g = 1;
h = 1;
% Define function to calculate impedance
function Impedance = Z(R, L)
w = 2*pi*50; % Assuming 50 Hz power system
Impedance = R + L*1j*w;
end
% Calculate impedances
Z12 = Z(88e-3, 130e-6);
Z15 = Z(13e-3, 280e-6);
Z35 = Z(78e-3, 50e-3);
Z45 = Z(29e-3, 467e-6);
Z6 = Z(30e-3, 147e-6);
Y12 = 1/Z12;
Y15 = 1/Z15;
Y35 = 1/Z35;
Y45 = 1/Z45;
Y6 = 1/Z6;
% Construct admittance matrix
Y = [Y15+Y12, -Y12, 0, 0, -Y15, 0;
-Y12, Y12, 0, 0, 0, 0;
0, 0, Y35, 0, -Y35, 0;
0, 0, 0, Y45, -Y45, 0;
-Y15, 0, -Y35, -Y45, Y15+Y35+Y45+Y6, -Y6;
0, 0, 0, 0, -Y6, Y6];
G = real(Y);
B = imag(Y);
% Define objective function
fun = @(x) a*x(13) + b*x(13)^2 + c*x(14) + d*x(14)^2 + e*x(15) + f*x(15)^2 + g*x(18) + h*x(18)^2;
% Set up constraints
A = [];
b = [];
Aeq = [];
beq = [];
lb = [0;0;0;0;0;0;
230;230;230;230;230;230;
24000;41000;34000;0;0;0;
-89600;-89600;-89600;0;0;-89600];
ub = [0;2*pi;2*pi;2*pi;2*pi;2*pi;
240;240;240;240;240;240;
89600;89600;89600;0;0;89600;%89600
89600;89600;89600;0;0;89600;
];
% Define nonlinear constraints
nonlcon = @(x) power(x, G, B);
% Provide initial point for fmincon closer to feasible region
x0 = [0.1; 0.1; 0.1; 0.1; 0.1; 0.1; % angles
230; 230; 230; 230; 230; 230; % voltages
1; 1; 1; 0; 0; 1; % active powers
1; 1; 1; 0; 0; 1]; % reactive powers
% Set solver options
%options = optimoptions('fmincon', 'Algorithm', 'interior-point', 'Display', 'iter');
options = optimoptions('fmincon', 'Algorithm', 'interior-point', 'Display', 'iter','MaxFunctionEvaluations',4e3)
% Call fmincon with updated options
[x, fval, exitflag, output] = fmincon(@(x) fun(x), x0, A, b, Aeq, beq, lb, ub, nonlcon, options);
% Display exit message
disp(output.message);
% Define power flow equations
function [c, ceq] = power(x, G, B)
w = 2*pi*50;
% Define power injections
PL = [24e3; 41e3; 50e3; 44e3];
QL = [18e3; 28e3; 34e3; 0];
% Calculate active and reactive powers
P = zeros(6, 1);
Q = zeros(6, 1);
P(1) = x(7)*(x(11)*(G(1,5)*cos(x(1)-x(5))+B(1,5)*w*sin(x(1)-x(5)))+x(8)*(G(1,2)*cos(x(1)-x(2))+B(1,2)*w*sin(x(1)-x(2))))-x(13);
Q(1) = x(7)*(x(11)*(G(1,5)*sin(x(1)-x(5))+B(1,5)*w*cos(x(1)-x(5)))+x(8)*(G(1,2)*sin(x(1)-x(2))+B(1,2)*w*cos(x(1)-x(2))))-x(19);
P(2) = x(8)*(x(7)*(G(2,1)*cos(x(2)-x(1))+B(2,1)*w*sin(x(2)-x(1))))-x(14);
Q(2) = x(8)*(x(7)*(G(2,1)*sin(x(2)-x(1))+B(2,1)*w*cos(x(2)-x(1))))-x(20);
P(3) = x(9)*(x(11)*(G(3,5)*cos(x(3)-x(5))+B(3,5)*w*sin(x(3)-x(5))))-x(15);
Q(3) = x(9)*(x(11)*(G(3,5)*sin(x(3)-x(5))+B(3,5)*w*cos(x(3)-x(5))))-x(21);
P(4) = x(10)*(x(11)*(G(4,5)*cos(x(4)-x(5))+B(4,5)*w*sin(x(4)-x(5))));
Q(4) = x(10)*(x(11)*(G(4,5)*sin(x(4)-x(5))+B(4,5)*w*cos(x(4)-x(5))));
P(5) = x(11)*(x(7)*(G(1,5)*cos(x(5)-x(1))+B(1,5)*w*sin(x(5)-x(1)))+...
x(9)*(G(3,5)*cos(x(5)-x(3))+B(3,5)*w*sin(x(5)-x(3)))+...
x(10)*(G(4,5)*cos(x(5)-x(4))+B(4,5)*w*sin(x(5)-x(4)))+...
x(12)*(G(5,6)*cos(x(5)-x(6))+B(5,6)*w*sin(x(5)-x(6))));
Q(5) = x(11)*(x(7)*(G(1,5)*sin(x(5)-x(1))+B(1,5)*w*cos(x(5)-x(1)))+...
x(9)*(G(3,5)*sin(x(5)-x(3))+B(3,5)*w*cos(x(5)-x(3)))+...
x(10)*(G(4,5)*sin(x(5)-x(4))+B(4,5)*w*cos(x(5)-x(4)))+...
x(12)*(G(5,6)*sin(x(5)-x(6))+B(5,6)*w*cos(x(5)-x(6))));
P(6) = x(12)*(x(11)*(G(6,5)*cos(x(6)-x(5))+B(6,5)*w*sin(x(6)-x(5))));
Q(6) = x(12)*(x(11)*(G(6,5)*sin(x(6)-x(5))+B(6,5)*w*cos(x(6)-x(5))));
% Set up nonlinear equality constraints
ceq = [P(1) + PL(1);
Q(1) + QL(1);
P(2) + PL(2);
Q(2) + QL(2);
P(3) + PL(3);
Q(3) + QL(3);
P(4) + PL(4);
Q(4) + QL(4);
P(5) - x(17);
Q(5) - x(23);
P(6) - x(18);
Q(6) - x(24);
sum(P)+sum(PL)-x(17)-x(18);
sum(Q)+sum(QL)-x(23)-x(24);];
% Set up nonlinear inequality constraints (none in this case)
c = [];
end
display(x);
display(fval);

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by