-
Notifications
You must be signed in to change notification settings - Fork 16
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
1159 add diffusive abm and smm #1162
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1162 +/- ##
==========================================
+ Coverage 96.97% 97.01% +0.03%
==========================================
Files 148 154 +6
Lines 13718 13928 +210
==========================================
+ Hits 13303 13512 +209
- Misses 415 416 +1 ☔ View full report in Codecov by Sentry. |
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 seem to barely document code I write under a deadline. I will continue this with more suggestions later, but feel free to edit them - or add your own documentation, there is a lot to do...
The directory structure and naming looks pretty good. I have not checked the tests yet
@@ -0,0 +1,13 @@ | |||
add_library(dabm |
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.
add_library(dabm | |
add_library(d_abm |
I would keep the underscore in the name, we keep it in other models as well.
The operator $G$ defines the infection state adoptions and only acts on $Z$, while $L$ defines location changes, only acting on $X$. Infection state adoptions are modeled with independent Poisson processes given by adoption rate functions. Movement is modeled with independent diffusion processes. A temporal Gillespie algorithm is used for simulation. | ||
|
||
The Model class needs an Implementation class as template argument which prvides the domain agents move and interact in. We here implemented a quadwell potential given in the class QuadWellModel, but any other suitable potential can be used as implementation. |
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 would point out how L and G can be found in the ABM implementation. Maybe:
The operator $G$ defines the infection state adoptions and only acts on $Z$, while $L$ defines location changes, only acting on $X$. Infection state adoptions are modeled with independent Poisson processes given by adoption rate functions. Movement is modeled with independent diffusion processes. A temporal Gillespie algorithm is used for simulation. | |
The Model class needs an Implementation class as template argument which prvides the domain agents move and interact in. We here implemented a quadwell potential given in the class QuadWellModel, but any other suitable potential can be used as implementation. | |
The operator $G$ defines the infection state adoptions and only acts on $Z$, while $L$ defines location changes, only acting on $X$. Infection state adoptions are modeled with independent Poisson processes given by adoption rate functions. Movement is modeled with independent diffusion processes. A temporal Gillespie algorithm is used for simulation, a direct method without rejection sampling. Therefore, $G$ and $L$ are not implemented explicitly, instead their effects are sampled via the `move` and `adoption_rate` functions, respectively. | |
The Model class needs an Implementation class as template argument which provides the domain agents move and interact in. We here implemented a quadwell potential given in the class QuadWellModel, but any other suitable potential can be used as implementation. |
(also, a typo)
template <class Implementation> | ||
class Model : public Implementation | ||
{ | ||
public: | ||
using Implementation::Implementation; | ||
|
||
using Implementation::adopt; | ||
using Implementation::adoption_rate; | ||
using Implementation::get_rng; | ||
using Implementation::move; | ||
using Implementation::time_point; | ||
|
||
using Status = typename Implementation::Status; | ||
using Agent = typename Implementation::Agent; | ||
|
||
inline constexpr void check_constraints() const | ||
{ | ||
} | ||
}; |
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.
Whoever would write all of this without a singular comment?
template <class Implementation> | |
class Model : public Implementation | |
{ | |
public: | |
using Implementation::Implementation; | |
using Implementation::adopt; | |
using Implementation::adoption_rate; | |
using Implementation::get_rng; | |
using Implementation::move; | |
using Implementation::time_point; | |
using Status = typename Implementation::Status; | |
using Agent = typename Implementation::Agent; | |
inline constexpr void check_constraints() const | |
{ | |
} | |
}; | |
/** | |
* @brief Wrap an implementation of a diffusive ABM so it can be run by the d_abm::Simulation. | |
* Uses the CRTP. See comments on using statements for expected function signatures. | |
* @tparam Implementation A class implementing all functions and types marked with the using keyword in Model. | |
*/ | |
template <class Implementation> | |
class Model : public Implementation | |
{ | |
public: | |
/// Use the constructors defined by the Implementation | |
using Implementation::Implementation; | |
/** | |
* @brief Set the status of an agent. | |
* Expected signature: `void adopt(Agent&, const Status&)` | |
*/ | |
using Implementation::adopt; | |
/** | |
* @brief Calculate the current adoption rate of an agent from its status to the given one. | |
* Expected signature: `double adoption_rate(const Agent&, const Status&)` | |
*/ | |
using Implementation::adoption_rate; | |
/** | |
* @brief Change the Position of an Agent, depending on its state, the current time and step size. | |
* Expected signature: `void move(const double, const double, Agent&)` | |
* The first argument is time, the second step size. | |
*/ | |
using Implementation::move; | |
/** | |
* @brief Get the Implementations RNG. | |
* Expected signature: `mio::RandomNumberGenerator& get_rng()` | |
*/ | |
using Implementation::get_rng; | |
/** | |
* @brief Aggregate the population by their Status for the simulation result. | |
* Expected signature: `Eigen::VectorXd time_point()` | |
*/ | |
using Implementation::time_point; | |
/// @brief The status of an agent. | |
using Status = typename Implementation::Status; | |
/// @brief An agent is expected to contain at least a status and a position. | |
using Agent = typename Implementation::Agent; | |
/// @brief Empty function for compatability with MEmilio. | |
inline constexpr void check_constraints() const | |
{ | |
} | |
};``` |
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 #1159