Cycletime in server

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
WUR
Posts: 21
Joined: Monday 10 June, 2013 - 14:14

Cycletime in server

Post by WUR »

I am simulating a supply chain of fresh lettuce.
Now at the end I have a server as retailer and I want to integrate the sales pattern of products, because at the start of the week less is sold than at the end.
(m=12%, t=11%, w=12/5%, do 16% of total sales etc.)

I have a time schedule and availability control to simulate the opening hours of the shop.
Monday = 8-20
Tuesday = 32-44 etc.

I have a Parameter in the parameter table as total sales (Parameter (23,1))

How can I say in 4D script (Cycletime of server) that for monday:
NegExp(mins(480/(0.12*(Parameter(23,1)))))

But for Tuesday:
NegExp(mins(480/(0.11*(Parameter(23,1)))))

The IF function is only for 2 options, right?
So, should I use than more servers? For different days?
marlies
Posts: 301
Joined: Monday 17 January, 2011 - 09:28

Re: Cycletime in server

Post by marlies »

Hi,

I suggest to use the case statement, which is like an if statement with more than 2 options. For example like this:

Code: Select all

Case(
 { returning the day of the week }
 dayofweek(time),
 { case 1: monday }
 NegExp(mins(480/(0.12*(Parameter(23,1))))),
 { case 2: tuesday }
 NegExp(mins(480/(0.11*(Parameter(23,1))))),
 { case 3: wednesday }
 NegExp(mins(480/(0.11*(Parameter(23,1)))))
 { etc. }
)
Regards, Marlies
WUR
Posts: 21
Joined: Monday 10 June, 2013 - 14:14

Re: Cycletime in server

Post by WUR »

Thanks for your quick reply Marlies!
I'm not familiar with this case function.
I wrote the 4D script as shown in this message, but received an error message when clicking on OK.
Maybe I have to label something? Or put someting wrong? I don't know.
Could you please take a look at my 4D script now?

Case(
{ returning the day of the week }
dayofweek(time),
{ case 1: monday }
NegExp(mins(480/(0.12*(Parameter(23,1))))),
{ case 2: tuesday }
NegExp(mins(480/(0.11*(Parameter(23,1))))),
{ case 3: wednesday }
NegExp(mins(480/(0.125*(Parameter(23,1))))),
{ case 4: thursday }
NegExp(mins(480/(0.16*(Parameter(23,1))))),
{ case 5: friday }
NegExp(mins(480/(0.255*(Parameter(23,1))))),
{ case 6: saturday }
NegExp(mins(480/(0.23*(Parameter(23,1))))),
)

Kind regards,
Wur
marlies
Posts: 301
Joined: Monday 17 January, 2011 - 09:28

Re: Cycletime in server

Post by marlies »

Hi,

I guess it's the comma behind the saturday option. You'll never use a comma directly before a closing bracket.

Regards, Marlies
WUR
Posts: 21
Joined: Monday 10 June, 2013 - 14:14

Re: Cycletime in server

Post by WUR »

Ah, yes thanks!
Stupid small mistake; large impact ;)
WUR
Posts: 21
Joined: Monday 10 June, 2013 - 14:14

Re: Cycletime in server

Post by WUR »

Hi Marlies,

I've a small problem with inserting the case-formula we discussed a few weeks ago. When I'm entering it, my clock doesn't work anymore ...
When I delete it and put a normal cycletime in it like (hr(1)) then it is OK.
Do you know what the mistake could be?

Kind regards
WU R
marlies
Posts: 301
Joined: Monday 17 January, 2011 - 09:28

Re: Cycletime in server

Post by marlies »

Hi,

I don't know. The code in some of the previous posts didn't contain an option for the sunday, did you add that in the meantime?

Otherwise it would help if you attach a small model with the code that you're currently using, than I can check what's happening.

Regards, Marlies
WUR
Posts: 21
Joined: Monday 10 June, 2013 - 14:14

Re: Cycletime in server

Post by WUR »

When I made it in another file it works, so I saved it twice and delete all my other atoms to keep it small. As you can see the store is opened from 8am. Then consumer demands occurs, however far too much as indicated and the clock stops.

There should be sold 22.68 products on Monday (integer 23)
-> 0.12 * 189 = 22.68
Interarrival time should be 480(0.12*189)= 21.64 minuts
-> 480 min store opened and 12% of the weekly sales is demanded

Or is it better to provide a mean for every day in the table.

I also have to include a 11% variation on the demand. However, the demand should be integer, not half clients or something. Is it possible to make the normal function integer?

Thanks in advance for your time and advice!
Kind regards
Attachments
Example.mod
(40.62 KiB) Downloaded 290 times
marlies
Posts: 301
Joined: Monday 17 January, 2011 - 09:28

Re: Cycletime in server

Post by marlies »

Hi,

I edited your model a little bit:

- Dayofweek returns 1 for sunday, 2 for monday etc. So, the case statement needed to be changed a bit.
- Just using dayofweek(time) will be counted as the time since 12:00 am, December 30, 1899. Therefore it's better to define a basetime first (see help for the explanation of basetime). I did this in the initialize atom that is now part of the model.
- The dayofweek now takes the time since basetime. It makes it easier for you to control the day of the week in the simulation.

- I selected the option 'pack contents' on the assemlber, otherwise the sendto statement makes no sense.

- To get integer results you could round the result of the normal function using the command round(), others are trunc() or ceil()

Regards, Marlies
Attachments
Example.mod
(41.87 KiB) Downloaded 284 times
Post Reply