Borrar filtros
Borrar filtros

Constrained Integer Genetic Algorithm

2 visualizaciones (últimos 30 días)
Natialol
Natialol el 1 de Abr. de 2013
Hello,
I am using 2012b.
Need help on solving a problem with the GA toolbox (have a variant soln that works but am not sure of the soln).
I have a fitness function say 'piqe' that I am looking for the global minimum. The inputs to this function are (x1 ... xn). These inputs variables can only take integer values 1:5 (bounds).
The integer variables serve as indexes (1 is leftmost, 5 rightmost) to a matrix function say
P = [30 20 10 5 0; 27 17 7 2 0; 20 14 4 0 0; 14 12 7 4 0; ..................];
I need to constrain the inputs to 'piqe' so that P(1,x1) + P(2,x2) + ...... + P(n,xn)<Constant.
I am having some problem on implementing the last part (relational constraint) into the toolbox. thanks
Here is what I have for now (courtesy Alan Weiss), doesn't work yet
function [c,ceq] = pconstraint(x,P)
ceq = [];
c = -Constant; % put in the value of Constant here
for ii = 1:numel(x)
c = c + P(ii,x(ii));
end
lb=[1 1 1 1 1];
ub=[5 5 5 5 5];
[x,fval,exitFlag,output,population,scores] = ga(@piqe,5,[],[],[],[],lb,ub,@(x)pconstraint(x,P),[1 2 3 4 5],[]);
I run into several errors regarding the ineq constraint, the integer constraint and the no of inputs. Any leads.
Thanks

Respuestas (0)

Categorías

Más información sobre Genetic Algorithm en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by