Return value of SimFactory.ModelMock(): Entity instance vs. entity set

Issue #14 resolved
Stefan Scherfke
created an issue

Currently, both, SimFactory.ModelMock.create() and SimFactory.ModelMock() return a list of entities created. From a user's point of view, it would make more sense that SimFactory.ModelMock() returns a single instance, because it looks like a normal class instantiation. However, in cases where you want to create, e.g., a power grid and get a number of buses and branches in return, obviously doesn't work.

The two possible solutions for this are

  1. Always return a list of entities (current implementation)
  2. Allow hierarichical entity sets. In the example above, this would return a PowerGrid entity with the buses and branches stored in sub-entitysets.

If we switch from lists of entities to an EntiySet data structure as a wrapper around multiple entities (see also issue #13), the second approach may become more feasible. On the other hand, the return value of the init() API call (which is currently a playin list of dicts) may becore more complicated.

Comments (1)

  1. Stefan Scherfke reporter

    Fixed issue #14 by introducing hierarchical entities.

    sim.Model() now always returns one entity typed Model and sim.Model.create(x) now alsways returns a list of x instances of Model. If not, an AssertionError is raised.

    Entity now has a children attribute which optionally contains an entity set with subordinate entities (e.g., the buses and branches of a grid).

    → <<cset 08d457849902>>

  2. Log in to comment