Skip to content

Assertion fails when building event callbacks #1528

Closed
@DaniGlez

Description

@DaniGlez

When composing a system with MTK (8.7.0), empty callbacks (i.e. of the form ModelingToolkit.SymbolicContinuousCallback(Equation[], Equation[])) are sometimes created. These callbacks seem to trip the assertion on

@assert maximum(eq_ind2affect) == length(affect_functions)

Here's code for reproducing the issue: https://gist.github.com/DaniGlez/22c98bd7d8b3bba479cf98082c62da56
In this example, four callbacks end up in the system after structural_simplify():

4-element Vector{ModelingToolkit.SymbolicContinuousCallback}: ModelingToolkit.SymbolicContinuousCallback(Equation[], Equation[]) ModelingToolkit.SymbolicContinuousCallback(Equation[m₊x(t) ~ 1.0], Equation[m₊v(t) ~ -m₊v(t)]) ModelingToolkit.SymbolicContinuousCallback(Equation[m₊x(t) ~ -1.0], Equation[m₊v(t) ~ -m₊v(t)]) ModelingToolkit.SymbolicContinuousCallback(Equation[], Equation[])

The assertion mentioned above therefore fails, since the largest index mapping to an affect is 3 while there are four affect functions (even if the last one is a dummy function)

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