How to fix this problem Genetic Algorithm
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ana Gabriela Fuentes
el 27 de Nov. de 2021
Respondida: Walter Roberson
el 27 de Nov. de 2021
This error appears in my code while trying to run it. I´m using this Genetic Algorithm to solve the problem of knapsack. Someone can tell me what im doing wrong?
I attach the code and the excel of the problem.
in the Excel file, first column is the article, second column the weight and third is the value. Im trying to solve for the optimal combination.
0 comentarios
Respuestas (1)
Walter Roberson
el 27 de Nov. de 2021
initpop = randi([0,1]);
So initpop is a single random scalar value, either 0.0 or 1.0 ?
pop= initpop(popsize,n) %初始种群initpop.m
So you are attempting to index that scalar value at (1000, something) ?
function pop=initpop(popsize,n)
but then it is also to be a function ??
Why are you doing
initpop = randi([0,1]);
??
0 comentarios
Ver también
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!