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
355456ab
Commit
355456ab
authored
1 year ago
by
Andreas Gattringer
Browse files
Options
Downloads
Patches
Plain Diff
butterflies: fractional generation calculation in function
parent
1c056e1a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/butterflies/butterflies_populations.c
+31
-16
31 additions, 16 deletions
src/modules/butterflies/butterflies_populations.c
with
31 additions
and
16 deletions
src/modules/butterflies/butterflies_populations.c
+
31
−
16
View file @
355456ab
...
...
@@ -63,6 +63,35 @@ bf_egg_to_adult_survival_rate(cats_dt_rates reproduction_rate, cats_dt_rates egg
return
reproduction_rate
/
eggs
;
}
float
get_fractional_generation
(
struct
cats_grid
*
grid
,
cats_dt_coord
row
,
cats_dt_coord
col
)
{
struct
conf_data_butterflies
*
module_conf
=
CATS_MODULE_DATA
;
const
int
module_id
=
CATS_MODULE_ID
;
struct
grid_data_butterflies
*
data
=
grid
->
grid_modules
[
module_id
].
module_data
;
float
this_generation_fraction
=
1
.
0
f
;
float
local_generation
=
data
->
generations
[
row
][
col
];
int32_t
global_max_generation
=
module_conf
->
generations_max
;
int32_t
local_max_generation
=
(
int32_t
)
ceilf
(
local_generation
);
int32_t
global_current_generation
=
data
->
generation_current
;
float
current_generation_float
=
(
float
)
data
->
generation_current
;
if
(
global_current_generation
==
global_max_generation
)
{
this_generation_fraction
=
1
.
0
f
;
}
else
if
(
current_generation_float
==
local_generation
||
data
->
generation_current
==
module_conf
->
generations_min
)
{
this_generation_fraction
=
1
.
0
f
;
}
else
if
(
data
->
generation_current
==
local_max_generation
)
{
this_generation_fraction
=
(
float
)
local_max_generation
-
local_generation
;
}
assert
(
this_generation_fraction
>
0
);
assert
(
this_generation_fraction
<=
1
.
0
);
return
this_generation_fraction
;
}
void
bf_cell_maturation
(
struct
cats_grid
*
grid
,
struct
cats_thread_info
*
ts
,
cats_dt_coord
row
,
cats_dt_coord
col
,
bool
check_exclusion
)
...
...
@@ -100,24 +129,10 @@ void bf_cell_maturation(struct cats_grid *grid, struct cats_thread_info *ts, cat
// ...
// at last all cells with have at least 1 generation are modelled
struct
conf_data_butterflies
*
module_conf
=
CATS_MODULE_DATA
;
float
this_generation_fraction
=
1
.
0
f
;
float
local_generation
=
data
->
generations
[
row
][
col
];
int32_t
global_max_generation
=
module_conf
->
generations_max
;
int32_t
local_max_generation
=
(
int32_t
)
ceilf
(
local_generation
);
int32_t
global_current_generation
=
data
->
generation_current
;
float
current_generation_float
=
(
float
)
data
->
generation_current
;
if
(
global_current_generation
==
global_max_generation
)
{
this_generation_fraction
=
1
.
0
f
;
}
else
if
(
current_generation_float
==
local_generation
||
data
->
generation_current
==
module_conf
->
generations_min
)
{
this_generation_fraction
=
1
.
0
f
;
}
else
if
(
data
->
generation_current
==
local_max_generation
)
{
this_generation_fraction
=
(
float
)
local_max_generation
-
local_generation
;
}
float
this_generation_fraction
=
get_fractional_generation
(
grid
,
row
,
col
);
assert
(
this_generation_fraction
>
0
);
assert
(
this_generation_fraction
<=
1
.
0
);
//cats_dt_population max_cc = (cats_dt_population) grid->param.carrying_capacity.max_rate;
const
float
eggs
=
this_generation_fraction
*
data
->
eggs
[
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