Page 1 of 1

bags in Ventity?

Posted: Wed Aug 15, 2018 1:25 pm
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

Re: bags in Ventity?

Posted: Wed Aug 15, 2018 1:37 pm
by tomfid
Does this selection happen at a single point in time, or does the state have to be remembered across time steps?

Re: bags in Ventity?

Posted: Wed Aug 15, 2018 2:12 pm
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 347 times
. This does not make so much sense for this model, but for the bigger model I'm developing it does.

Re: bags in Ventity?

Posted: Wed Aug 15, 2018 2:21 pm
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.

Re: bags in Ventity?

Posted: Wed Aug 15, 2018 2:47 pm
by apmoorepa
Yes, that is right.

Re: bags in Ventity?

Posted: Wed Aug 15, 2018 3:03 pm
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.

Re: bags in Ventity?

Posted: Wed Aug 15, 2018 11:45 pm
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.)

Re: bags in Ventity?

Posted: Thu Aug 16, 2018 12:23 pm
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?

Re: bags in Ventity?

Posted: Thu Aug 16, 2018 1:21 pm
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.

Re: bags in Ventity?

Posted: Thu Aug 23, 2018 3:56 pm
by apmoorepa
This worked brilliantly. Thanks Tom. I think I finally understand the full value of the IsNull built-in function for this purpose.

Re: bags in Ventity?

Posted: Thu Aug 23, 2018 4:10 pm
by tomfid
It'll get better, too, when we make it possible to reanimate a deleted relationship. Glad it works for you!