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.

Kavika F avatar image Kavika F ♦ commented ·
Hey @Laurentius, do you have a sample model you could attach that his your concept outlined a bit? Thanks.
0 Likes 0 ·
Laurentius avatar image Laurentius Kavika F ♦ commented ·

Hi @Kavika F, here I've attached my sample model.

Prevent Start.fsm

I don't want Station A to process new objects if the object cannot be completed at Station E on the same day (I set the working hours to end at 10 p.m.). So, there won't be any object left in any machine overnight.

0 Likes 0 ·
prevent-start.fsm (29.8 KiB)
Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

Hi @Laurentius, was our answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes 0 ·

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:

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.

Table stops=Table(getvarnode(current,"table"));
double tablenow=stops[tablerow]["Time"]+stops[tablerow]["Duration"];  //check
double repeattime=getvarnum(current,"repeattime");
double stopend=tablenow;
double nextstop=0;
int nextstate=0;
int searching=1;
int looped=tablerow==stops.numRows;
int firstcheckrow=(tablerow==stops.numRows)?1:tablerow+1;
for (int nextrow=firstcheckrow;searching;nextrow++){
    if (nextrow>stops.numRows){
        looped=1;
        nextrow=1;
    }
    nextstop=stops[nextrow]["Time"]+looped*repeattime;
    nextstate=stops[nextrow]["State"];
    if (nextstop!=stopend)
        break; //searching=0;
    stopend=nextstop+stops[nextrow]["Duration"];
}
double nextModelStopTime=time()+nextstop-tablenow-looped*getvarnum(current,"modelstarttime");
print("Row:",tablerow, current,"next stop:", nextModelStopTime);
downobject.nextstop=nextModelStopTime;
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:

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

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.

Laurentius avatar image Laurentius commented ·

Hi @Jason Lightfoot thanks for your answer. Please if you don't mind, I'm waiting for your model to make it clear.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Laurentius commented ·
Will post as soon as it's fixed.
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Laurentius commented ·
Updated the post.
0 Likes 0 ·
Laurentius avatar image Laurentius Jason Lightfoot ♦♦ commented ·

Hi @Jason Lightfoot,

So sorry for my late response. I've tried working on your suggestions but it still doesn't work. I'm still confused about where to put the code.

Would you mind to share your model so I can check it out? Also see whether my needs can be fully met with your modeling. Thanks in advance

0 Likes 0 ·
Show more comments