Skip to content

Contact between identical agentid? #400

@RobRomijnders

Description

@RobRomijnders

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions