Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1515 +/- ##
=======================================
Coverage 97.38% 97.38%
=======================================
Files 188 188
Lines 16621 16621
=======================================
Hits 16186 16186
Misses 435 435 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
DavidKerkmann
left a comment
There was a problem hiding this comment.
There are a couple of generalized questions that we need to tackle now that we are bringing python bindings to the simulation level.
| template <class T> | ||
| concept HasSampleFunction = requires(T t) { | ||
| { t.get_sample(std::declval<RandomNumberGenerator&>()) } -> std::convertible_to<ScalarType>; | ||
| { t.get_sample(std::declval<abm::PersonalRandomNumberGenerator&>()) } -> std::convertible_to<ScalarType>; |
There was a problem hiding this comment.
The abstract parameter disctribution is in utils/ and should remain model-independent. An abm::PersonalRandomNumberGenerator is only known when there is knowledge about the ABM..
Is this required at this point? Requiring an abm::PRNG makes this unusable for other models.
| model.parameters.AgeGroupGotoSchool[AgeGroup(age_group)] = False | ||
| model.parameters.AgeGroupGotoWork[AgeGroup(age_group)] = False |
There was a problem hiding this comment.
As the default is false, these line could be removed, unless you have an intention to explicitly write them down.
| for age in range(num_age_groups): | ||
| model.parameters.InfectionProtectionFactor[abm.ProtectionType.GenericVaccine, AgeGroup( | ||
| age), abm.VirusVariant.Wildtype] = mio.TimeSeriesFunctor( | ||
| [[0, 0.0], [14, 0.67], [180, 0.4]]) | ||
|
|
||
| model.parameters.SeverityProtectionFactor[abm.ProtectionType.GenericVaccine, AgeGroup( | ||
| age), abm.VirusVariant.Wildtype] = mio.TimeSeriesFunctor( | ||
| [[0, 0.0], [14, 0.85], [180, 0.7]]) |
There was a problem hiding this comment.
This part is not in the .cpp file. We should probably stay as close as possible to the .cpp example. If we want to add this, then we should also add it in the .cpp example.
| # Seed infections | ||
|
|
||
| infection_distribution = [0.5, 0.3, 0.05, 0.05, 0.05, 0.05, 0.0, 0.0] | ||
| rng = np.random.default_rng() |
There was a problem hiding this comment.
With the availability of the MEmilio RNG / Personal RNG we should use that one here instead of the numpy rng. The discrete distribution would be suitable.
| .def_property_readonly("is_in_quarantine", &mio::abm::Person::is_in_quarantine); | ||
| .def_property_readonly("is_in_quarantine", &mio::abm::Person::is_in_quarantine) | ||
| .def_property_readonly("id", &mio::abm::Person::get_id) | ||
| .def("add_new_infection", |
There was a problem hiding this comment.
I see that this looked different at some point. Normally, as far as I can tell, we always bind the functions 1:1, meaning that we use the same arguments as in the cpp code. Here, the model is passed instead of the rng, and then the function itself creates the PRNG. However, then we could go a step further and also remove the age for example, as it could also be inferred directly from the person.
In general, we should decide how we want to go about these things. In a way, we lose flexibility if the user intends to use a different rng for some reason here. However, I think it also simplifies the use and perhaps we could bind functions for easier use in general.
| .def( | ||
| "advance", | ||
| [](mio::abm::Simulation<>& sim, mio::abm::TimePoint tmax) { | ||
| sim.advance(tmax); | ||
| }, | ||
| py::arg("tmax")) | ||
| .def( | ||
| "advance", | ||
| [](mio::abm::Simulation<>& sim, mio::abm::TimePoint tmax, | ||
| mio::History<mio::abm::TimeSeriesWriter, mio::abm::LogInfectionState>& history) { | ||
| sim.advance(tmax, history); | ||
| }, | ||
| py::arg("tmax"), py::arg("history")) |
There was a problem hiding this comment.
This only allows for two specific advance calls. A general functionality with any history object would be preferred (in conjuction with the binding of the History).
| { | ||
| bind_class<mio::AbstractParameterDistribution, EnablePickling::Never>(m, name.c_str()) | ||
| .def(py::init<>()) | ||
| .def(py::init<mio::ParameterDistributionLogNormal>(), py::arg("dist")) |
There was a problem hiding this comment.
This should be generic for any distribution (see templated definition).
Changes and Information
Please briefly list the changes (main added features, changed items, or corrected bugs) made:
Merge Request - Guideline Checklist
Please check our git workflow. Use the draft feature if the Pull Request is not yet ready to review.
Checks by code author
Checks by code reviewer(s)
Closes #1503