Skip to content

Syntax for simple assignment events #4031

@TorkelE

Description

@TorkelE

With the new MTK event, we can pretty much define all manners of events. However, by being very general, it complicates things for defining many simpler, more common events. I.e. an event which updated a parameter at time 1.0 previously was:

event = [1.0] => [p ~ 1.0]

while now it requires first importing the discrete event callback, and then designating that p's value should change:

using ModelingToolkit:SymbolicDiscreteCallback,
event = SymbolicDiscreteCallback([1.0] => [p ~ 1.0]; discrete_parameters = [p])

this is especially a problem in Catalyst's DSL where we currently have no means of designating options like discrete_parameters, which means that we currently cannot support events that upate parameters.

Would it be possible to have some kind of simplified syntax for an affect on the form:

... => [X ~ ...]

where the rhs is a single thing which is updated according to the expression on the right (where Pre can be implied or explicitly required). That way, we could support this in the Catalyst DSL (and require people who wish to declare more complicated events to do so programmatically. If this actually turns out to be something that people would like to do frequently, although I doubt it, we can then figure out how to support this in the DSL).

We could just implement this directly in Catalyst, however, it would be preferable to have something MTK generic we could point to instead of having a separate syntax.

Alternative ways to do it would to have a separate event constructor, or to have a different syntax in the symbolic, e.g. something like

... => [X = ...]
... => [X := ...]
... => [X <= ...]

A different Constructor would save introducing a new syntax, but a new syntax like this would enable the creation of events without importing SymbolicDiscreteCallback or an equivalent.

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