Optimization of a unknown vector variable

1 visualización (últimos 30 días)
Soumili Sen
Soumili Sen el 27 de Nov. de 2020
Comentada: Soumili Sen el 29 de Nov. de 2020
Hello ,
I have a code
a,b -----> variables should be vector(like a=[a1,a2,a3,a4])
x=h1*a^2+h2*b^2+h3;------>objctive fun(h1,h2,h3 are constants let say which has 1*4 value)
---->constraints are also present here.. so I am writting the code like
for i=1:4
x(i)=h1(i)*a^2+h2(i)*b^2+h3(i)
end
obj=sum(x);----->(objective function is basically summation of x )
x0=[1,1];
lb = [];
ub = [];
Aeq = [];
beq =[];
A = [];
b = [];
fun=@(p) obj(p(1),p(2));
nonlcon =@constraintfcn;
opts = optimoptions('fmincon','Display','iter','Algorithm','sqp');
[x_value,fval] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,opts);
But I am not getting the ans,I want optimized value as vector .
  2 comentarios
Matt J
Matt J el 27 de Nov. de 2020
Quite unclear, I'm afraid. What is the for-loop supposed to be doing? Do you have more than one objective to minimize? Why does the right hand side not depend on i?
Soumili Sen
Soumili Sen el 28 de Nov. de 2020
Editada: Soumili Sen el 28 de Nov. de 2020
yes, you are right. My objective function is summation of 'x' (I have modified my code), and the unknown optimized veriables are vector. so how can I continue to find the values?

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 28 de Nov. de 2020
Editada: Matt J el 28 de Nov. de 2020
H1=sum(h1);
H2=sum(h2);
H3=sum(h3);
obj=@(a,b) H1.*a.^2 +H2.*b.^2+H3;
x0=[1,1];
lb = [];
ub = [];
Aeq = [];
beq =[];
A = [];
b = [];
fun=@(p) obj(p(1),p(2));
nonlcon =@constraintfcn;
opts = optimoptions('fmincon','Display','iter','Algorithm','sqp');
[x_value,fval] = fmincon( fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,opts);
  12 comentarios
Matt J
Matt J el 29 de Nov. de 2020
You're welcome, but please Accept-click the answer if you consider the matter resolved.
Soumili Sen
Soumili Sen el 29 de Nov. de 2020
yah sure.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surrogate Optimization 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