tournament_selection.html ( File view )

  • By moeah 2014-04-18
  • View(s):30
  • Download(s):1
  • Point(s): 1
			<html xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   
      <!--
This HTML is auto-generated from an M-file.
To make changes, update the M-file and republish this document.
      -->
      <title>function tournament_selection(chromosome, pool_size, tour_size)</title>
      <meta name="generator" content="MATLAB 7.0">
      <meta name="date" content="2006-03-16">
      <meta name="m-file" content="tournament_selection"><style>
body {

  background-color: white;
  margin:10px;

}
h1 {

  color: #990000; 
  font-size: x-large;

}
h2 {

  color: #990000;
  font-size: medium;

}
p.footer {

  text-align: right;
  font-size: xx-small;
  font-weight: lighter;
  font-style: italic;
  color: gray;

}

pre.codeinput {

  margin-left: 30px;

}

span.keyword {
color: #0000FF
}
span.comment {
color: #228B22
}
span.string {
color: #A020F0
}
span.untermstring {
color: #B20000
}
span.syscmd {
color: #B28C00
}

pre.showbuttons {

  margin-left: 30px;
  border: solid black 2px;
  padding: 4px;
  background: #EBEFF3;

}

pre.codeoutput {

  color: gray;
  font-style: italic;

}
pre.error {

  color: red;

}

/* Make the text shrink to fit narrow windows, but not stretch too far in 
wide windows.  On Gecko-based browsers, the shrink-to-fit doesn't work. */ 
p,h1,h2,div {

  /* for MATLAB's browser */
  width: 600px;
  /* for Mozilla, but the "width" tag overrides it anyway */
  max-width: 600px;
  /* for IE */
  width:expression(document.body.clientWidth > 620 ? "600px": "auto" );

}

    </style></head>
   <body>
      <h1>function tournament_selection(chromosome, pool_size, tour_size)</h1>
      <introduction>
         <p>is the selection policy for selecting the individuals for the mating pool. The selection is based on tournament selection.
            Argument <tt>chromosome</tt> is the current generation population from which the individuals are selected to form a mating pool of size <tt>pool_size</tt> after performing tournament selection, with size of the tournament being <tt>tour_size</tt>. By varying the tournament size the selection pressure can be adjusted. But for NSGA-II the tour_size is fixed to two, but
            the user may feel free to experiment with different tournament size. Also it has been observed that a tournament size of more
            than five has no significant meaning.
         </p>
      </introduction>
      <h2>Contents</h2>
      <div>
         <ul>
            <li><a href="#1">Tournament selection process</a></li>
         </ul>
      </div>
      <h2>Tournament selection process<a name="1"></a></h2>
      <p>In a tournament selection process n individuals are selected at random, where n is equal to <tt>tour_size</tt>. From these individuals only one is selected and is added to the mating pool, where size of the mating pool is <tt>pool_size</tt>. Selection is performed based on two criteria. First and foremost is the rank or the front in which the solutions reside.
         Individuals with lower rank are selected. Secondly if the rank of two individuals are the same then, the crowding distance
         is compared. Individuals with greater crowding distance is selcted.
      </p><pre class="codeinput"><span class="comment">% Get the size of chromosome. The number of chromosome is not important</span>
<span class="comment">% while the number of elements in chromosome are important.</span>
[pop, variables] = size(chromosome);
<span class="comment">% The peunltimate element contains the information about rank.</span>
rank = variables - 1;
<span class="comment">% The last element contains information about crowding distance.</span>
distance = variables;

<span class="comment">% Until the mating pool is filled, perform tournament selection</span>
<span class="keyword">for</span> i = 1 : pool_size
    <span class="comment">% Select n individuals at random, where n = tour_size</span>
    <span class="keyword">for</span> j = 1 : tour_size
        <span class="comment">% Select an individual at random</span>
        candidate(j) = round(pop*rand(1));
        <span class="comment">% Make sure that the array starts from one.</span>
        <span class="keyword">if</span> candidate(j) == 0
            candidate(j) = 1;
        <span class="keyword">end</span>
        <span class="keyword">if</span> j &gt; 1
            <span class="comment">% Make sure that same candidate is not choosen.</span>
            <span class="keyword">while</span> ~isempty(find(candidate(1 : j - 1) == candidate(j)))
                candidate(j) = round(pop*rand(1));
                <span class="keyword">if</span> candidate(j) == 0
                    candidate(j) = 1;
                <span class="keyword">end</span>
            <span class="keyword">end</span>
        <span class="keyword">end</span>
    <span class="keyword">end</span>
    <span class="comment">% Collect information about the selected candidates.</span>
    <span class="keyword">for</span> j = 1 : tour_size
        c_obj_rank(j) = chromosome(candidate(j),rank);
        c_obj_distance(j) = chromosome(candidate(j),distance);
    <span class="keyword">end</span>
    <span class="comment">% Find the candidate with the least rank</span>
    min_candidate = <span class="keyword">...</span>
        find(c_obj_rank == min(c_obj_rank));
    <span class="comment">% If more than one candiate have the least rank then find the candidate</span>
    <span class="comment">% within that group having the maximum crowding distance.</span>
    <span class="keyword">if</span> length(min_candidate) ~= 1
        max_candidate = <span class="keyword">...</span>
        find(c_obj_distance(min_candidate) == max(c_obj_distance(min_candidate)));
        <span class="comment">% If a few individuals have the least rank and have maximum crowding</span>
        <span class="comment">% distance, select only one individual (not at random).</span>
        <span class="keyword">if</span> length(max_candidate) ~= 1
            max_candidate = max_candidate(1);
        <span class="keyword">end</span>
        <span class="comment">% Add the selected individual to the mating pool</span>
        f(i,:) = chromosome(candidate(min_candidate(max_candidate)),:);
    <span class="keyword">else</span>
        <span class="comment">% Add the selected individual to the mating pool</span>
        f(i,:) = chromosome(candidate(min_candidate(1)),:);
    <span class="keyword">end</span>
<span class="keyword">end</span>
</pre><p class="footer"><br>
         Published with MATLAB&reg; 7.0<br></p>
      <!--
##### SOURCE BEGIN #####


%% function tournament_selection(chromosome, pool_size, tour_size) 
% is the selection policy for selecting the individuals for the mating 
% pool. The selection is based on tournamen
...
...
(Please download the complete source code to view)
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
01.96 kB
01.96 kB
tournament_selection.html10.01 kB2006-03-16|16:37
replace_chromosome.html7.98 kB2006-03-16|16:38
objective_description_function.html6.25 kB2006-03-16|16:31
nsga_2.html20.78 kB2006-03-16|16:29
non_domination_sort_mod.html18.88 kB2006-03-16|16:35
initialize_variables.html6.42 kB2006-03-16|16:30
genetic_operator.html14.78 kB2006-03-16|16:30
evaluate_objective.html7.08 kB2006-03-16|16:28
NSGA131.01 kB2006-03-19|20:24
evaluate_objective.m2.16 kB2006-03-16|16:28
genetic_operator.m6.93 kB2009-07-16|10:08
initialize_variables.m3.34 kB2009-07-16|10:09
non_domination_sort_mod.m8.30 kB2009-07-16|10:09
nsga_2.m9.30 kB2009-07-16|10:09
objective_description_function.m3.52 kB2009-07-16|10:09
replace_chromosome.m4.02 kB2009-07-16|10:09
tournament_selection.m4.91 kB2009-07-16|10:09
license.txt1.31 kB2009-07-19|16:16
...
Sponsored links

tournament_selection.html (153.84 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D