Skip to content

Copy world doesn't work with fixed trips #961

@DavidKerkmann

Description

@DavidKerkmann

Bug description

When copying the world of the ABM, persons are copied in order of appearance in the locations. That means that person IDs change but the order of the person vector may change. Since trips are accessed via
auto& person = m_persons[trip.person_id];
this is an issue and leads to an error.

This can be either resolved by keeping the order of the persons during a copy operation on the world OR by accessing people not with array indices but only by their unique person ID.

Version

Mac

To reproduce

Go to branch abm_paper_test_bs.
Use the code

// Create the sampled simulation with start time t0.
auto world = mio::abm::World(num_age_groups);
create_sampled_world(world, input_dir, t0, max_num_persons);
auto world_copy = world;
// auto world_copy = world; // COPY CONSTRUCTOR DOESN'T WORK. LOCATIONS AREN'T ASSIGNED!
auto sim = mio::abm::Simulation(t0, std::move(world_copy));

in lines 897 ff.

Relevant log output

Assertion failed: (index != INVALID_LOCATION_INDEX && "unexpected error."), function find_location, file world.cpp, line 191.

Add any relevant information, e.g. used compiler, screenshots.

No response

Checklist

  • Attached labels, especially loc:: or model:: labels.
  • Linked to project

Metadata

Metadata

Assignees

No one assigned

    Labels

    class::bugBugs found in the softwareloc::backendThis issue concerns the C++ backend implementation.model::abmThis issue concerns any kind of agent-based model.

    Type

    No type

    Projects

    Status

    Done (Total) 💯

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions