Optimization nonlinear function with several variable

13 vues (au cours des 30 derniers jours)
Asshaa
Asshaa le 14 Mar 2022
Commenté : Walter Roberson le 16 Mar 2022
i have nonlinear function and the constraint have lower and upper boundary.
f(x,y,z)
0<=x<=2 , 0<=y<=1, -1<=z<=1
i want to optimize this function to find the max value. define g(x,y,z)=-f(x,y,z) since we want to find the max. How to use the fminsearch/fmincon on this fucntion in MATLAB?

Réponse acceptée

Walter Roberson
Walter Roberson le 14 Mar 2022
A = []; b = [];
Aeq = []; beq = [];
lb = [0 0 -1];
ub = [2 1 1];
nonlcon = [];
g = @(xyz) -f(xyz(1), xyz(2), xyz(3));
[bestxyz, fval] = fmincon(g, A, b, Aeq, beq, lb, ub, nonlcon);
  3 commentaires
Asshaa
Asshaa le 16 Mar 2022
f= @(xyz) 8+2.*x+2.*y.*(4-x.^2)+3.*(4-x.^2).*(1-y.^2)+((1/4).*x.^6+(x.^2).*(y.^2).*((4-x.^2).^2)+(9/4).*(x.^2).*(y.^4).*((4-x.^2).^2)+(x.^4).*(4-x.^2).*y.*z-(3/2).*(x.^4).*(y.^2).*(4-x.^2).*(2.*(z.^2)-1)-(3.*(x.^2).*(4-(x.^2)).*(y.^3).*z)).^(1/2);
g = @(xyz) -f(xyz(1),xyz(2),xyz(3));
A = [];
b = [];
Aeq = [];
beq = [];
lb = [0 0 -1];
ub = [2 1 1];
nonlcon = [];
xyz0=[1;0.5;0];
[bestxyz, fval] = fmincon(g,xyz0, A, b, Aeq, beq, lb, ub, nonlcon);
how shall i correct this?
Walter Roberson
Walter Roberson le 16 Mar 2022
f= @(xyz)
should be
f= @(x, y, z)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Nonlinear Optimization dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by