Skip to main content

DOCES is an experimental library to simulate opinion dynamics on complex networks

Project description

DOCES

DOCES (Dynamical Opinion Clusters Exploration Suite) is an experimental Python library to simulate opinion dynamics on adaptive complex networks. Its background is implemented in C for performance.

Install

To install DOCES, simply use the following:

pip install doces

Usage

Once installed, you can set up the agent-based simulation by instantiating an object with the constructor Opinion_dynamics() with a network, like in the example below.

import doces
# Initializes the network parameters
...
# Creates a DOCES object.
od = doces.Opinion_dynamics( 
    vertex_count, 
    edges,
    directed)

The constructor takes the features of the network connecting agents as arguments. They are:

  • vertex_count - number of nodes/agents in the network;
  • edges - a python list of 2-tuples of nodes denoting the network edges ((source, target) in the case it is directed);
  • directed - a boolean indicating whether the network is directed or not;

Once the od object is initialized, the simulation can be performed by calling its method simulate_dynamics() as

# Initializes the dynamics parameters
...
# Run the dynamics
output_dictionary = od.simulate_dynamics(
    number_of_iterations,
    phi,
    mu, 
    posting_filter, 
    receiving_filter,
    b = None,
    feed_size = 5,
    rewire = True,
    cascade_stats_output_file = None,
    min_opinion = -1, 
    max_opinion = 1,
    delta = 0.1,
    verbose = True,
    rand_seed = None)

opinions = output_dictionary["b"]
edge_list = output_dictionary["edges"]

The method outputs are a list opinions of continuous values between min_opinion and max_opinion for each agent and a Python list of 2-tuples with the network structure after the simulation is finished. Its inputs are:

  • number_of_iterations - an integer (positive value) that is used as the number of iterations for the model to run;
  • phi - a float number which controls the receiving filter;
  • mu - a float number that controls the innovation parameter. If mu = 0, there is no innovation, and if mu = 1, all the posts are new and the feed posts are never re-posted;
  • posting_filter - an integer from 0 to 5 to set which function filters posting activity, according to the below specification;
  • receiving_filter - an integer from 0 to 5 to set which function filters how posts are received, according to the below specification;
  • b - an array of floats corresponding to the initial opinions of agents;
  • feed_size - an integer to set the size of the feed. The default value is 5;
  • rewire - a boolean to allow rewiring in each iteration or not;
  • cascade_stats_output_file - a string representing the output file path for cascade statistics. The default value is None;
  • min_opinion - a float corresponding to the minimum opinion value agents can have;
  • max_opinion - a float corresponding to the maximum opinion value agents can have;
  • delta - a float corresponding to the increment (or decrement) applied to opinions in each iteration;
  • verbose - a boolean that allows the code to print details of each simulation;
  • rand_seed - an integer (positive value) used as a seed for random number generation;

The filter functions are predefined in the library in the variables

  • 0: COSINE: Controversial posting rule (eq. 1);
  • 2: UNIFORM: Priority receiving rule;
  • 3: HALF_COSINE Aligned posting rule (eq. 2),
  • 5:CUSTOM Allows different filters to be passed as a list of integers (with size equal to the number of agents).

To use option 5, you can call the methods set_posting_filter() and set_receiving_filter(), as in the example below. Additionally, agents can be set as stubborn by passing a list with integers indicating those agents to the method set_stubborn(). Remember to do this before calling simulate_dynamics().

# Initializes the lists to be set
...
# Set the posting filter
od.set_posting_filter(posting_filter)

# Set the receiving filter
od.set_receiving_filter(receiving_filter)

# Set stubborn users 
od.set_stubborn(stubborn_users)

Citation Request

If you publish a scientific paper using this material, please cite the respective reference(s) as follows.

The standard dynamics developed for undirected networks is cited as follows:

  • Henrique Ferraz de Arruda, Felipe Maciel Cardoso, Guilherme Ferraz de Arruda, Alexis R. Hernández, Luciano da Fontoura Costa, and Yamir Moreno. "Modelling how social network algorithms can influence opinion polarization." Information Sciences 588 (2022): 265-278.

The dynamics for directed networks, or with the use of particular types of users (e.g., stubborn and verified) is cited as follows:

  • Henrique Ferraz de Arruda, Kleber Andrade Oliveira, and Yamir Moreno. "Echo chamber formation sharpened by priority users." iScience (2024).

The dynamics with feeds (innovation parameter mu < 1) is cited as follows:

  • Kleber Andrade Oliveira, Henrique Ferraz de Arruda, and Yamir Moreno. "Mechanistic interplay between information spreading and opinion polarization." arXiv preprint arXiv:2410.17151 (2024).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

doces-0.0.4-cp312-cp312-win_amd64.whl (26.2 kB view details)

Uploaded CPython 3.12 Windows x86-64

doces-0.0.4-cp312-cp312-macosx_11_0_arm64.whl (25.3 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

doces-0.0.4-cp312-cp312-macosx_10_9_x86_64.whl (25.1 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

doces-0.0.4-cp311-cp311-win_amd64.whl (26.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

doces-0.0.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (69.8 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

doces-0.0.4-cp311-cp311-macosx_11_0_arm64.whl (25.1 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

doces-0.0.4-cp311-cp311-macosx_10_9_x86_64.whl (24.9 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

doces-0.0.4-cp310-cp310-win_amd64.whl (26.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

doces-0.0.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (69.5 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

doces-0.0.4-cp310-cp310-macosx_11_0_arm64.whl (25.1 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

doces-0.0.4-cp310-cp310-macosx_10_9_x86_64.whl (24.8 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

doces-0.0.4-cp39-cp39-win_amd64.whl (26.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

doces-0.0.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (69.3 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

doces-0.0.4-cp39-cp39-macosx_11_0_arm64.whl (25.1 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

doces-0.0.4-cp39-cp39-macosx_10_9_x86_64.whl (24.8 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

Details for the file doces-0.0.4-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: doces-0.0.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 26.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for doces-0.0.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9ac3e091fb7d8baac0a626c4d934be507514255381170b40be02075fd5a6809d
MD5 0fa4ffa8b04f0ef85e103f54a9056671
BLAKE2b-256 c4814e05779248a8b728a96538f9b9b15cab03163a5dbc3f98a0c3ad056a239c

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp312-cp312-win_amd64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for doces-0.0.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3a460cc1cf0bb6b2fa017be9ae0eb5a6c61b6ecdc18b461a18bc25b04310fd62
MD5 0b68ab6658b54096aabec6a4643f44f1
BLAKE2b-256 3a93a8673c55734701d7d61e0cfb6b8d289e607f53bee1a330ae43ac42b41472

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for doces-0.0.4-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bbf14a44a26bbb55833d7d0b0fdce3c54d8a03be654a33e1bcbf951fc2e7efcc
MD5 3605bb3ce879470e20c76d9ba8a919d2
BLAKE2b-256 f61e64e245b24136f46e54b2d1f681daf4afcb011bd8c7f9f3bfae9724a49763

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp312-cp312-macosx_10_9_x86_64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: doces-0.0.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for doces-0.0.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dc982a742ffd8b1d2b4817b099dfb8384e2f32ef89554f6f22f2450597b0115e
MD5 e5e7b17a6a434b9c9f409b58a7b3346c
BLAKE2b-256 8899a361b72ca1979216196fef84f57f1189c265cc370ea229fe42c00746d4c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp311-cp311-win_amd64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for doces-0.0.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9dbe567d0249d1cc8bce1609a50230cf4422d99619aac6e0b3c4a09415b22766
MD5 5416305ea87b7c5a6bb775b2645816cd
BLAKE2b-256 7bd692c0abdc0392aa20bbbcda80547b1fbf9aa286e6717f64f73d0f2ee9134b

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for doces-0.0.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e298ce097fdcec6ba4da281c410b2e0e04c8b3b7bb504521fc7454c342c69387
MD5 8cd29afbff7ed7a91cc36b38e5e94ef1
BLAKE2b-256 35bdbafddc4ce102f22fea36eb8797ac6fcd72ca6199de4c49700d0d1bc38ab4

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for doces-0.0.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8260cc750a7cf6685975f3f3500413e983bdb2b6d6a352fac11199ea50595bf7
MD5 25b99961ed41cb4c20e5ed401407705f
BLAKE2b-256 9f9b7df08f681e3b028e332fbc56b542aa314056427b529fccde48c36c7bda46

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: doces-0.0.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for doces-0.0.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b4b318ce688e4f62ef8ac2c55cfe1827c75d79c42c9e197234e3041d5eb1d30b
MD5 cbeeb845f82f3c8280e85307713073cc
BLAKE2b-256 fb7d14f90636305fc7d618eac10741006f6094cbd00cece44c7c357dcda5adb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp310-cp310-win_amd64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for doces-0.0.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 85745e989f1edf593c6cad61053bdc9dc5104309a5b450a40e465000f0b963b4
MD5 be6e264d3cec51790f410ba5d936a738
BLAKE2b-256 ff7a9f0cf9c046bceed04b86e09081631b3af6a93281b9e7c4158f92746b164e

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for doces-0.0.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 568bebc8f3456c0ddf1d4e73495c4e710a29f658f6c2c5f43e8efdb80960017b
MD5 f19701b03edd4bec74819cf2e0bb2fb9
BLAKE2b-256 0804d5a3a4d1ffaca206d324c7ee31e1fa6e134638ae8153aafe441289620348

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for doces-0.0.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7be824aae997bdf79e3644c23c186ed4691640bfe0f49fb38dbbe158475a1cb1
MD5 2b2ef15bd13d4cd0712824f93de2611b
BLAKE2b-256 cf662fdd0baf47298233fbc0425fa6ed5b8e08d12d0e570a9d072ea517cfb0f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp310-cp310-macosx_10_9_x86_64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: doces-0.0.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for doces-0.0.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f743c1e226a2c944d91c43d9e59a42e5e3d083e1af4722cd332e80ebff9957f9
MD5 2c540773dbe8c5427e30d23338b2b6f3
BLAKE2b-256 190a18b01d0e705a7adf1e9db68482a3529df47e0c5aeb0e9169ea16db93c425

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp39-cp39-win_amd64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for doces-0.0.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 465c5d60a3c66391c3a44ff3249ed6005da29c5b7303e38a0b96d836f714f021
MD5 45d8fadccdb962a20526e4e710c4e789
BLAKE2b-256 33f327ddac7c794c2effda7d0c59e4ec367c4ebca7d446d1160b1cc982c84dd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for doces-0.0.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f099ad141b6fea1772631dee953e962a415d2081deab9e1b2632da92a66e28c7
MD5 c787eb73d4c5778b8ea5e9f0835e77f2
BLAKE2b-256 d48d8e64ca43b6a3f7e3ef9d209e1647493f58938ce9560239bd0cc5172ce36e

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

File details

Details for the file doces-0.0.4-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for doces-0.0.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 475a3233cc993e44f75b19550a6a0e014f66b76377e513afe0bdf787e3cb33e6
MD5 78a479a4ae4a16dd2b61740ec0432d49
BLAKE2b-256 013a93351890faa7947e5c4fc01fbd929e35d08ecab5d918b35965eb6926b20c

See more details on using hashes here.

Provenance

The following attestation bundles were made for doces-0.0.4-cp39-cp39-macosx_10_9_x86_64.whl:

Publisher: build-publish-pypi.yml on hfarruda/doces

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page