replace_chromosome.html ( File view )

  • By moeah 2014-04-18
  • View(s):30
  • Download(s):1
  • Point(s): 1
			<html xmlns:mwsh="">
      <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 f  = replace_chromosome(intermediate_chromosome,pro,pop)</title>
      <meta name="generator" content="MATLAB 7.0">
      <meta name="date" content="2006-03-16">
      <meta name="m-file" content="replace_chromosome"><style>
body {

  background-color: white;

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" );


      <h1>function f  = replace_chromosome(intermediate_chromosome,pro,pop)</h1>
      <p>This function replaces the chromosomes based on rank and crowding distance. Initially until the population size is reached
         each front is added one by one until addition of a complete front which results in exceeding the population size. At this
         point the chromosomes in that front is added subsequently to the population based on crowding distance.
      </p><pre class="codeinput">[N, m] = size(intermediate_chromosome);

<span class="comment">% Get the index for the population sort based on the rank</span>
[temp,index] = sort(intermediate_chromosome(:,M + V + 1));

clear <span class="string">temp</span> <span class="string">m</span>

<span class="comment">% Now sort the individuals based on the index</span>
<span class="keyword">for</span> i = 1 : N
    sorted_chromosome(i,:) = intermediate_chromosome(index(i),:);
<span class="keyword">end</span>

<span class="comment">% Find the maximum rank in the current population</span>
max_rank = max(intermediate_chromosome(:,M + V + 1));

<span class="comment">% Start adding each front based on rank and crowing distance until the</span>
<span class="comment">% whole population is filled.</span>
previous_index = 0;
<span class="keyword">for</span> i = 1 : max_rank
    <span class="comment">% Get the index for current rank i.e the last the last element in the</span>
    <span class="comment">% sorted_chromosome with rank i.</span>
    current_index = max(find(sorted_chromosome(:,M + V + 1) == i));
    <span class="comment">% Check to see if the population is filled if all the individuals with</span>
    <span class="comment">% rank i is added to the population.</span>
    <span class="keyword">if</span> current_index &gt; pop
        <span class="comment">% If so then find the number of individuals with in with current</span>
        <span class="comment">% rank i.</span>
        remaining = pop - previous_index;
        <span class="comment">% Get information about the individuals in the current rank i.</span>
        temp_pop = <span class="keyword">...</span>
            sorted_chromosome(previous_index + 1 : current_index, :);
        <span class="comment">% Sort the individuals with rank i in the descending order based on</span>
        <span class="comment">% the crowding distance.</span>
        [temp_sort,temp_sort_index] = <span class="keyword">...</span>
            sort(temp_pop(:, M + V + 2),<span class="string">'descend'</span>);
        <span class="comment">% Start filling individuals into the population in descending order</span>
        <span class="comment">% until the population is filled.</span>
        <span class="keyword">for</span> j = 1 : remaining
            f(previous_index + j,:) = temp_pop(temp_sort_index(j),:);
        <span class="keyword">end</span>
        <span class="keyword">return</span>;
    <span class="keyword">elseif</span> current_index &lt; pop
        <span class="comment">% Add all the individuals with rank i into the population.</span>
        f(previous_index + 1 : current_index, :) = <span class="keyword">...</span>
            sorted_chromosome(previous_index + 1 : current_index, :);
    <span class="keyword">else</span>
        <span class="comment">% Add all the individuals with rank i into the population.</span>
        f(previous_index + 1 : current_index, :) = <span class="keyword">...</span>
            sorted_chromosome(previous_index + 1 : current_index, :);
        <span class="keyword">return</span>;
    <span class="keyword">end</span>
    <span class="comment">% Get the index for the last added individual.</span>
    previous_index = current_index;
<span class="keyword">end</span>
</pre><p class="footer"><br>
         Published with MATLAB&reg; 7.0<br></p>
(Please download the complete source code to view)
Expand> <Close

Want complete source code? Download it here

Point(s): 1

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

replace_chromosome.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


Don't have an account? Register now
Need any help?
Mail to:


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!

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D