Skip to content

Enable AssignmentAffect for simple events #4239

@TorkelE

Description

@TorkelE

Previously, you had events on the form p ~ p + 1, where the left-hand side was the symbolic variable you wanted to update, and the right-hand side the expression you wanted to assign it to. With the new events, we can make much more general events, however, it complicated the simple eventsl ike this as you now have to specify discrete_parameters, which requires importing ModelingToolkitBase.SymbolicDiscreteCallback and similar.

Per previous discussion, it would be useful to have a special constructor that assmues the old simplified affect syntax. I.e. you could do

... => AssignmentAffect(p ~ p + 1)

which is automatically inferred to be

SymbolicDiscreteCallback(... => p ~ Pre(p) + 1; discrete_parameters = p)

The reason this is useful is that, within the Catalyst DSL, we do not have the option of using arguments as discrete_parameters. My soolution would be:

  1. The DSL only supports the simple assignment events (this is >95% of the events we would expect anyway).
  2. People who want to use more complicated events either have to interpoalte them into the DSL, or use programmatic modelling).

Currently, I have a normal implementation of this, however, if MTK had a AssignmentAffect or similar, I could simply dispatch to that, and MTK could do the related work, which probably is a more sensible solution. It could likely be useful to others as well who are in similar situations.

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