-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use host pool and action objects to manage data and operations #184
Conversation
This is meant for pseudo code only for now, but I'm keeping it with the other code.
10456e2
to
e4c6e53
Compare
fc5234e
to
235c213
Compare
235c213
to
28cbfb6
Compare
… explicit total host, resistant, and suitable cells in host pool, so suitable cells needs to be non-const now in all functions
…used variables from host movement
… but determines that (or when) it should happen.
…t is computed in that context
… needed, i.e., weather is disabled but the function still requires that to be a parameter (usage of empty env is currently undefined behavior)
…witch to environment so that the caller does not need to care about weather being enabled or if the multiplication is the right thing to do.
Also changes order of exposed and infected in the parameters. Keeps old one parameter version of disperse (as a wrapper) for tests.
…ate parameter to be associated with class, not method), use using for host class template instantiation
…hich is only what environment needs. This greatly simplifies the code and removes the cyclic dependency between env iface and host iface.
For the record: Alternative idea with mortality in the actionMy initial idea was to do mortality in the action to keep the special action to the action object, but I ended up implementing mortality in the host pool object and here, just call the right method because mortality behavior is linked to the host. Eventually, even mortality_rate and mortality_time_lag may end up in the host for multi-host because they are linked to the to the host. class Mortality
{
void action(Hosts host)
{
for (const auto& [i, j] : hosts.suitable_cells) {
for (host in hosts) {
for (item in hosts.mortality_at(i, j)) {
if (index == 0)
mortality = item;
else
mortality = mortality_rate * item;
list.push_back(mortality);
}
hosts.kill_at(i, j, mortality);
}
}
}
}; |
…here in host pool for specific row and col instead of i, j
… the same and the results are the same)
…maybe, it can be enabled)
…e error message (needs to remain disabled).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have skimmed over most of the code and read the actions, pest and host pool more closely. It looks good and passes all tests in rpops.
Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
Old code design:
New code design:
Code:
Compatibility:
Last phase pieces:
completely_remove_*
methods into one.The results from tests for core and for r.pops.spread are identical with the new code.
For now, this includes also the original pseudo code for host object and actions.
Note: The separate seeds and generators PR (#192) required a lot of changes, so the merge was not trivial.