question

Marzanne avatar image
0 Likes"
Marzanne asked tannerp converted comment to answer

Batching and Resources: Can I sink one token from a batch and continue?

I am working on the left side of the attached process flow model: processflowbatching.fsm

The process flow has three different loops, each with up to 6 stops. I have only been working on the blue loop so far (stop 1 and 2 are the most up-to-date), the rest should follow all the same logic once I figure it out. The batch activity at the beginning of the loop will batch up to 6 tokens (usually 4 tokens), and I would like to create logic that does the following:

  1. Only one resource is acquired per batch (currently, four resources are acquired for the four tokens in the first batch).
  2. One of the tokens is processed at Stop 1, goes through the sink, and the remaining tokens travel with the resource on to Stop 2.
  3. Once all of the tokens are processed, the resource is released.

Creating a connection from a sink to a decide activity seems to be impossible, so I'm thinking that I might have to use some combination of label assignment and conditional decides.

I am also up to suggestions on how to remove all of the connections between the activities in my process flow-- I know it's kind of overwhelming with all of the arrows, but I've tried using lists, global tables, etc. and I can't quite figure out the logic to push and pull tokens without the manual connections.

Thanks in advance for any advice or recommendations you might have!

FlexSim 19.0.0
batchingresourcesrelease tokenbatching grouping
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Joshua S avatar image
0 Likes"
Joshua S answered

I'll keep looking at your model. One way to condense it so it is easier to look at it is to create 1 delay activity per group of Stops. Replace the delays code with this:

Object current = param(1);
treenode activity = param(2);
Token token = param(3);
int stream = getstream(activity);
double randomnum = uniform(0, 100, stream);
double total = 0.0;
for(int i=1;i<=Table(token.TableStop).numRows;i++)
{
		total+=Table("token.TableStop)[i][1]*100;
	if (randomnum<=total)
	{
		return Table(token.TableStop)[i][2];
	}
}
return 1;

You would have a label on the token called "token.TableStop" that would be a string value referencing the correct table. Your tables would also have the Percentage in the first column, and the delay time in the second. If the delay time is a distribution, then select the second column and convert the data type to flexscript.

· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Marzanne avatar image Marzanne commented ·

@Joshua S,

Thank you for the suggestion on how to condense my model! I really like that idea and I think I understand how to do it, but FlexSim is telling me that there is an error in the code. I removed the *100 and updated my tables with numbers that sum to 100, and have updated my process flow to match the direction that I see this going in: processflowbatching.fsm

This is what I hope to do with this updated model (sort of a work-around for my original question):

  • Use a counter (label?) that is set to the batch size and subtracts 1 each time a delay (stop) is completed.
  • Have a Decide after each delay that asks whether or not there are more tokens to process, and if there aren't, releases the resource and sinks all of the tokens.

I would appreciate any suggestions on how to update the model to work with the code (I have updated the tables for all of the 2HL stops) and how to incorporate the counter (this way, I can work around the problem of releasing a single token from the batch and having the equipment continue).

Thanks again!

0 Likes 0 ·
Joshua S avatar image Joshua S Marzanne commented ·

Sorry, I changed some of the code without actually trying to run it so that is why it wasn't working for you, the code should look like below now:

Object current = param(1);
treenode activity = param(2);
Token token = param(3);
int stream = getstream(activity);
double randomnum = uniform(0, 100, stream);
double total = 0.0;
string Tab=token.TableStop;
for(int i=1;i<=Table(Tab).numRows;i++)
{
		total+=Table(Tab)[i][1];
	if (randomnum<=total)
	{
		return Table(Tab)[i][2];
	}
}
return 1;
0 Likes 0 ·
Marzanne avatar image Marzanne Joshua S commented ·

Joshua,

I think you almost got it the second time around! I have been able to make all of the necessary corrections on my model in regards to the batching, but for some reason the delay activities with your custom code weren't working and resources weren't being acquired at all.

I am very proud of myself for being able to debug code with my limited experience. In the line after the "for" loop begins, I changed the + to an = so that it reads "total==Table(Tab)[I][1];", and it seems to be working as expected now.

If this is incorrect, please let me know, and thank you again for all of your help!

0 Likes 0 ·
Show more comments