1package Algorithm::Evolutionary::Op::LinearFreezer; 2 3use lib qw(../../..); 4 5use strict; 6use warnings; 7 8=head1 NAME 9 10Algorithm::Evolutionary::Op::LinearFreezer - Used by Simulated Annealing algorithms, reduces temperature lineally. 11 12=head1 SYNOPSIS 13 14 my $freezer = new Algorithm::Evolutionary::Op::LinearFreezer( $minTemp ); 15 16=head1 Base Class 17 18L<Algorithm::Evolutionary::Op::Base|Algorithm::Evolutionary::Op::Base> 19 20=head1 METHODS 21 22=cut 23 24 25 26our ($VERSION) = ( '$Revision: 3.1 $ ' =~ / (\d+\.\d+)/ ); 27 28use Carp; 29use base 'Algorithm::Evolutionary::Op::Base'; 30 31=head2 new ([ $initial_temperature = 0.2] ) 32 33Creates a new linear freezer. 34 35=cut 36 37sub new { 38 my $class = shift; 39 my $self = {}; 40 $self->{'_initTemp'} = shift || 0.2 ; 41 $self->{'_n'} = 0 ; 42 43 bless $self, $class; 44 return $self; 45} 46 47=head2 apply( $temperature ) 48 49Applies freezing schedule to the temperature; returns new temperature 50 51=cut 52 53sub apply ($$) { 54 my $self = shift; 55 my $t = shift; 56 57 $t = ($self->{'_initTemp'}) / ( 1 + $self->{_n} ) ; 58 $self->{'_n'}++ ; 59 60 return $t; 61} 62 63=head1 Copyright 64 65 This file is released under the GPL. See the LICENSE file included in this distribution, 66 or go to http://www.fsf.org/licenses/gpl.txt 67 68 CVS Info: $Date: 2012/07/08 10:38:52 $ 69 $Header: /media/Backup/Repos/opeal/opeal/Algorithm-Evolutionary/lib/Algorithm/Evolutionary/Op/LinearFreezer.pm,v 3.1 2012/07/08 10:38:52 jmerelo Exp $ 70 $Author: jmerelo $ 71 $Revision: 3.1 $ 72 $Name $ 73 74=cut 75