Jump to content

Sequential Storage Queue Search


jrobinson

Recommended Posts

Hi All,

I am attempting to model a triage logic where I want to periodically, sequentially search the contents of a storage queue associated with a station and test the availability of resources to handle processing it. If the resources are not available in the system, I would like to move to the next entity in the queue and test it until all the current queue has been examined. 

The goal is to sequentially walk the queue organized by priority using the lowest value first of a state variable on the entities. 

Is there a suggested "best" way to approach this sort of problem?  Essentially I want to do a loop to examine entities in a storage queue and transfer the best one with a match to available resources.

I tried using a search based on index but ran into an error getting the state values of the entity and also seem to have challenges sorting the storage queue correctly.  I would be grateful if someone has a basic example of such a sequential search.

Thanks Very Much,

Jim

Link to comment
Share on other sites

Well, I seem to have made some progress.  I realized I was trying to sort the contents of the station incorrectly.  When I started using the "Contents Ranking Rule" the entities in the storage queue lined up correctly.  

I then found that I could assign a string Element Reference Element state variable "ElRef" to TestStation.Contents.ItemAtIndex(CycleCounter ) where TestStation is the name of my station with a storage queue. This returns a reference to the entity at wherever the cycle counter is at for example, it might find "entity.27" for the current reference.  

This is where I get a bit confused.  I was able to then search the storage queue for TestStation.Contents.ItemAtIndex( CycleCounter)==ElRef.  This is the only way I could figure out how to access the existing state values of the entity with reference "entity.27" or whatever as it would be guaranteed to exit the found branch.  From that point I believe I can test the states of the found entity to see if it is a good fit to enter the system.  If not I can increment the CycleCounter if there are more to check in the prioritized storage queue.  

My sense is this "should work".   But it does not seem as efficient as one might like. I am curious if there might be a more direct way to access the entity's attributes without the search step.

Thanks,

Jim

 

 

 

Link to comment
Share on other sites

×
×
  • Create New...