How do I solve this problem at the optimization toolbox?

2 次查看(过去 30 天)
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!

采纳的回答

Star Strider
Star Strider 2021-7-1
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)
Optimization terminated: average change in the fitness value less than options.FunctionTolerance.
Xr = 1×2
-0.1234 -6.0000
fval = -1.3101e+05
exitflag = 1
output = struct with fields:
problemtype: 'boundconstraints' rngstate: [1×1 struct] generations: 97 funccount: 4612 message: 'Optimization terminated: average change in the fitness value less than options.FunctionTolerance.' maxconstraint: 0 hybridflag: []
population = 50×2
-0.1234 -6.0000 -0.1234 -6.0000 -0.1234 -6.0000 -0.1234 -6.0000 -0.1234 -5.9999 -0.1234 -6.0000 -0.1234 -6.0000 -0.1234 -6.0000 -0.1234 -6.0000 -0.1234 -6.0000
scores = 50×1
1.0e+05 * -1.3101 -1.3101 -1.3101 -1.3101 -1.3100 -1.3101 -1.3101 -1.3101 -1.3101 -1.3101
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 个)

类别

Help CenterFile Exchange 中查找有关 Nonlinear Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by