Setting linear constraints for fmincon,

42 次查看(过去 30 天)
wasif
wasif 2024-9-3,7:38
编辑: Torsten 2024-9-3,8:11
I am setting the linear inequality constraints for my problem in fmincon.
My problem is min_(gamma,t) t s.t -t<=0; PS(gamma) - t <= 0; - PS(gamma) - t <= 0; i want to minimize t and my optimization variables are both t and gamma. gamma is comlex in nature so i am separating real and imaginary parts for fmincon in x_opt. A and B are not correct anyone can help ?
function [A, B] = linear_constraints(x_opt---)
real_gamma = x_opt(1:Nris+2); % Real part of gamma
imag_gamma = x_opt(Nris+3:length(x_opt)-1); % Imaginary part of gamma
gamma = real_gamma + 1i * imag_gamma; % Recombine gamma as complex vector
A = zeros(0, length(x_opt));
B = zeros(0, 1);
%% Constraint (a): -t <= 0
A_a = zeros(1, length(x_opt)); % Coefficients for all variables
A_a(end) = -1; % -t in the last column
B_a = 0; % Right-hand side of constraint
% Append to A and B
A = [A; A_a];
B = [B; B_a];
%% Constraint (b): PS(gamma) - t <= 0
% PS_term is a scalar real value based on gamma
PS_term = PS(gamma);
A_b = zeros(1, length(x_opt)); % Coefficients for all variables
%A_b(1:Nris+2) = (PS_term); % Include coefficients for gamma
A_b(end) = -1; % Coefficient for -t
B_b = -PS_term; % Right-hand side of constraint
% Append to A and B
A = [A; A_b];
B = [B; B_b];
%% Constraint (d): - PS(gamma) - t <= 0
PS_term_1 = -Ps(gamma)
A_d = zeros(1, length(x_opt));
%A_d(1:Nris+2) = ; % Coefficients for gamma
A_d(end) = -1; % Coefficient for -t
B_d = (TA_PS_term); % Right-hand side of constraint
% Append to A and B
A = [A; A_d];
B = [B; B_d];
end

回答(1 个)

Torsten
Torsten 2024-9-3,8:09
编辑:Torsten 2024-9-3,8:11
If real(gamma) and imag(gamma) are vectors of optimization variables, the constraints
PS(gamma) - t <= 0;
- PS(gamma) - t <= 0;
are nonlinear constraints. You will have to define them in function "nonlcon".

类别

Help CenterFile Exchange 中查找有关 Gamma Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by