Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cats
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDC
cats
Commits
18dcdc70
Commit
18dcdc70
authored
1 year ago
by
Andreas Gattringer
Browse files
Options
Downloads
Patches
Plain Diff
butterflies: minor cleanups
parent
246e3e80
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/butterflies/butterflies_populations.c
+13
-15
13 additions, 15 deletions
src/modules/butterflies/butterflies_populations.c
with
13 additions
and
15 deletions
src/modules/butterflies/butterflies_populations.c
+
13
−
15
View file @
18dcdc70
...
...
@@ -18,16 +18,17 @@
int64_t
count_populated_cells
(
const
struct
cats_grid
*
grid
)
{
int64_t
cells
=
0
;
cats_dt_coord
rows
=
grid
->
dimension
.
rows
;
cats_dt_coord
cols
=
grid
->
dimension
.
cols
;
const
cats_dt_coord
rows
=
grid
->
dimension
.
rows
;
const
cats_dt_coord
cols
=
grid
->
dimension
.
cols
;
for
(
cats_dt_coord
row
=
0
;
row
<
rows
;
row
++
)
{
for
(
cats_dt_coord
col
=
0
;
col
<
cols
;
col
++
)
{
if
(
get_adult_population
(
grid
,
row
,
col
))
{
cells
+=
1
;
}
}
}
return
cells
;
}
...
...
@@ -35,22 +36,23 @@ int64_t count_populated_cells(const struct cats_grid *grid)
int64_t
butterflies_prune_invalid_cells
(
struct
cats_grid
*
grid
)
{
int64_t
invalid_habitat
=
0
;
int
module_id
=
CATS_MODULE_ID
;
struct
grid_data_butterflies
*
data
=
grid
->
grid_modules
[
module_id
].
module_data
;
cats_dt_coord
rows
=
grid
->
dimension
.
rows
;
cats_dt_coord
cols
=
grid
->
dimension
.
cols
;
const
int
module_id
=
CATS_MODULE_ID
;
const
struct
grid_data_butterflies
*
data
=
grid
->
grid_modules
[
module_id
].
module_data
;
const
cats_dt_coord
rows
=
grid
->
dimension
.
rows
;
const
cats_dt_coord
cols
=
grid
->
dimension
.
cols
;
for
(
cats_dt_coord
row
=
0
;
row
<
rows
;
row
++
)
{
for
(
cats_dt_coord
col
=
0
;
col
<
cols
;
col
++
)
{
if
(
!
(
data
->
info_layer
[
row
][
col
]
&
BF_CELL_VALID_DISPERSAL_TARGET
))
{
if
(
get_adult_population
(
grid
,
row
,
col
))
{
invalid_habitat
+=
1
;
}
set_population_ignore_cc
(
grid
,
row
,
col
,
0
);
}
}
}
return
invalid_habitat
;
}
...
...
@@ -83,12 +85,9 @@ void bf_cell_maturation(struct cats_grid *grid, struct cats_thread_info *ts, cat
}
// the number of generations per cell is usually not an integer value
// The number of generations per cell is usually not an integer value:
// the non-integer part of the number of generations is used in the generation which is
// one greater than the integer part of the number of generations
// one greater than the integer part of the number of generations
.
// i.e. if the number of generations is 2.4, 40% of all eggs in the cell
// will be considered as if they belonged to generation 3
// the minimum number of generations is 1 if the cell is climatically viable (and the host species is present)
...
...
@@ -117,7 +116,7 @@ void bf_cell_maturation(struct cats_grid *grid, struct cats_thread_info *ts, cat
assert
(
this_generation_fraction
<=
1
.
0
);
//cats_dt_population max_cc = (cats_dt_population) grid->param.carrying_capacity.max_rate;
float
eggs
=
this_generation_fraction
*
data
->
eggs
[
row
][
col
];
const
float
eggs
=
this_generation_fraction
*
data
->
eggs
[
row
][
col
];
#ifdef BF_DEBUG
printf
(
"BFDBG::%s::row %d, col %d: local gen %f gen fraction %f, eggs %f, this gen eggs %f
\n
"
,
__func__
,
row
,
col
,
local_generation
,
this_generation_fraction
,
data
->
eggs
[
row
][
col
],
eggs
);
...
...
@@ -133,7 +132,6 @@ void bf_cell_maturation(struct cats_grid *grid, struct cats_thread_info *ts, cat
data
->
eggs
[
row
][
col
]
-=
eggs
;
assert
(
data
->
eggs
[
row
][
col
]
>=
0
);
// not capped, we can have more adults than CC
cats_dt_environment
suit
=
get_suitability
(
grid
,
row
,
col
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment