Initializing Entities from a stack?

A place for Ventity software questions & answers
Post Reply
rob_n
Senior Member
Posts: 53
Joined: Thu Feb 22, 2018 6:12 pm
Vensim version: DSS

Initializing Entities from a stack?

Post by rob_n »

Hi,
Consider a stack of projects to complete, each with a different initial amount of work to do. Since labor is finite, work is completed for only a few projects simultaneously. Naturally I would like to track only the projects that are active, e.g. start the simulation with just a few projects entities and delete a project entity once the remaining work is zero. Since completion of a project frees up labor, progress can begin on a new project: I would like the initial conditions of the new project entity to be drawn from the "stack" of projects.

So it seems like there are two ways to initialize entities:
(1) With the Entity Initialization Data in the Model Overview. This seems like a natural place for the "stack" of projects: there are place holders for all the information I would need about every project. The problem is I do not know in advance the time at which the entity must be created. Entities that have an empty checkbox are not "next on the stack", instead they are never created.
(2) With the create entity action, you can set the initial conditions for stocks, attributes, etc. I can populate the initial condition of a stock with a lookup table, driven by a running counter of the number of projects. (See attached example.) But this becomes tedious if there are many initial conditions to set, and becomes especially tedious if I need to change the projects in the "stack".

Seems like a third way would be useful:
(3) Check all the entities in the Entity Initialization Data, but allow for some other trigger than Time >= value to create the entity.

Is there an easy way to do this already?

Best regards,
Rob
Attachments
Initialize_from_Lookup.zip
(11.65 KiB) Downloaded 309 times
rob_n
Senior Member
Posts: 53
Joined: Thu Feb 22, 2018 6:12 pm
Vensim version: DSS

Re: Initializing Entities from a stack?

Post by rob_n »

I guess rather than a lookup table, the Create Entity action could initialize the project (stock initial conditions, attributes, etc.) using a Vensim-like GET DIRECT DATA, say with a counter to index the row number. Can we do a similar kind of mapping to a Data Entity?
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Initializing Entities from a stack?

Post by tomfid »

There is a way to do this, but it's a little indirect. Create an entitytype A containing just the initialization data, then a paired entitytype B with the dynamics.

Then the A entities serve as the stack, and you can use the next available A to create a B via an action. This is a little wasteful, because the A's don't really need to exist all the time, but if they don't have any dynamic variables, the cost should be low.

I've entered a feature ticket for the more general idea - it's closely related to some other things we'd like to do.
rob_n
Senior Member
Posts: 53
Joined: Thu Feb 22, 2018 6:12 pm
Vensim version: DSS

Re: Initializing Entities from a stack?

Post by rob_n »

Yep, this can work. My solution (attached) is a bit of a kludge.
1. In the portfolio, an attribute refers to the "header" of the Project A list, and we track the work associated with header Project A.
2. During the action to create a Project B entity, I initialize the work by transferring the entire stock out of all the work from header Project A.
3. When the work of header Project A goes to zero, it triggers a Process List action to change the header ID.
4. The Process List filters on Project A with positive work. For the Sort to work, I needed to add a sequence auxiliary to Project A (which is probably helpful anyway).

Perhaps there is a more elegant solution?
Attachments
Initialize_from_Stack.zip
(12.52 KiB) Downloaded 312 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Initializing Entities from a stack?

Post by tomfid »

I'll take a look. I'm not sure about "more elegant" but you could avoid the process list by making the stack into a linked list by adding a "next in stack" attribute to each stack item. On the other hand, the process list is nice because you could change the priority for selecting the next item dynamically.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: Initializing Entities from a stack?

Post by tomfid »

Here are a couple variations. In the "PL1" version, I made the process list approach a little fancier.

In the "2" version, I switched to a linked list.
projectStack.zip
(31.95 KiB) Downloaded 360 times
rob_n
Senior Member
Posts: 53
Joined: Thu Feb 22, 2018 6:12 pm
Vensim version: DSS

Re: Initializing Entities from a stack?

Post by rob_n »

I like it! I find it takes me a lot of clicking and peeking to build the mental map of where are all the triggers for the actions, especially for someone else's model. A swimlane diagram seems to be a compact way to show who are the invokers / owners / setters of triggers, actions, and initial conditions. See attached for the Intialize_from_Stack_PL1 example. Graphml version opens in yEd. It would be cool, and perhaps not too difficult, to generate such a swimlane diagram automatically from the entity relationships.
Attachments
Initialize_from_Stack_PL1_swimlane.zip
(59.98 KiB) Downloaded 314 times
Post Reply