I am modelling a job shop process and use the event block to generate orders for the order arrival process. In action of the event block, the due date of the generated order has to be specified. This value however is not fixed. It should either be 17:45:00 PM, 19:15:00 PM or 20:15:00 PM. However, the possibility that time 17:45:00 is chosen should be twice as likely as the chances for choosing the other two times. How can I define the due date of an order according to these conditions? My process looks like this
I first tried given the order a fixed due date, like this:
Order order = new Order(); // Set due date as fixed time Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY,17); cal.set(Calendar.MINUTE,30); cal.set(Calendar.SECOND,0); cal.set(Calendar.MILLISECOND,0); order.atrDueDate = cal.getTime(); // proc time for single orders order.varProcTime = triangular(1,2,3); order.markParametersAreSet(); enter1.take(order);
This works, but I do not know how to choose a due date from 3 different options.
Advertisement
Answer
This is not the optimal answer and there are more general ways of doing this, but a simple solution would be
if(randomTrue(0.5)){//50% chances of choosing this date cal.set(Calendar.HOUR_OF_DAY,17); cal.set(Calendar.MINUTE,45); }else if(randomTrue(0.5)){//25% chances of choosing this date cal.set(Calendar.HOUR_OF_DAY,19); cal.set(Calendar.MINUTE,15); }else{//25% chances of choosing this date cal.set(Calendar.HOUR_OF_DAY,20); cal.set(Calendar.MINUTE,15); }