Skip to content

refactor: implement new additions to SII interface #2544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 13, 2024

Conversation

AayushSabharwal
Copy link
Member

Also some bug fixes and test improvements

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.

@ChrisRackauckas ChrisRackauckas merged commit 539fe81 into SciML:master Mar 13, 2024
@AayushSabharwal AayushSabharwal deleted the as/sii-default-values branch March 14, 2024 05:24
@@ -630,7 +630,7 @@ function _structural_simplify!(state::TearingState, io; simplify = false,
if has_io
ModelingToolkit.markio!(state, orig_inputs, io...)
end
if io !== nothing
if io !== nothing || any(isinput, state.fullvars)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might (almost certain) have unintended consequences. input = true does not have the same meaning as being part of io.

Copy link
Contributor

@baggepinnen baggepinnen Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for example, all RealInput in MTKstdlib are marked as input = true, but they should not be considered io unless explicitly requested by the user.

Copy link
Member Author

@AayushSabharwal AayushSabharwal Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware of this. The fix comes from a test failure: input_output_handling.jl expects the following system to be simplified

@variables x(t) u(t) [input = true]

@named sys = ODESystem([D(x) ~ -x + u], t) # both u and x are unbound

However, without this change the test fails since u isn't recognized as an input. Should the test be updated?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I seem to have been a bit confused about how it works internally here, which test was it that failed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssys = structural_simplify(sys)
errors

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see

# simplification turns input variables into parameters
ssys = structural_simplify(sys)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few days ago, this code was actually being run unconditionally on io == nothing, so I don't think it will break anything. Also for MTKstdlib, it's probably more correct not run the inputs_to_parameters unless io is provided, in case we want to make more use of the input= true metadata in the future. When the test was written, I think input = true was the only way to indicate an input, but since we added the io argument we changed approach to let the user-provided io indicate the externally visible inputs and outputs, while the input = true metadata lost most of its meaning. the reason is that whether something is an externally visible input is a property of how a component is used, rather than an inherent property of the component. Hence, specifying this information inside component does not make sense, and we instead pass io when we have assembled the whole system

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants