Congratulations on the groups 250th commit.

1 view
Skip to first unread message

Tim Sigler

unread,
Jun 20, 2011, 1:09:37 AM6/20/11
to sit-bmela...@googlegroups.com, sit-bmela...@googlegroups.com
Congradulations to everyone on the great work we've done so far.  As of today, we have made a total of 250 revisions of varying importances and sizes to the SVN repository, and with the PDF's due Monday, 6/20/11 at 5 PM the initial phases of the work on Inara and the general project are coming to completion.

There's still plenty of work to be done, but you should all be quite proud of the successes we've had so far.  More to come of this after PDF's are handed in. 

On Mon, Jun 20, 2011 at 12:54 AM, <sit-bmela...@googlecode.com> wrote:
Revision: 250
Author:   EN.WP...@gmail.com
Date:     Sun Jun 19 21:54:15 2011
Log:      Whitespace and a few minor things, such as not using a coderef as a float.
http://code.google.com/p/sit-bmelab-labview/source/detail?r=250

Modified:
 /trunk/EANN/ANN/lib/AI/ANN/Evolver.pm

=======================================
--- /trunk/EANN/ANN/lib/AI/ANN/Evolver.pm       Mon Jun 13 19:34:16 2011
+++ /trunk/EANN/ANN/lib/AI/ANN/Evolver.pm       Sun Jun 19 21:54:15 2011
@@ -184,124 +184,124 @@
 =cut

 sub mutate {
-       my $self = shift;
-       my $network = shift;
-       my $class = ref($network);
-       my $networkdata = $network->get_internals();
-       my $inputcount = $network->input_count();
-       my $minvalue = $network->minvalue();
-       my $maxvalue = $network->maxvalue();
-       my $afunc = $network->afunc();
-       my $dafunc = $network->dafunc();
-       my $neuroncount = $#{$networkdata}; # BTW did you notice that this
-                                                                               # isn't what it says it is?
-       $networkdata = dclone($networkdata); # For safety.
-       for (my $i = 0; $i <= $neuroncount; $i++) {
-               # First each input/neuron pair
-               for (my $j = 0; $j < $inputcount; $j++) {
-                       my $weight = $networkdata->[$i]->{'inputs'}->[$j];
-                       if (defined $weight && $weight != 0) {
-                               if (rand() < $self->{'mutation_chance'}) {
-                                       $weight += &{$self->{'mutation_amount'}};
-                                       if ($weight > $self->{'max_value'}) {
-                                               $weight = $self->{'max_value'};
-                                       }
-                                       if ($weight < $self->{'min_value'}) {
-                                               $weight = $self->{'min_value'} + 0.000001;
-                                       }
-                               }
-                               if (abs($weight) < $self->{'mutation_threshold'}) {
-                                       if (rand() < $self->{'kill_link_chance'}) {
-                                               $weight = undef;
-                                       }
-                               }
-                       } else {
-                               if (rand() < $self->{'add_link_chance'}) {
-                                       $weight = &{$self->{'mutation_amount'}};
-                                       # We want to Do The Right Thing. Here, that means to
-                                       # detect whether the user is using weights in (0, x), and
-                                       # if so make sure we don't accidentally give them a
-                                       # negative weight, because that will become 0.000001.
-                                       # Instead, we'll generate a positive only value at first
-                                       # (it's easier) and then, if the user will accept negative
-                                       # weights, we'll let that happen.
-                                       if ($self->{'min_value'} < 0) {
-                                               ($weight *= 2) -= $self->{'mutation_threshold'};
-                                       }
-                                       # Of course, we have to check to be sure...
-                                       if ($weight > $self->{'max_value'}) {
-                                               $weight = $self->{'max_value'};
-                                       }
-                                       if ($weight < $self->{'min_value'}) {
-                                               $weight = $self->{'min_value'} + 0.000001;
-                                       }
-                                       # But we /don't/ need to to a kill_link_chance just yet.
-                               }
-                       }
-                       # This would be a bloody nightmare if we hadn't done that dclone
-                       # magic before. But look how easy it is!
-                       $networkdata->[$i]->{'inputs'}->[$j] = $weight;
-               }
-               # Now each neuron/neuron pair
-               for (my $j = 0; $j <= $neuroncount; $j++) {
-               # As a reminder to those cursed with the duty of maintaining this code:
-               # This should be an exact copy of the code above, except that 'inputs'
-               # would be replaced with 'neurons'.
-                       my $weight = $networkdata->[$i]->{'neurons'}->[$j];
-                       if (defined $weight && $weight != 0) {
-                               if (rand() < $self->{'mutation_chance'}) {
-                                       $weight += &{$self->{'mutation_amount'}};
-                                       if ($weight > $self->{'max_value'}) {
-                                               $weight = $self->{'max_value'};
-                                       }
-                                       if ($weight < $self->{'min_value'}) {
-                                               $weight = $self->{'min_value'} + 0.000001;
-                                       }
-                               }
-                               if (abs($weight) < $self->{'mutation_threshold'}) {
-                                       if (rand() < $self->{'kill_link_chance'}) {
-                                               $weight = undef;
-                                       }
-                               }
-
-                       } else {
-                               if (rand() < $self->{'add_link_chance'}) {
-                                       $weight = &{$self->{'mutation_amount'}};
-                                       # We want to Do The Right Thing. Here, that means to
-                                       # detect whether the user is using weights in (0, x), and
-                                       # if so make sure we don't accidentally give them a
-                                       # negative weight, because that will become 0.000001.
-                                       # Instead, we'll generate a positive only value at first
-                                       # (it's easier) and then, if the user will accept negative
-                                       # weights, we'll let that happen.
-                                       if ($self->{'min_value'} < 0) {
-                                               ($weight *= 2) -= $self->{'mutation_threshold'};
-                                       }
-                                       # Of course, we have to check to be sure...
-                                       if ($weight > $self->{'max_value'}) {
-                                               $weight = $self->{'max_value'};
-                                       }
-                                       if ($weight < $self->{'min_value'}) {
-                                               $weight = $self->{'min_value'} + 0.000001;
-                                       }
-                                       # But we /don't/ need to to a kill_link_chance just yet.
-                               }
-                       }
-                       # This would be a bloody nightmare if we hadn't done that dclone
-                       # magic before. But look how easy it is!
-                       $networkdata->[$i]->{'neurons'}->[$j] = $weight;
-               }
-               # That was rather tiring, and that's only for the first neuron!!
-       }
-       # All done. Let's pack it back into an object and let someone else deal
-       # with it.
-       $network = $class->new ( 'inputs' => $inputcount,
-                                                        'data' => $networkdata,
-                                                        'minvalue' => $minvalue,
-                                                        'maxvalue' => $maxvalue,
-                                                        'afunc' => $afunc,
-                                                        'dafunc' => $dafunc);
-       return $network;
+    my $self = shift;
+    my $network = shift;
+    my $class = ref($network);
+    my $networkdata = $network->get_internals();
+    my $inputcount = $network->input_count();
+    my $minvalue = $network->minvalue();
+    my $maxvalue = $network->maxvalue();
+    my $afunc = $network->afunc();
+    my $dafunc = $network->dafunc();
+    my $neuroncount = $#{$networkdata}; # BTW did you notice that this
+                                        # isn't what it says it is?
+    $networkdata = dclone($networkdata); # For safety.
+    for (my $i = 0; $i <= $neuroncount; $i++) {
+        # First each input/neuron pair
+        for (my $j = 0; $j < $inputcount; $j++) {
+            my $weight = $networkdata->[$i]->{'inputs'}->[$j];
+            if (defined $weight && $weight != 0) {
+                if (rand() < $self->{'mutation_chance'}) {
+                    $weight += &{$self->{'mutation_amount'}};
+                    if ($weight > $self->{'max_value'}) {
+                        $weight = $self->{'max_value'};
+                    }
+                    if ($weight < $self->{'min_value'}) {
+                        $weight = $self->{'min_value'} + 0.000001;
+                    }
+                }
+                if (abs($weight) < $self->{'mutation_threshold'}) {
+                    if (rand() < $self->{'kill_link_chance'}) {
+                        $weight = undef;
+                    }
+                }
+            } else {
+                if (rand() < $self->{'add_link_chance'}) {
+                    $weight = &{$self->{'mutation_amount'}};
+                    # We want to Do The Right Thing. Here, that means to
+                    # detect whether the user is using weights in (0, x), and
+                    # if so make sure we don't accidentally give them a
+                    # negative weight, because that will become 0.000001.
+                    # Instead, we'll generate a positive only value at first
+                    # (it's easier) and then, if the user will accept negative
+                    # weights, we'll let that happen.
+                    if ($self->{'min_value'} < 0) {
+                        ($weight *= 2) -= $self->{'mutation_threshold'};
+                    }
+                    # Of course, we have to check to be sure...
+                    if ($weight > $self->{'max_value'}) {
+                        $weight = $self->{'max_value'};
+                    }
+                    if ($weight < $self->{'min_value'}) {
+                        $weight = $self->{'min_value'} + 0.000001;
+                    }
+                    # But we /don't/ need to do a kill_link_chance just yet.
+                }
+            }
+            # This would be a bloody nightmare if we hadn't done that dclone
+            # magic before. But look how easy it is!
+            $networkdata->[$i]->{'inputs'}->[$j] = $weight;
+        }
+        # Now each neuron/neuron pair
+        for (my $j = 0; $j <= $neuroncount; $j++) {
+        # As a reminder to those cursed with the duty of maintaining this code:
+        # This should be an exact copy of the code above, except that 'inputs'
+        # would be replaced with 'neurons'.
+            my $weight = $networkdata->[$i]->{'neurons'}->[$j];
+            if (defined $weight && $weight != 0) {
+                if (rand() < $self->{'mutation_chance'}) {
+                    $weight += &{$self->{'mutation_amount'}};
+                    if ($weight > $self->{'max_value'}) {
+                        $weight = $self->{'max_value'};
+                    }
+                    if ($weight < $self->{'min_value'}) {
+                        $weight = $self->{'min_value'} + 0.000001;
+                    }
+                }
+                if (abs($weight) < $self->{'mutation_threshold'}) {
+                    if (rand() < $self->{'kill_link_chance'}) {
+                        $weight = undef;
+                    }
+                }
+
+            } else {
+                if (rand() < $self->{'add_link_chance'}) {
+                    $weight = &{$self->{'mutation_amount'}};
+                    # We want to Do The Right Thing. Here, that means to
+                    # detect whether the user is using weights in (0, x), and
+                    # if so make sure we don't accidentally give them a
+                    # negative weight, because that will become 0.000001.
+                    # Instead, we'll generate a positive only value at first
+                    # (it's easier) and then, if the user will accept negative
+                    # weights, we'll let that happen.
+                    if ($self->{'min_value'} < 0) {
+                        ($weight *= 2) -= $self->{'mutation_threshold'};
+                    }
+                    # Of course, we have to check to be sure...
+                    if ($weight > $self->{'max_value'}) {
+                        $weight = $self->{'max_value'};
+                    }
+                    if ($weight < $self->{'min_value'}) {
+                        $weight = $self->{'min_value'} + 0.000001;
+                    }
+                    # But we /don't/ need to to a kill_link_chance just yet.
+                }
+            }
+            # This would be a bloody nightmare if we hadn't done that dclone
+            # magic before. But look how easy it is!
+            $networkdata->[$i]->{'neurons'}->[$j] = $weight;
+        }
+        # That was rather tiring, and that's only for the first neuron!!
+    }
+    # All done. Let's pack it back into an object and let someone else deal
+    # with it.
+    $network = $class->new ( 'inputs' => $inputcount,
+                             'data' => $networkdata,
+                             'minvalue' => $minvalue,
+                             'maxvalue' => $maxvalue,
+                             'afunc' => $afunc,
+                             'dafunc' => $dafunc);
+    return $network;
 }

 =method mutate_gaussian
@@ -320,24 +320,24 @@
 sub mutate_gaussian {
    my $self = shift;
    my $network = shift;
-       my $class = ref($network);
-       my $networkdata = $network->get_internals();
-       my $inputcount = $network->input_count();
-       my $minvalue = $network->minvalue();
-       my $maxvalue = $network->maxvalue();
-       my $afunc = $network->afunc();
-       my $dafunc = $network->dafunc();
-       my $neuroncount = $#{$networkdata}; # BTW did you notice that this
-                                                                               # isn't what it says it is?
-       $networkdata = dclone($networkdata); # For safety.
-       for (my $i = 0; $i <= $neuroncount; $i++) {
+    my $class = ref($network);
+    my $networkdata = $network->get_internals();
+    my $inputcount = $network->input_count();
+    my $minvalue = $network->minvalue();
+    my $maxvalue = $network->maxvalue();
+    my $afunc = $network->afunc();
+    my $dafunc = $network->dafunc();
+    my $neuroncount = $#{$networkdata}; # BTW did you notice that this
+                                        # isn't what it says it is?
+    $networkdata = dclone($networkdata); # For safety.
+    for (my $i = 0; $i <= $neuroncount; $i++) {
        my $n = 0;
        for (my $j = 0; $j < $inputcount; $j++) {
-                       my $weight = $networkdata->[$i]->{'inputs'}->[$j];
+            my $weight = $networkdata->[$i]->{'inputs'}->[$j];
            $n++ if $weight;
        }
        for (my $j = 0; $j <= $neuroncount; $j++) {
-                       my $weight = $networkdata->[$i]->{'neurons'}->[$j];
+            my $weight = $networkdata->[$i]->{'neurons'}->[$j];
            $n++ if $weight;
        }
        next if $n == 0;
@@ -345,29 +345,29 @@
        my $tau_prime = &{$self->{'gaussian_tau_prime'}}($n);
        my $random1 = 2 * rand() - 1;
        for (my $j = 0; $j < $inputcount; $j++) {
-                       my $weight = $networkdata->[$i]->{'inputs'}->[$j];
+            my $weight = $networkdata->[$i]->{'inputs'}->[$j];
            next unless $weight;
            my $random2 = 2 * rand() - 1;
-                       $networkdata->[$i]->{'eta_inputs'}->[$j] *= exp($tau_prime*$random1+$tau*$random2);
-                       $networkdata->[$i]->{'inputs'}->[$j] += $networkdata->[$i]->{'eta_inputs'}->[$j]*$random2;
+            $networkdata->[$i]->{'eta_inputs'}->[$j] *= exp($tau_prime*$random1+$tau*$random2);
+            $networkdata->[$i]->{'inputs'}->[$j] += $networkdata->[$i]->{'eta_inputs'}->[$j]*$random2;
        }
        for (my $j = 0; $j <= $neuroncount; $j++) {
-                       my $weight = $networkdata->[$i]->{'neurons'}->[$j];
+            my $weight = $networkdata->[$i]->{'neurons'}->[$j];
            next unless $weight;
            my $random2 = 2 * rand() - 1;
-                       $networkdata->[$i]->{'eta_neurons'}->[$j] *= exp($tau_prime*$random1+$tau*$random2);
-                       $networkdata->[$i]->{'neurons'}->[$j] += $networkdata->[$i]->{'eta_neurons'}->[$j]*$random2;
+            $networkdata->[$i]->{'eta_neurons'}->[$j] *= exp($tau_prime*$random1+$tau*$random2);
+            $networkdata->[$i]->{'neurons'}->[$j] += $networkdata->[$i]->{'eta_neurons'}->[$j]*$random2;
        }
    }
-       # All done. Let's pack it back into an object and let someone else deal
-       # with it.
-       $network = $class->new ( 'inputs' => $inputcount,
-                                                        'data' => $networkdata,
-                                                        'minvalue' => $minvalue,
-                                                        'maxvalue' => $maxvalue,
-                                                        'afunc' => $afunc,
-                                                        'dafunc' => $dafunc);
-       return $network;
+    # All done. Let's pack it back into an object and let someone else deal
+    # with it.
+    $network = $class->new ( 'inputs' => $inputcount,
+                             'data' => $networkdata,
+                             'minvalue' => $minvalue,
+                             'maxvalue' => $maxvalue,
+                             'afunc' => $afunc,
+                             'dafunc' => $dafunc);
+    return $network;
 }

 __PACKAGE__->meta->make_immutable;



--
~~~~T. Joseph Sigler
Stevens Institute of Technology, M.E. Electrical Engineering, 2011
Project Leader, Stevens BioRobotics Lab
Stevens Graduate Student Body President, 2011-2012

Reply all
Reply to author
Forward
0 new messages