optimize vector by fminimax

1 visualización (últimos 30 días)
koorosh dastan
koorosh dastan el 27 de Nov. de 2023
Editada: Torsten el 27 de Nov. de 2023
if i uuse fminimax to optimize vector how it recognize which element is suitable for it here is example
clear all
q=20;
random_numbersw = rand(1,20); % Random number from 0 to 1
random_numberst = -90 + (90 + 90) * rand(1, 20); % Random number from -90 to 90
x0 = [ random_numberst,random_numbersw ] ; %Initiat delta
ub = zeros(1, 40); % Initialize a matrix of zeros with 40 elements
ub(1:20) = 1; % Set values from 1 to 21 to 0
ub(21:40) = 90; % Set values from 22 to 40 to 90
lb = zeros(1, 40); % Initialize a matrix of zeros with 40 elements
lb(1:20) = 0; % Set values from 1 to 21 to 0
lb(21:40) = -90; % Set values from 22 to 40 to 90
[x,fval] = fminimax(@costy,x0,[],[],[],[],lb,ub)
Local minimum possible. Constraints satisfied. fminimax stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance.
x = 1×40
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5993 0.3742 0.8878 0.6410 0.4318 1.1086 1.0821 0.3574 0.5501 0.0653
fval = 1×21
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
function y = costy(deltaTeta)
f=9*10^9; %Freq
j=sqrt(-1); %Define Imaginary
l=(3*10^8)/f; %Lambda
k=(2*pi)/l; %Constant
d=0.5*l; %Distant of each element
q=20;
teta1=((-4):0.1:(-2));
g = zeros(q,length(teta1));
for h=1:q
for aa = 1:length(teta1)
g(h,aa) = g(h,aa)+(deltaTeta(h) * ( exp(j*(h-1) * (k*d*sind(teta1(aa)+deltaTeta(h+q)))))); %w W
end
end
y = abs(sum(g,1));
end
teta1=((-4):0.1:(-2)); is my input which it is not for optimize and my function should sweep it everytime and i want to optimize deltaTeta
here i s another example for more clearify my question if with my first input i have this vector (output) (1 2 5 6 9 5) and with next input i have this one (1 2 9 6 9 1) as you can see in two point they have different but in first one first input is minimize but second one is next input is minimize so how my function( here fminimax) recognize which input is suitable?
and is fminimax is good for it?
  1 comentario
Torsten
Torsten el 27 de Nov. de 2023
Please describe your optimization problem - once the forum understands it, we might be able to select a suitable solver for it.

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 27 de Nov. de 2023
if with my first input i have this vector (output) (1 2 5 6 9 5) and with next input i have this one (1 2 9 6 9 1) as you can see in two point they have different but in first one first input is minimize but second one is next input is minimize so how my function( here fminimax) recognize which input is suitable?
In both vectors in this example, the maximum value is the same, i.e. 9. fminimax will therefore view both vectors as equivalent for the purposes of optimization. Niether one is more optimal than the other.
Any third vector with a maximum value less than 9 will be more optimal than these. For example [7,7,8,8,8,8] has max value 8, so it is better than both the vectors in your example.

Más respuestas (0)

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by