Skip to content

Scales cannot work properly from native code #10

@LourensVeen

Description

@LourensVeen

In a macro-micro situation, the macromodel runs once, and a native implementation of the macromodel can use will_stop() to test whether to exit its submodel execution loop. If you set the 'macro:T' and 'macro:dt' properties appropriately, this works.

However, for a native micromodel (which has to run more than once), it seems like it doesn't. A Java micromodel that inherits from muscle.core.kernel.Submodel can override init(), receive its f_init message in there, then return the timestamp of that message to be set as its originTime. The muscle.core.kernel.Submodel.willStop() method will then add the model's T to that originTime, and check that a message has been sent for that timestamp (i.e. an O_f) to decide whether to stop or not.

A native micromodel cannot do this, and has no way of setting originTime. As a result, will_stop() will only work correctly on the first submodel run. After that, it will always return true, since we're already past the time of the first model run. There does not seem to be any way for the native micromodel to communicate the originTime of its current run to the muscle.core.standalone.NativeKernel in the protocol or the native APIs.

The obvious work-around is to have the native model do its own time-keeping and not use will_stop(), but it would be better to fix this in a new native API.

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