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
cfb7e2a7
Commit
cfb7e2a7
authored
1 year ago
by
Andreas Gattringer
Browse files
Options
Downloads
Patches
Plain Diff
butterflies: fixed fractional generations
parent
37662ba1
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
+15
-10
15 additions, 10 deletions
src/modules/butterflies/butterflies_populations.c
with
15 additions
and
10 deletions
src/modules/butterflies/butterflies_populations.c
+
15
−
10
View file @
cfb7e2a7
...
@@ -39,13 +39,12 @@ void bf_cell_maturation(struct cats_grid *grid, struct cats_thread_info *ts, cat
...
@@ -39,13 +39,12 @@ void bf_cell_maturation(struct cats_grid *grid, struct cats_thread_info *ts, cat
struct
grid_data_butterflies
*
data
=
grid
->
grid_modules
[
module_id
].
module_data
;
struct
grid_data_butterflies
*
data
=
grid
->
grid_modules
[
module_id
].
module_data
;
if
(
data
->
eggs
[
row
][
col
]
==
0
)
return
;
if
(
data
->
eggs
[
row
][
col
]
==
0
)
return
;
if
(
data
->
eggs
[
row
][
col
]
<
0
)
{
if
(
data
->
eggs
[
row
][
col
]
<
0
)
{
log_message
(
LOG_ERROR
,
"Number of eggs < 0: row %d col %d: %f"
,
row
,
col
,
data
->
eggs
[
row
][
col
]);
log_message
(
LOG_ERROR
,
"Number of eggs < 0: row %d col %d: %f"
,
row
,
col
,
data
->
eggs
[
row
][
col
]);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
//int orig_eggs = data->eggs[row][col];
// 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
// 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
...
@@ -60,16 +59,22 @@ void bf_cell_maturation(struct cats_grid *grid, struct cats_thread_info *ts, cat
...
@@ -60,16 +59,22 @@ void bf_cell_maturation(struct cats_grid *grid, struct cats_thread_info *ts, cat
// then all the cells with have at least 4 (> 3) generations are modelled
// then all the cells with have at least 4 (> 3) generations are modelled
// ...
// ...
// at last all cells with have at least 1 generation are modelled
// 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
this_generation_fraction
=
1
.
0
f
;
int32_t
local_max_generation
=
(
int32_t
)
ceilf
(
data
->
generations
[
row
][
col
]);
float
local_generation
=
data
->
generations
[
row
][
col
];
int32_t
local_max_generation
=
(
int32_t
)
ceilf
(
local_generation
);
if
(
data
->
generation_current
==
local_max_generation
)
{
float
current_generation_float
=
(
float
)
data
->
generation_current
;
this_generation_fraction
=
(
float
)
local_max_generation
-
data
->
generations
[
row
][
col
];
assert
(
this_generation_fraction
>=
0
);
if
(
current_generation_float
==
local_generation
assert
(
this_generation_fraction
<=
1
.
0
);
||
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
);
//cats_dt_population max_cc = (cats_dt_population) grid->param.carrying_capacity.max_rate;
//cats_dt_population max_cc = (cats_dt_population) grid->param.carrying_capacity.max_rate;
float
eggs
=
this_generation_fraction
*
data
->
eggs
[
row
][
col
];
float
eggs
=
this_generation_fraction
*
data
->
eggs
[
row
][
col
];
...
@@ -86,7 +91,7 @@ void bf_cell_maturation(struct cats_grid *grid, struct cats_thread_info *ts, cat
...
@@ -86,7 +91,7 @@ void bf_cell_maturation(struct cats_grid *grid, struct cats_thread_info *ts, cat
if
(
eggs
==
0
)
return
;
if
(
eggs
==
0
)
return
;
// not capped, we can have more adults than CC
// not capped, we can have more adults than CC
struct
conf_data_butterflies
*
module_conf
=
CATS_MODULE_DATA
;
cats_dt_environment
suit
=
get_suitability
(
grid
,
row
,
col
);
cats_dt_environment
suit
=
get_suitability
(
grid
,
row
,
col
);
cats_dt_rates
reproduction_rate
=
calculate_rate
(
&
module_conf
->
reproduction_rate
,
NAN
,
&
grid
->
param
,
cats_dt_rates
reproduction_rate
=
calculate_rate
(
&
module_conf
->
reproduction_rate
,
NAN
,
&
grid
->
param
,
grid
,
row
,
col
,
NULL
);
grid
,
row
,
col
,
NULL
);
...
...
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