ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 04-09-2009
mariogib mariogib is offline
Flexsim User
 
Join Date: Jan 2009
Posts: 18
Downloads: 4
Uploads: 0
Thanks: 7
Thanked 0 Times in 0 Posts
Rep Power: 139
mariogib is on a distinguished road
Default to take from the rack

Hi All,
I have a model with source ->rack -> transporter->queue->sink. The transporter takes the items from the rack object. In the model the trasporter continuously draws from the rack object. I don't want that. What I need is the trasporter drew, for example every 800 seconds, a specified number of flowitems. The number of flowitems is variable ed it has, for example, mean=10 and standard deviation=3.

How can I realize that?

Thanks
  #2  
Old 04-09-2009
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

Mario,

You could try closing the output port on reset and then sending a delayed message everytime you want the transport to pull from the rack. The transport would have to have a max content greater than the maximum value you want. On the message you can set a label on the rack to the number of items you want to leave, send another delayed message to start the sequence again, and finally open the output port of the rack. Each time an item leaves you would increment a different label than before. then you would check to see if the labels were equal and if they were you would close the output port again.

This is off the top of my head so it may need some tweaking.

Good Luck,
Brandon
__________________
thats not normal.
  #3  
Old 04-09-2009
AlanZhang's Avatar
AlanZhang AlanZhang is offline
Flexsim Super Moderator
 
Join Date: Aug 2007
Location: CA
Posts: 289
Downloads: 64
Uploads: 0
Thanks: 88
Thanked 91 Times in 47 Posts
Rep Power: 225
AlanZhang is a jewel in the roughAlanZhang is a jewel in the roughAlanZhang is a jewel in the rough
Default

Mario,

I found this problem is interesting and just gave it a quick try. I found a solution. This is different from Brandon's solution and requires understanding of tasksequence in Flexsim. But once you know, the idea is simple.

Basically I create tasksequence to load/unload several items every time. When you open the attached model, take a look at the Operator's OnMessage trigger, in which I created tasksequence for Operators. In Operator's OnReset trigger, I kicked off the first move. And the only other place I changed is the Rack's Minimum Dwell Time, which I set to "Do not release items".

Hope this is helpful.

Alan
Attached Files
File Type: zip rack batch test.zip (37.8 KB, 306 views)
__________________
Best,
Alan
The Following User Says Thank You to AlanZhang For This Useful Post:
Tom David (04-10-2009)
  #4  
Old 04-10-2009
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

Mario,

A third solution is a combination of brandon's and alan's. You do not release the items when they enter the rack by selecting the "Do Not Release Items" option on the Dwell time. And then send a delayed message to itself and on the onmessage create a small for loop to release the right amount of items with the "releaseitem" command.

Steven
The Following User Says Thank You to Steven Hamoen For This Useful Post:
Tom David (04-10-2009)
  #5  
Old 04-10-2009
mariogib mariogib is offline
Flexsim User
 
Join Date: Jan 2009
Posts: 18
Downloads: 4
Uploads: 0
Thanks: 7
Thanked 0 Times in 0 Posts
Rep Power: 139
mariogib is on a distinguished road
Default

Brandon
I did not understand much. you can send me a template?
tanks
  #6  
Old 04-10-2009
mariogib mariogib is offline
Flexsim User
 
Join Date: Jan 2009
Posts: 18
Downloads: 4
Uploads: 0
Thanks: 7
Thanked 0 Times in 0 Posts
Rep Power: 139
mariogib is on a distinguished road
Default

Steven
I did not understand much. you can send me a template?
tanks

  #7  
Old 04-10-2009
mariogib mariogib is offline
Flexsim User
 
Join Date: Jan 2009
Posts: 18
Downloads: 4
Uploads: 0
Thanks: 7
Thanked 0 Times in 0 Posts
Rep Power: 139
mariogib is on a distinguished road
Default

Alan
in the your moel the operatorcontinuously draws from the rack. why?
I don't want that.
the model have a task error.
you can check?
thanks


  #8  
Old 04-10-2009
AlanZhang's Avatar
AlanZhang AlanZhang is offline
Flexsim Super Moderator
 
Join Date: Aug 2007
Location: CA
Posts: 289
Downloads: 64
Uploads: 0
Thanks: 88
Thanked 91 Times in 47 Posts
Rep Power: 225
AlanZhang is a jewel in the roughAlanZhang is a jewel in the roughAlanZhang is a jewel in the rough
Default

The model does not continuously draw items. It wait every 3 time units. You can change the following lines in the OnMessage trigger of the operator to have some other logic, say every 800 seconds.

Code:
// do next draw
double delayTime = 800;
inserttask(ts, TASKTYPE_SENDMESSAGE, current, NULL, 0, 0, 0, delayTime);
The model seems working fine on my computer. When do you get the error message?
__________________
Best,
Alan
  #9  
Old 04-10-2009
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default

Alan,

When I run your model, I also got a task error. I had a look into it and I guess it is that on the rack you did not choose "Do not release items", even if you said this in your post.
Still at the end if the rack is empty or nearly empty you get a task error. That’s strange, because you check if item exits, but I did not have a deep look into it, and just might have something overseen. I guess this error occurs because there is a check to fill the itemArray but none before creating the tasks.

I like your model and solution and the questions in my eyes is, if we need to post a perfect solution or if it is enough to give hints and help?
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."
  #10  
Old 04-11-2009
mariogib mariogib is offline
Flexsim User
 
Join Date: Jan 2009
Posts: 18
Downloads: 4
Uploads: 0
Thanks: 7
Thanked 0 Times in 0 Posts
Rep Power: 139
mariogib is on a distinguished road
Default

Alan,
I have Tom's problem too. I have selected “Do not release items” but the error message remains.
Moreover I have modified code inserting 800 but nothing has changed and the operator continuously draws from the rack object.
Why?
  #11  
Old 04-14-2009
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default

Mario,

I thought I already gave you the solution in telling that there is a check (if the item exists) to fill the itemArray, but not before creating the tasks. If you create a task with a bad pointer (in this case that the item does not exists) you get an error message.
If you have a look into the error message you posted you can see that the Involved 1 is NULL. That’s a bad pointer to a not existing item. So this item can not be loaded. I guess this happens if the rack is nearly empty.

In my eyes the model works find beside this issue. I guess that it looks like that the operator works continuously is because Alan gave him a very high speed. Change the speed of the operator and the run speed of the simulation and you will see that it works.
If you change the speed of the operator to a low speed than the rack will also not getting empty and you do not get the error message. :-)

Anyway, I had a short look into the code and I would make the check in the code before creating the tasks.
Just put a if(objectexists(itemArray[i]))
Before the inserttask for FRLOAD and FRUNLOAD and the error message will not occur any longer.

Code:
treenode ts = createemptytasksequence(current,0,0);
treenode rack = centerobject(current, 1);
int batchSize = normal(5,1);      // how many items will be draw every time
if(batchSize<1) batchSize = 1;
treenodearray itemArray = makearray(batchSize);
inti;
for(i=1;i<=batchSize;i++) {
      if(objectexists(rank(rack, i)))
            itemArray[i] = rank(rack, i);
}
inserttask(ts,TASKTYPE_TRAVEL,rack,NULL);
for(i=1;i<=batchSize;i++)
      if(objectexists(itemArray[i])) inserttask(ts,TASKTYPE_FRLOAD,itemArray[i],rack,1);
inserttask(ts,TASKTYPE_BREAK,NULL,NULL);
inserttask(ts,TASKTYPE_TRAVEL,outobject(rack,1),NULL);
for(i=1;i<=batchSize;i++)
      if(objectexists(itemArray[i])) inserttask(ts,TASKTYPE_FRUNLOAD,itemArray[i],outobject(rack,1),opipno(rack,1));
// do next draw
double delayTime = 3;
inserttask(ts, TASKTYPE_SENDMESSAGE, current, NULL, 0, 0, 0, delayTime);
dispatchtasksequence(ts);
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."
The Following 3 Users Say Thank You to Tom David For This Useful Post:
Roland Tainton (04-28-2009)
  #12  
Old 04-14-2009
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

Here is my model. Only code in: OnReset, Onmessage and dwelltime.

And to be honest, a lot less code then in the previous post!
Attached Files
File Type: zip Model for Mario.zip (66.7 KB, 266 views)
The Following 2 Users Say Thank You to Steven Hamoen For This Useful Post:
Roland Tainton (04-28-2009)
  #13  
Old 04-14-2009
RalfGruber's Avatar
RalfGruber RalfGruber is offline
FlexSim Software Products
 
Join Date: Jul 2007
Location: Orem, UT, USA
Posts: 195
Downloads: 37
Uploads: 0
Thanks: 518
Thanked 294 Times in 124 Posts
Rep Power: 345
RalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to behold
Default

One formal remark to keep the level of basic statistic knowledge in this forum:
You used the variable BatchSize type integer and set that to a value from a normal distribution, which is a continuous distribution. Doesn´t make a difference here but could confuse less experienced users.

Ralf aka ralle
Flexsim Germany
The Following User Says Thank You to RalfGruber For This Useful Post:
Carsten Seehafer (04-15-2009)
  #14  
Old 04-14-2009
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

Ralf, I did the same with my model. The question clearly stated a mean and a standard deviation. If you can give me statistic that returns an integer with those parameters I'm happy to use that.
So this solution is, I think, the easiest way and as far as I can think of now the only one with those parameters.

Good that you point it out though, but it is called casting (getting an integer from a double), which is a normal programming feature

Steven


PS you are on a holiday, get your butt of this forum
The Following User Says Thank You to Steven Hamoen For This Useful Post:
Carsten Seehafer (04-15-2009)
  #15  
Old 04-16-2009
AlanZhang's Avatar
AlanZhang AlanZhang is offline
Flexsim Super Moderator
 
Join Date: Aug 2007
Location: CA
Posts: 289
Downloads: 64
Uploads: 0
Thanks: 88
Thanked 91 Times in 47 Posts
Rep Power: 225
AlanZhang is a jewel in the roughAlanZhang is a jewel in the roughAlanZhang is a jewel in the rough
Default

Thank you David. I was in a hurry and did not run long enough time to check the model. You are right.

You modified code should work. However, I still get an invalid task one time. And I checked the item that the operator loaded is in the Flowitem Bin. I am not sure how that happen. But here is another slightly different solution, which may be safer than just using objectexists command.

Code:
/**Custom Code*/
treenode current = ownerobject(c);
treenode ts = createemptytasksequence(current,0,0);
treenode rack = centerobject(current, 1);
int batchSize = normal(5,1);    // how many items will be draw every time
if(batchSize<1) batchSize = 1;
treenodearray itemArray = makearray(batchSize);
int i;
int actualBatchSize = batchSize;
for(i=1;i<=batchSize;i++) {
    if(objectexists(rank(rack, i)))
        itemArray[i] = rank(rack, i);
    else{
        actualBatchSize = i - 1;
        break;
    }
}
inserttask(ts,TASKTYPE_TRAVEL,rack,NULL);
for(i=1;i<=actualBatchSize;i++) {
    inserttask(ts,TASKTYPE_FRLOAD,itemArray[i],rack,1);
}
inserttask(ts,TASKTYPE_BREAK,NULL,NULL);
inserttask(ts,TASKTYPE_TRAVEL,outobject(rack,1),NULL);
for(i=1;i<=actualBatchSize;i++)
    inserttask(ts,TASKTYPE_FRUNLOAD,itemArray[i],outobject(rack,1),opipno(rack,1));
// do next draw
double delayTime = 3;
inserttask(ts, TASKTYPE_SENDMESSAGE, current, NULL, 0, 0, 0, delayTime);
dispatchtasksequence(ts);
__________________
Best,
Alan
The Following User Says Thank You to AlanZhang For This Useful Post:
Roland Tainton (04-28-2009)
  #16  
Old 04-16-2009
AlanZhang's Avatar
AlanZhang AlanZhang is offline
Flexsim Super Moderator
 
Join Date: Aug 2007
Location: CA
Posts: 289
Downloads: 64
Uploads: 0
Thanks: 88
Thanked 91 Times in 47 Posts
Rep Power: 225
AlanZhang is a jewel in the roughAlanZhang is a jewel in the roughAlanZhang is a jewel in the rough
Default

Quote:
Originally Posted by Steven Hamoen View Post
Here is my model. Only code in: OnReset, Onmessage and dwelltime.

And to be honest, a lot less code then in the previous post!
Steve,

I like your model. It also demonstrate why there is a break task within the standard task sequence created for operators.

But if I change the delay time to a short time such as 2, I will get a lot of exceptions in the System Console and I have to quite Flexsim. I guess you need some sort of checking before the releaseitem command in the OnMessage trigger. But just using objectexists does not work. The reason is that when the next message is fired, the operator has not pick up the item yet. This will cause items being released by more than once. Maybe a flag to mark if the item is already released or not is required.
__________________
Best,
Alan
The Following 2 Users Say Thank You to AlanZhang For This Useful Post:
Tom David (04-21-2009)
  #17  
Old 08-05-2009
LINWEIXU
Guest
 
Posts: n/a
Downloads:
Uploads:
Default

AlanZhang you are right ,I chang code like this.
/**Custom Code*/
treenode current = ownerobject(c);


int Content = content( current );

//We sample the nr of items. We use the max because sample could be negative
//and negative nr's are not possible
int NrOfItems = max( 1, normal( 10, 3, 0) );

//Then we check only the max amount of products in rack
int Result = min( NrOfItems, Content );

//Then release the right amount of items
for( int x = 1 ; x <= Result ; x++)
{
addlabel(rank( current, x ),"rls",0);
if(getlabelnum(rank( current, x ),"rls")==0)
{
setlabelnum(rank( current, x ),"rls",1);
releaseitem( rank( current, x ) );

}
}

//And create this event again
senddelayedmessage( current, 1, current, 0, 0, 0 );
it works very well.
Attached Files
File Type: zip batch1.zip (64.9 KB, 199 views)

Last edited by Tom David; 08-06-2009 at 01:29 AM. Reason: Useless Quote
  #18  
Old 08-05-2009
LINWEIXU
Guest
 
Posts: n/a
Downloads:
Uploads:
Default

AlanZhang sorry , I still get an invalid task one time.

Last edited by Tom David; 08-06-2009 at 01:30 AM. Reason: Useless Quote


Thread Thread Starter Forum Replies Last Post
lifo fom a rack?? Kevin Baird Q&A 4 06-26-2008 04:23 PM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.