function [xOpt,fval,exitflag,output,population,scores] = ...
% Particle swarm optimization for binary genomes.
% This function will optimize fitness functions where the variables are
% row vectors of size 1xnvars consisting of only 0s and 1s.
% PSOBINARY is provided as a wrapper for PSO, to avoid any confusion. This
% is because the binary optimization scheme is not designed to take any
% constraints, and PSOBINARY does not allow the passing of constraints. It
% takes a given optimization problem with binary variables, and
% automatically sets the options structure so that 'PopulationType'
% is 'bitstring'.
% This has exactly the same effect as setting the appropriate options
% manually for PSO, except that it is not possible to unintentionally
% define constraints, which would be ignored by the binary variable
% optimizer anyway.
% Problems with hybrid variables (double-precision and bit-string
% combined) cannot be solved yet.
% The output variables for PSOBINARY are the same as for PSO.
% See also:
% PSO, PSOOPTIMSET, PSODEMO
if nargin < 2
error('PSOBINARY requires at least two input arguments.')
elseif ~exist('options','var') % Set default options
options = struct ;
end % if ~exist
options = psooptimset(options,'PopulationType','bitstring') ;
[xOpt,fval,exitflag,output,population,scores] = ...