Skip to content

Type mismatch in metaprogramming for test_commuters #1383

@julianlitz

Description

@julianlitz

Bug description

There is a type mismatch in the metaprogramming expression used for test_commuters.

In metapopulation_mobility_instant.h, the alias is defined as:

template <typename FP, class Sim>
using test_commuters_expr_t = decltype(test_commuters(
    std::declval<Sim&>(), std::declval<Eigen::Ref<const Eigen::VectorX<FP>>&>(), std::declval<FP>()));

Here the second argument is declared as
Eigen::Ref<const Eigen::VectorX<FP>>&.

However, in ode_secir/model.h, test_commuters is actually implemented as:

template <typename FP, class Base = mio::Simulation<Model<FP>, FP>>
auto test_commuters(Simulation<FP, Base>& sim, Eigen::Ref<Eigen::VectorX<FP>> mobile_population, FP time)
{
    ...
}

So the function expects a non-const Eigen::Ref<Eigen::VectorX<FP>>, while the metaprogramming code uses a const reference.
This causes a mismatch and should be fixed by removing the const in the alias.

Additionally, the template parameter Base in the definition of test_commuters should be updated.
It currently uses:

class Base = mio::Simulation<Model<FP>, FP>

but the correct order should be:

class Base = mio::Simulation<FP, Model<FP>>

Summary of fixes

  • In test_commuters_expr_t, change
    Eigen::Ref<const Eigen::VectorX<FP>>&Eigen::Ref<Eigen::VectorX<FP>>.
  • In the test_commuters template, change
    class Base = mio::Simulation<Model<FP>, FP>class Base = mio::Simulation<FP, Model<FP>>.

Version

Windows

To reproduce

./../build/bin/ode_secir_graph_example

Relevant log output

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

Checklist

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

Metadata

Metadata

Assignees

Labels

class::bugBugs found in the software

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions