function y = simple_fitness(x)
y = 100*(x(1)^2 - x(2))^2 + (1 - x(1))^2;
function [c,ceq] = simple_constraint(x)
c = [1.5 + x(1)*x(2) + x(1) - x(2);-x(1)*x(2) + 10];
ceq = [];
Objective Function = @simple_fitness;
nvars = 2;
LB = [0 0];
UB = [1 13];
ConstraintFunction = @simple_constraint;
[x,fval] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB,ConstraintFunction)
simple_fitness
输入参数的数目不足。
出错 simple_fitness (line 2)
y = 100*(x(1)^2 - x(2))^2 + (1 - x(1))^2;
我用的是MATLAB64位R2016a
我经常遇到输入参数数目不足的问题,有谁能告诉我这怎么解决?

 Réponse acceptée

0 votes

试试这样:
ObjectiveFunction = @(x)100*(x(1)^2 - x(2))^2 + (1 - x(1))^2;
ConstraintFunction = @(x)deal([1.5 + x(1)*x(2) + x(1) - x(2);-x(1)*x(2) + 10],[]);
nvars = 2;
LB = [0 0];
UB = [1 13];
[x,fval] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB,ConstraintFunction)

Plus de réponses (0)

Catégories

En savoir plus sur 优化 dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!