Home > src > randPopulationCandidateSelection.m

randPopulationCandidateSelection

PURPOSE ^

- random population selection method for selecting swaps

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 - random population selection method for selecting swaps

 copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut

    This file is part of SOS

    SOS is free software: you can redistribute it and/or modify
    it for academic and non-commercial purposes
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.  For commercial or for-profit
    uses, please contact the authors (sos@cnbc.cmu.edu).

    SOS is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % - random population selection method for selecting swaps
0002 %
0003 % copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut
0004 %
0005 %    This file is part of SOS
0006 %
0007 %    SOS is free software: you can redistribute it and/or modify
0008 %    it for academic and non-commercial purposes
0009 %    under the terms of the GNU General Public License as published by
0010 %    the Free Software Foundation, either version 3 of the License, or
0011 %    (at your option) any later version.  For commercial or for-profit
0012 %    uses, please contact the authors (sos@cnbc.cmu.edu).
0013 %
0014 %    SOS is distributed in the hope that it will be useful,
0015 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017 %    GNU General Public License for more details.
0018 
0019 %    You should have received a copy of the GNU General Public License
0020 %    along with SOS (see COPYING.txt).
0021 %    If not, see <http://www.gnu.org/licenses/>.
0022 
0023 
0024 
0025 classdef randPopulationCandidateSelection < genericFeederCandidateSelection
0026     %% Randomly selects an item from the targetSample's population to swap into the sample.
0027     %
0028     % This particular obj does not need to be implemented in OO style, but
0029     % it has been done for consistency with the rest of the implementation
0030     %
0031     %METHODS:
0032     % randPopulationCandidateSelection()  % Constructor
0033     % init() %Not needed for this class; no functional role in object
0034     %[feederdf,feederdfIndex] = getCandidateIndex(obj,sample)  % returns a dataframe and row index for a swap candidate
0035     
0036     
0037     properties
0038     end
0039     
0040     methods
0041         
0042         %% randPopulationCandidateSelection() CONSTRUCTOR
0043         function obj = randPopulationCandidateSelection()
0044             % Constructor
0045             
0046             obj.init();
0047             
0048             verbosePrint('Random Population Candidate Feeder Selection Ready', ...
0049                 'randPopulationCandidateSelection_const');
0050         end
0051         
0052         %% init() Method
0053         function init(obj)
0054             %Not needed for this class; no functional role in object
0055         end
0056         
0057         %% [feederdf,feederdfIndex] = getCandidateIndex(obj,sample) METHOD
0058         function [feederdf,feederdfIndex] = getCandidateIndex(obj,sample) 
0059             % returns a dataframe and row index for a swap candidate
0060             %
0061             %PARAMETERS:
0062             %   sample - the target sample to swap into
0063             %
0064             % RETURNS:
0065             % feederdf - the feeder dataframe
0066             % feederdfIndex -row index of item in feederdf
0067             
0068             feederdf = sample.population;
0069             feederdfIndex = floor((length(sample.population.data{1})*rand)+1);
0070         end
0071 
0072     end
0073 end

Generated on Fri 27-Jan-2012 16:18:41 by m2html © 2005