question

Laurentius avatar image
0 Likes"
Laurentius asked Jason Lightfoot commented

Prevent Processor from Starting New Process if it Won't Finish on the Same Day

Hello,


I am creating a model consisting of several processors (station A-B-C-D) with different runtimes to process in each processor. The model runs for 2 shifts per day. I am wondering how to prevent station A from starting a new process if it won't completed until station D on the same day.


Does anybody know how to achieve this or find a workaround?

FlexSim 22.0.16
timetablesstop inputnext stop time
· 3
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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot commented

I'm going to start by describing the general case for the timetable and how to access the time of the next stop.

In the timetable's resume function you have access to the tablerow of the table found at:

  1. Table(getvarnode(current,"table"))

1697199359319.png

This table currently tells you the time of day (in model units) of the stops - the first being at 10 hours - 36000 seconds, corresponding to this stop:

1697199401780.png

Since you know the stoppage row from which you are resuming you can determine the time of the next stoppage and write that onto your object. Then you can use that label to determine if you should close/stop ports or use some other mechanism to restrict the processing.

  1. Table stops=Table(getvarnode(current,"table"));
  2. double tablenow=stops[tablerow]["Time"]+stops[tablerow]["Duration"];  //check
  3. double repeattime=getvarnum(current,"repeattime");
  4. double stopend=tablenow;
  5. double nextstop=0;
  6. int nextstate=0;
  7. int searching=1;
  8. int looped=tablerow==stops.numRows;
  9. int firstcheckrow=(tablerow==stops.numRows)?1:tablerow+1;
  10. for (int nextrow=firstcheckrow;searching;nextrow++){
  11.     if (nextrow>stops.numRows){
  12.         looped=1;
  13.         nextrow=1;
  14.     }
  15.     nextstop=stops[nextrow]["Time"]+looped*repeattime;
  16. nextstate=stops[nextrow]["State"];
  17.     if (nextstop!=stopend)
  18.         break; //searching=0;
  19.     stopend=nextstop+stops[nextrow]["Duration"];
  20. }
  21. double nextModelStopTime=time()+nextstop-tablenow-looped*getvarnum(current,"modelstarttime");
  22. print("Row:",tablerow, current,"next stop:", nextModelStopTime);
  23. downobject.nextstop=nextModelStopTime;
  24. downobject.nextstate=nextstate;

Since this only happens when an object resumes you may need a method to put this value on the object when the model starts but since you're only concerned with the stop at the end of the day the break at 10:00 am probably isn't of concern.

All you need next is the expected or 95% makespan time to figure out if you have enough time to start an item.

If you only want to consider certain states then you can modify the code to check only for the offshift states, or you may find it easier to have the objects a member of production schedule and break schedule as two distinct timetables, in which case the logic above should work fine to tell you when the production time for the day will end, but you will may need the reset code below to set the label to show the first stop time:

  1. Object current=Model.find("Tools/TimeTables/TimeTable1");
  2. Table stops=Table(getvarnode(current,"table"));
  3. double modelStart=getvarnum(current,"modelstarttime");
  4. int n;
  5. for (n=1;stops[n]["Time"]<=modelStart;n++){1;}
  6. treenode memberlink=getvarnode(current,"members").first;
  7. while (memberlink){
  8.     Object member=ownerobject(memberlink.value);
  9.     member.nextstop=stops[n]["Time"]-modelStart;
  10. member.nextstate=stops[n]["State"];
  11.     memberlink=next(memberlink);
  12. }

You can put that code or something similar (more robust) in the onModelReset trigger.


1697199359319.png (7.1 KiB)
1697199401780.png (7.4 KiB)
· 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.