如何将以下约束传递给Matlab ga
优化函数?请注意,x
是向量1xnvars
0.2 <= sum(x,2)/(W*H) <= 0.4
where `W` and `H` are two constant.
x(1) >= x(2) >= ... >= x(size(x,1))
答案 0 :(得分:1)
有关文档,请参阅here。
A = cat(1,ones(1,nvars), ones(1,nvars)*-1)/W/H;
b = [0.4;-0.2];
function [ceq ce] = noncolon1(x)
ce = [];
ceq = x(1,2:end) - x(1,1:end-1);
end
[x , fval] = ga(@fitnessfunc,nvars,A,b,[],[],[],[],@noncolon1);