Skip to content
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

Develop #36

Merged
merged 25 commits into from
Mar 22, 2024
Merged

Develop #36

merged 25 commits into from
Mar 22, 2024

Conversation

amritagos
Copy link
Member

Now implements the Deffuant models, and various refactors to improve the code base structure, reducing redundancy and complexity.

amritagos and others added 25 commits March 19, 2024 18:27
The ConfigParser sets variables and checks them, so defaults should not
live inside the class

Co-authored-by: Moritz Sallermann <[email protected]>
Now you can use the draw_k_from_n function without repitition while
optionally including or excluding a particular index from 0 to N

Co-authored-by: Moritz Sallermann <[email protected]>
This compiles but segfaults when you run the example. Some
silly prints inside simulation for ad-hoc debugging.

Co-authored-by: Moritz Sallermann <[email protected]>
More clarity. The public interface of a class should be the most visible

Co-authored-by: Amrita Goswami <[email protected]>
Implemented a simple unit test with two agents for the basic deffuant
model. Also initialize the agents uniformly on the interval [0,1] in the
constructor (like we do in the DeGroot model).

Co-authored-by: Amrita Goswami <[email protected]>
This function sorts the adjacency list by neighbour idx and removes
doubly counted edges by summing up their weight.

Co-authored-by: Amrita Goswami <[email protected]>
Also fixed the clear() function and removed some prints in test_network
Generates a neighbour list such that agents are on a square lattice, and
each agent has 4 neighbours. PBCs are implemented. TODO: perhaps move
from size_t to int?

Co-authored-by: Moritz Sallermann <[email protected]>
To reduce unnecessary commits with minor formatting changes, we have
pinned clang-format to 18.1.1. Different versions of clang-format
apparently produce different outputs.

Co-authored-by: Moritz Sallermann <[email protected]>
Implemented the Deffuant model with a square lattice neighbour list.
TODO: Actually parse these options.

Co-authored-by: Moritz Sallermann <[email protected]>
We now support an implementation of the Deffuant model on a square
lattice. TODO: unit test!
We use a 16x16 lattice and observe the formation of two stable clusters.

Co-authored-by: Amrita Goswami <[email protected]>
Utility function that parses a string that is in teh format of a
comma separated list and executes a callback function for each entry
in the list.
Also added a unit test for it.
Started to implement the Deffuant model with vectors. To minimize code
duplication we refactored the `ModelDeffuant` class in the following
way:
    - We introduced `DeffuantModelAbstract<AgentT>` which is a template
      class and implement the behaviour that is common to both the basic
      Deffuant model and the vector deffuant model
    - The basic deffuant model is now a specialization of
     `DeffuantModelAbstract<SimpleAgent>`, where all the behaviour
      specific to the basic Deffuant model is implemented via template
      specialization and explicit instantiation in a separate .cpp
      source code file
    - The same was done with the vector Deffuant model, but it is not
      fully implemented yet.

To simplify the notation they are availabe to the rest of the code via:
`using DeffuantModel = DeffuantModelAbstract<SimpleAgent>;`
`using DeffuantModelVector = DeffuantModelAbstract<DiscreteVectorAgent>;`

Co-authored-by: Amrita Goswami <[email protected]>
Implemented the Hamming distance, needed for the vector Deffuant model.

Co-authored-by: Amrita Goswami <[email protected]>
Also hacked in the generation of the initial agents by hardcoding the
dimensionality <--- TODO

Co-authored-by: Amrita Goswami <[email protected]>
The generation of the initial network is now simpler and doesnt need
model specific branches anymore. The tradeoff was that the meanfield
AD model must now create the fully connected network it requires itself.

Co-authored-by: Amrita Goswami <[email protected]>
Now takes the `ActivityDrivenSettings` struct to construct. This also
enabled making many member variables private. Also gave the `Model`
base class a constructor that takes `max_iterations`.

Co-authored-by: Amrita Goswami <[email protected]>
Easier and clearer. Also more private members.

Co-authored-by: Amrita Goswami <[email protected]>
Less code repetition, less confusing, less shitty

Co-authored-by: Amrita Goswami <[email protected]>
Made a new header `model_factory` that takes care of the complexity.

Co-authored-by: Amrita Goswami <[email protected]>
We now call initialize_agents for the Deffuant model out of the
constructor, so that we can pass it the dimensions for the
DeffuantVector model

Co-authored-by: Moritz Sallermann <[email protected]>
The user can now enter the dimensions for the DeffuantVectorModel.
Additionally, ConfigParser also checks to make sure that the
user-defined dim=1, if the basic Deffuant model is being used. We also
added a test for the DeffuantVectorModel.

Co-authored-by: Moritz Sallermann <[email protected]>
@amritagos amritagos merged commit 2481785 into main Mar 22, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants