Variable number of variables for each polling point for optimization algorithm

2 views (last 30 days)
The number of variables in my input point vector (x0) to the genetic algorithm changes depending on the integer value of one of the elements in x0 (ranging from 1 to n). This value can vary from one population to another. Therefore, each population may have a different size. Since I am using vectorization my x0 matrix must be square (population size x n), and so there may be differing numbers of redundant elements in each population.
Is there a way to tell the genetic algorithm to ignore/account for these redundant elements, so that the algorithm may potentially run more efficiently?
Currently, my objective function sets the redundant elements to zero, which seems to work but is not the most elegant approach.

Answers (1)

Matt J
Matt J on 24 Sep 2015
Edited: Matt J on 24 Sep 2015
Your population matrix must have a fixed size, but there's no reason why the redundant elements need to slow down or even participate in the evaluation of the fitness function in any way. Just structure your fitness function like this:
function fvals=myfitness(X0)
n=X0(i); %The last non-redundant index
X0(:,n+1:end)=[]; %delete redundant values
.... %continue deriving fitness values from X0
end

Community Treasure Hunt

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

Start Hunting!