Skip to content

build_explicit_observed_function no longer handles inputs correctly #2794

@baggepinnen

Description

@baggepinnen

When sys has been processed by io_preprocessing and inputs are passed to build_explicit_observed_function, these inputs are sorted out of the parameter vector by the code

    if inputs !== nothing
        ps = setdiff(ps, inputs) # Inputs have been converted to parameters by io_preprocessing, remove those from the parameter list
    end

However, the following code does not account for this

reorder_parameters(get_index_cache(sys), ps)

so the generated code still expects a parameter vector that is the length of length(ps) + length(inputs) rather than just length(ps). This causes the generated code to be incorrect, accessing parameter values at the wrong indices.

I tried

reorder_parameters(get_index_cache(sys), ps, drop_missing=true)

which makes the parameter array in the generated code of the correct length, but the order is still wrong. @AayushSabharwal I don't understand what reorder_parameters is supposed to do, can you have a look?

It appears possible for us to work around the issue by using split=false to structural_simplify

CC @shobhitvoleti

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions