How do I solve this problem at the optimization toolbox?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
민제 강
le 1 Juil 2021
Réponse apportée : Star Strider
le 1 Juil 2021
function Y = objective_function(X)
x1=X(1,1);
x2=X(1,2);
p00 = -9.601e+04;
p10 = -1031;
p01 = -4854;
p20 = 8810;
p11 = 404.4;
p02 = 359.8;
p21 = -228.4;
p12 = 165.8;
p03 = 356.1;
Y = p00 + p10*x(1) + p01*x(2) + p20*x(1).^2 + p11*x(1)*x(2) + p02*x(2).^2 + p21*x(1).^2*x(2) + p12*x(1)*x(2).^2 + p03*x(2).^3;
end
This is my code.
When I run a optimization toolbox, a problem such as the picture occur.
I'd appreciate your help. Thank you!![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/670498/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/670498/image.png)
0 commentaires
Réponse acceptée
Star Strider
le 1 Juil 2021
It would llikely be easier to just call ga from a script —
lb = [-10 -6];
ub = [ 10 6];
nvars = 2;
[Xr,fval,exitflag,output,population,scores] = ga(@objective_function, nvars, [], [], [], [], lb, ub)
function Y = objective_function(X)
x(1)=X(1,1);
x(2)=X(1,2);
p00 = -9.601e+04;
p10 = -1031;
p01 = -4854;
p20 = 8810;
p11 = 404.4;
p02 = 359.8;
p21 = -228.4;
p12 = 165.8;
p03 = 356.1;
Y = p00 + p10*x(1) + p01*x(2) + p20*x(1).^2 + p11*x(1)*x(2) + p02*x(2).^2 + p21*x(1).^2*x(2) + p12*x(1)*x(2).^2 + p03*x(2).^3;
end
.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Nonlinear Optimization dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!