Skip to content

Support explicit output dependencies to avoid false circular dependency #258

Description

@JackCaster

Hi, I'm using PythonFMU to create a FMI-based co-simulation driving simulator. Roughfly, the setup consists of esmini acting as the scenario controller, a driver, and a simple vehicle kinematic model.

esmini -> Driver FMU -> Vehicle FMU
              ^            |
              |            |
              +------------+

where:

  • omsimulator is the orchestrator
  • esmini provides the scenario and surrounding traffic information.
  • The Driver FMU receives vehicle and environment information (speed, position, lane information, traffic participants, etc.).
  • The Driver FMU computes driving actions (steering, throttle, brake, trajectory updates, etc.).
  • The Vehicle FMU receives these actions and updates the vehicle state.
  • The updated vehicle state is fed back to the Driver FMU.

This creates a feedback loop between the Driver FMU and Vehicle FMU.

The issue is that PythonFMU generates output entries such as:

<ModelStructure>
  <Outputs>
    <Unknown index="1"/>
  </Outputs>
</ModelStructure>

Since the dependencies attribute is omitted, omsimulator assumes that an output depends on all current inputs as per standard

If not present, it must be assumed that the Unknown depends on all Knowns. (p 61 in https://fmi-standard.org/assets/releases/FMI_for_ModelExchange_and_CoSimulation_v2.0.pdf)

, but this does not apply here. The driver, in fact, gets inputs from the Vehicle FMU and esmini, internal state is updated during do_step(), and outputs are produced from the driver's internal state. There is no direct feedthrough from current inputs to current outputs within the FMU. The outputs are effectively based on information from the previous communication step.

Current workaround

After building the FMU, we patch modelDescription.xml and change:

<Unknown index="1"/>

to:

<Unknown index="1" dependencies=""/>

for outputs that have no direct feedthrough.

This prevents false algebraic-loop detection.

Request

Would it be possible to expose output dependency information in PythonFMU?

For example:

Real(
    "steering",
    causality=Fmi2Causality.output,
    dependencies=[]
)

or some equivalent mechanism.

This would allow FMU authors to provide accurate ModelStructure information and avoid the need to patch the generated FMU after the build process.

Is there already a supported way to specify output dependencies in PythonFMU that I may have missed? If not, would you consider adding support for explicit output dependencies?

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