Merge lp:~philsf/mmrrsim/fix-lp-1260122 into lp:mmrrsim

Proposed by Felipe Figueiredo
Status: Merged
Merged at revision: 236
Proposed branch: lp:~philsf/mmrrsim/fix-lp-1260122
Merge into: lp:mmrrsim
Diff against target: 115 lines (+47/-41)
2 files modified
ChangeLog (+4/-0)
lib/MMRRSim.pm (+43/-41)
To merge this branch: bzr merge lp:~philsf/mmrrsim/fix-lp-1260122
Reviewer Review Type Date Requested Status
Felipe Figueiredo Pending
Review via email: mp+198856@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2013-12-11 23:32:10 +0000
+++ ChangeLog 2013-12-13 01:30:33 +0000
@@ -1,3 +1,7 @@
12013-12-12 Felipe Figueiredo <philsf79@gmail.com>
2
3 * lib/MMRRSim.pm (create_population): Fix bug LP:1260122.
4
12013-12-11 Felipe Figueiredo <philsf79@gmail.com>52013-12-11 Felipe Figueiredo <philsf79@gmail.com>
26
3 * lib/MMRRSim/GridCell.pm: Grid is now a rectangle instead of a7 * lib/MMRRSim/GridCell.pm: Grid is now a rectangle instead of a
48
=== modified file 'lib/MMRRSim.pm'
--- lib/MMRRSim.pm 2013-12-11 23:33:49 +0000
+++ lib/MMRRSim.pm 2013-12-13 01:30:33 +0000
@@ -130,56 +130,58 @@
130## Determine size of population130## Determine size of population
131 my $pop_size = $self->pop_size_u + $self->pop_size_m;131 my $pop_size = $self->pop_size_u + $self->pop_size_m;
132132
133
134## Retrieve individual attributes from config object and store them in
135## single a hash
136 my %individual_attributes;
137 for my $attr ( qw( longevity survival autonomy flight_mode act_prop delta_flight ) ) {
138 my $att_value = $self->config->params->{$attr};
139 if ($att_value) {
140 $individual_attributes{$attr} = $att_value;
141 }
142 }
143
144## Loops for the whold population, and use $_ as the individual name
133 for (1..$pop_size) {145 for (1..$pop_size) {
134## Set initial coordinates for everyone (if there's a release point146
135## for marked individuals, its coords will overwrite this)147## Set initial random coordinates for every individual. If there's a
148## release point for marked individuals, its coords will overwrite
149## this
136 my @coordinates = $self->random_coordinates();150 my @coordinates = $self->random_coordinates();
137151 $individual_attributes{coordinates} = \@coordinates;
138## Create random Activity Center152## Set random Activity Center
139 my @act_center = $self->random_coordinates();153 my @act_center = $self->random_coordinates();
140154 $individual_attributes{act_center} = \@act_center;
141## FIXME: the following code was made with the pork programming155
142## method. Try to make both cases in one block156 if ($_ <= $self->pop_size_u ) { # unmarked individuals
143 if ($_ <= $self->pop_size_u ) {157
144##Creates unmarked population158## Sets unmarked individuals attributes
145 $population{$_} = MMRRSim::Mosquito->new('name' => $_,159 $individual_attributes{mark} = 0;
146 coordinates => \@coordinates,160 $individual_attributes{survival}=1;
147 act_center => \@act_center,161
148 mark => 0,162 } else { # marked individuals
149 survival => 1,163
150 );164## Sets marked individuals attributes
151## Set parameters from config file, if applicable165 $individual_attributes{mark} = 1;
152 for my $attr ( qw( longevity autonomy flight_mode act_prop delta_flight ) ) {166
153 my $att_value = $self->config->params->{$attr};167## Sets initial coordinates, if a release point is given
154 if ($att_value) {
155 $population{$_}->$attr($att_value);
156 }
157 }
158## FIXME: be serious and don't copy/paste the same block in two places
159 } else {
160## Set initial coordinates
161 if ( @{$self->release_p}) {168 if ( @{$self->release_p}) {
162 @coordinates = @{$self->release_p};169 @coordinates = @{$self->release_p};
163 }170 }
171 $individual_attributes{coordinates} = \@coordinates;
172
173## Sets activity center, if at least one is given
164 if ( @{$self->a_centers}) {174 if ( @{$self->a_centers}) {
165 @act_center = $self->pick_activity_centers();175 @act_center = $self->pick_activity_centers();
166 }176 }
167177 $individual_attributes{act_center} = \@act_center;
168##Creates marked population178
179 }
180
181## Create the individual
169 $population{$_} = MMRRSim::Mosquito->new('name' => $_,182 $population{$_} = MMRRSim::Mosquito->new('name' => $_,
170 coordinates => \@coordinates,183 %individual_attributes,
171 act_center => \@act_center,
172 mark => 1,
173 );184 );
174## Set parameters from config file, if applicable
175 for my $attr ( qw( longevity survival autonomy flight_mode act_prop delta_flight ) ) {
176 my $att_value = $self->config->params->{$attr};
177 if ($att_value) {
178 $population{$_}->$attr($att_value);
179 }
180 }
181## FIXME: be serious and don't copy/paste the same block in two places
182 }
183 }185 }
184186
185## Set last seen name to pop size, to make sure the next mosquito187## Set last seen name to pop size, to make sure the next mosquito

Subscribers

People subscribed via source and target branches