Skip to content

Instantly share code, notes, and snippets.

@gidili
Created April 4, 2010 03:45
Show Gist options
  • Save gidili/355077 to your computer and use it in GitHub Desktop.
Save gidili/355077 to your computer and use it in GitHub Desktop.
function [ Population ] = genHighDiversityPop(GenomeLength, FitnessFcn, options)
%generateHighDensityPopulation generates initial population of rules
% This function generates popSize rules of size chromSize. The rules are
% generated with pseudo-uniform distribution of densitites of 1s, spanning from
% very low to very high as this facilitates evolution.
%constants
chromSize = GenomeLength;
popSize = 100;
% thresholds go from 0 (all 0) to 1 (all 1) - need to play with params
thresholdVector = linspace(0.1,0.9,popSize);
% vectors are per row
Population = bsxfun(@lt,rand(popSize, chromSize),thresholdVector');
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment