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

Contact between identical agentid? #400

Open
RobRomijnders opened this issue Jun 27, 2023 · 2 comments
Open

Contact between identical agentid? #400

RobRomijnders opened this issue Jun 27, 2023 · 2 comments

Comments

@RobRomijnders
Copy link

Hey covasim team, thanks again for opensourcing this simulator. I'm asking this question on the public github so other people get to benefit as well from your answers. Best regards, Rob

Describe the bug

Some layers seem to define contacts between two identical agents. For example, contacts[layer]['p1'][i] == contacts[layer]['p2'][i] for some i. Is this expected or is this a bug?

To reproduce

  1. Run a simulation like in the tutorial5.ipynb
  2. Use as subtarget function for test_num the following:
  def subtarget_func(sim):
    contacts = sim.people.contacts

    for layerkey in contacts.keys():
      num_selfcontact = np.sum(
        contacts[layerkey]['p1'] == contacts[layerkey]['p2'])
      if num_selfcontact > 0:
        print(f"Found {num_selfcontact} contacts in layer {layerkey}")

    # Baseline intervention
    vals = np.ones(len(sim.people))  # Create the array
    vals[cv.true(sim.people.exposed)] = 100  # Probability for testing
    output = dict(inds=sim.people.uid, vals=vals)
    return output

Expected behavior

I would expect that a simulator wouldn't simulate a contact between the identical agent, unless this contact has a special meaning?

Screenshots or outputs

The above subtarget function will print an output like the following. The num_selfcontact differs randomly between runs, but is usually around 5 to 50.

All layers: ['h', 's', 'w', 'c']
Found 8 contacts in layer s
Found 13 contacts in layer w
Found 7 contacts in layer c

Platform (please complete the following information):

  • Covasim version: 3.1.4
  • Python 3.9 on Ubuntu 22
@cliffckerr
Copy link
Member

cliffckerr commented Jun 28, 2023

Hi @RobRomijnders -- well spotted, you're right! In Covasim's default "hybrid" network, we don't bother to remove self-connections, because they have (virtually) no effect on the network, and are computationally costly to find and remove. However, other network options -- such as SynthPops -- do have self-connections removed. We'll add this to the FAQ, because you probably aren't the only person who was confused by this.

@RobRomijnders
Copy link
Author

Ok, good to know. Thanks!

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

No branches or pull requests

2 participants