필터 지우기
필터 지우기

How do I solve this problem at the optimization toolbox?

조회 수: 2 (최근 30일)
민제 강
민제 강 2021년 7월 1일
답변: Star Strider 2021년 7월 1일
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에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by