bags in Ventity?

A place for Ventity software questions & answers
Post Reply
apmoorepa
Junior Member
Posts: 15
Joined: Mon May 21, 2018 2:25 pm
Vensim version: DSS

bags in Ventity?

Post by apmoorepa »

I have a need to sequentially select randomly from a collection of entities where subsequent selections can no longer select entities that were previously selected (like pulling objects from a bag, the objects no longer exist for future selection). I recognize that the process list action can be used to randomly select from a collection (thanks to Tom), but am not sure how to ensure future selections no longer select past selections.

I think it would be possible to keep the items selected in a separate collection that you build up, and then make sure your current selection is not in that collection. I have not tried this, but seems like it should work if a bit awkward/inefficient. I thought I'd see if anyone had any other ideas on how to do this, before trying my hand at it.

Thanks!

--Andy
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: bags in Ventity?

Post by tomfid »

Does this selection happen at a single point in time, or does the state have to be remembered across time steps?
apmoorepa
Junior Member
Posts: 15
Joined: Mon May 21, 2018 2:25 pm
Vensim version: DSS

Re: bags in Ventity?

Post by apmoorepa »

If I am understanding your question correctly, I believe that it has to be remembered across time steps. Going back to the model that you sent me in a previous post, which I've attached, it would be as if you wanted to never pick the same vendor twice (via the PickVendor action)
RandomizeCreateAttrib2.zip
(17.45 KiB) Downloaded 346 times
. This does not make so much sense for this model, but for the bigger model I'm developing it does.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: bags in Ventity?

Post by tomfid »

Is this right?

You have
- firms
- vendors
- firm x vendor relationships

A firm iterates (process list) over the vendors for which there is not an existing firm x vendor relationship, picks n new vendors, and creates relationships with them.
apmoorepa
Junior Member
Posts: 15
Joined: Mon May 21, 2018 2:25 pm
Vensim version: DSS

Re: bags in Ventity?

Post by apmoorepa »

Yes, that is right.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: bags in Ventity?

Post by tomfid »

OK. So, the hard part is that firm is iterating over vendor[], but the check needed is for an instance of relationship[firm,vendor] where firm = the invoker and vendor = refVendor in the process list.

I think it might be possible to construct a reference to the relationship populated that way, and use the IsNull() function to test it.

Another option is to ignore the redundancy and attempt to create the relationship - the create will fail due to duplicate keys. However, the invoker probably can't detect the failure and proceed to another vendor if needed.

Bit of a head-scratcher, but this is actually a fairly common requirement for this kind of situation. Will ponder and attempt a test model.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: bags in Ventity?

Post by tomfid »

This can be done, as long as you don't need to delete relationships but reestablish them later. (There are probably workarounds if you do need that.)
apmoorepa
Junior Member
Posts: 15
Joined: Mon May 21, 2018 2:25 pm
Vensim version: DSS

Re: bags in Ventity?

Post by apmoorepa »

Great to hear! I don't think I need to delete relationships. Do you have a test model or a structure for how it can work?
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: bags in Ventity?

Post by tomfid »

PickNotExistNoDelete 1.zip
(13.72 KiB) Downloaded 349 times
This is an example. The trick is to use IsNull to check for an existing relationship in the Pick Vendor process list action.

You can delete relationships, but then you can't subsequently resurrect one with the same key. This is something we're considering. There might be a workaround, but it'll be a little complicated.
apmoorepa
Junior Member
Posts: 15
Joined: Mon May 21, 2018 2:25 pm
Vensim version: DSS

Re: bags in Ventity?

Post by apmoorepa »

This worked brilliantly. Thanks Tom. I think I finally understand the full value of the IsNull built-in function for this purpose.
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: bags in Ventity?

Post by tomfid »

It'll get better, too, when we make it possible to reanimate a deleted relationship. Glad it works for you!
Post Reply