question

JIANYUAN, HALLEY L avatar image
0 Likes"
JIANYUAN, HALLEY L asked JIANYUAN, HALLEY L commented

Unable to pull with condition from global list

Hello all,

I am having trouble with a pulling condition: Table("GlobalTable1")[1][1] >= 1

I am setting up a model that runs after values are keyed into the global table via excel. Items would be sent to various queues and pulled to the processors. There is no problem with pulling from the global list as I am able to pull if condition is set to be "true" (as seen in queue3).

However, if I were to use the condition mentioned above, it would not work. The weird part is if I were to use the default Table("GlobalTable1")[1][1] == 1, the system works as well. Have I done something wrong? Please do advise if it is the case. If it is possible, please try not to use the tracked variable data as it would mess with the model runs.

Appreciate all help with this!

test-14.fsm

FlexSim 20.0.0
global tableitem flowpull from list based on condition
test-14.fsm (43.3 KiB)
· 6
5 |100000

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

Braydn T avatar image Braydn T commented ·

@JIANYUAN, HALLEY L

Where in your model is this pulling happening?

Matthew may comment in with a better solution, but my workaround would be to have some custom code above the pull from list that checks if that value is above your limit.

int value = Table("GlobalTable1")[1][1] >= 1;

if(value >= 1){

//do whatever you need

}

0 Likes 0 ·
JIANYUAN, HALLEY L avatar image JIANYUAN, HALLEY L Braydn T commented ·

@Braydn T

The pulling is happening in both processor 1 and 2 but none of them seems to be able to pull.

I've just tried your suggestion but it didn't work as well. Is the following code wrong? I've made some amendments since the >=1 doesn't seem to belong in the int assign.

int value = Table("GlobalTable1")[1][1];

if(value >= 1){//do whatever you need}

The exact codes are as below, but those are codes in the system and I didn't change them.

int value= Table("GlobalTable1")[1][1];
if (/** \nCondition: *//***tag:condition*//**/value>=1/**/) {
 int callbackCase = param(5);
 #define CALLBACK_CASE 10293
 treenode pulled = 0;
 if (callbackCase != CALLBACK_CASE) {
  string listName = /** \nList: *//***tag:listName*//**/"ItemList1"/**/;
  List list = List(listName);
  string queryStr = /** \nQuery: *//***tag:query*//**/"ORDER BY ageInQueue DESC"/**/;
  Variant partitionId = /** \nPartition ID: *//***tag:partitionId*//**/0/**/;
  int removeFromList = /** \nRemove From List: *//***tag:removeFromList*//**/1/**/;
  int addToBackOrders = /** \nAdd To Back Orders: *//***tag:addToBackOrders*//**/1/**/;
  pulled = list.pull(queryStr, 1, addToBackOrders ? 1 : 0, current, partitionId, (removeFromList ? 0 : LIST_DO_NOT_REMOVE) | LIST_RETURN_BACK_ORDER_IF_NOT_FULFILL);
  if (isclasstype(pulled, "ListBackOrder"))
   eventlisten(pulled, "OnFulfill", c, 0, LIST_ON_FULFILL_VALUE, 0, 0, 0, CALLBACK_CASE, current);
  else if (objectexists(pulled))
   pullitem(current, pulled, 0, BYPASS_ALL);
 } else {
  pulled = param(1);
  current = param(6);
  pushitem(pulled, current, 0, 0);
 }
}
return current.inObjects.length + 1;

0 Likes 0 ·
Braydn T avatar image Braydn T JIANYUAN, HALLEY L commented ·

@JIANYUAN, HALLEY L

I misunderstood where you wanted this. That looks like it should work to me. Should the items in Queue1 be pushed to a list? Because you are trying to pull from a list in the processor, but the items in queue1 are never pushed to a list.

0 Likes 0 ·
Show more comments

1 Answer

·
Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered JIANYUAN, HALLEY L commented

Processors 1 and 2 aren't pulling because the first time they try to pull your condition is false. So they don't pull any thing the first time. They never try to pull again because that code is only fired when the processors first become available to pull something.

Basically, this is an inappropriate case to use that condition field. You want your processors to wait for a certain condition to be met before pulling something, not try to pull and give up if the condition isn't met.

· 5
5 |100000

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

JIANYUAN, HALLEY L avatar image JIANYUAN, HALLEY L commented ·

Understood, so should I use While instead of if function? Or is there such a function in the system?

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ JIANYUAN, HALLEY L commented ·

Haha, NO, a while loop would cause an infinite loop and crash your model. You need to use one of FlexSim's built-in listening mechanisms: Wait for Event, Event-triggered Source, Pull from List, Acquire Resource, etc...

You're not approaching your model the right way and making the model logic more complicated than it needs to be. Several of us have tried to help you with this model across many different questions, but it's still very unclear what you're trying to do. That's the reason you're not getting the solutions from us that you're looking for. You have a vision of what your model is supposed to do, but it's never been fully or accurately communicated to us and so we're giving you incomplete answers.

0 Likes 0 ·
JIANYUAN, HALLEY L avatar image JIANYUAN, HALLEY L Matthew Gillespie ♦♦ commented ·

Oh, I know......

Actually most of the issues and explanation of the model have been done in this thread.

https://answers.flexsim.com/questions/81044/what-is-the-best-process-flow-model-to-resolve-thi.html

However, I had problem with replicating the model to the actual thing and I found an issue that would not let it function the way I wanted it to. However, no one answered yet and I don't have much time left to spend on developing the model with something less familiar and wanted to see if I could just go around the issue with just 3d modelling.

It seems as if there is no model that could handle the global table values being changed either after it hits 0 or I pause the model to update the values in the global table, which is important because there is insufficient vehicles (value) to transport the people (items) and outsider intervention would be needed to shift vehicles to the stations depending on the demand- mainly done with me changing values in global table before starting the run again.

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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