Please help me to solve the errors in the program

9 visualizaciones (últimos 30 días)
KRISHNAPRIYA U
KRISHNAPRIYA U el 9 de Mayo de 2021
Respondida: Walter Roberson el 9 de Mayo de 2021
clc
IntCon = 1;
function z=fun(x)
z = ((x(1)^2 + x(2)^2 - 11)^2 + (x(1)+ x(2)^2 - 7)^2 );
A = [];
b = [];
Aeq = [];
beq = [];
lb = [0 0];
ub = [6 6];
nonlcon = [];
x = ga(@fun,2,A,b,Aeq,beq,lb,ub,nonlcon,IntCon)

Respuestas (1)

Walter Roberson
Walter Roberson el 9 de Mayo de 2021
Just need the definition for the function to be below the rest of the script.
IntCon = 1;
A = [];
b = [];
Aeq = [];
beq = [];
lb = [0 0];
ub = [6 6];
nonlcon = [];
x = ga(@fun,2,A,b,Aeq,beq,lb,ub,nonlcon,IntCon)
Optimization terminated: average change in the penalty fitness value less than options.FunctionTolerance and constraint violation is less than options.ConstraintTolerance.
x = 1×2
3.0000 1.7321
function z=fun(x)
z = ((x(1)^2 + x(2)^2 - 11)^2 + (x(1)+ x(2)^2 - 7)^2 );
end

Categorías

Más información sobre Genetic Algorithm 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