trigger on entry for assembler

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Mia
Posts: 6
Joined: Monday 15 June, 2015 - 11:51

trigger on entry for assembler

Post by Mia »

Dear Sir or Madam,

I'm a master student at Wageningen University and I'm using enterprise dynamics for my thesis project. Now i'm facing some difficulties for doing it.

I'm using Enterprise Dynamics for modelling discounting policy in supermarkets. in my model I have used the assembler atom for modelling consumers picking up pattern based on the different remaining shelf life. For example, I have coded the different consumer type and its demand at trigger on exit of the Source atom for consumer orders in my model. For type 1, it means the consumers always take the products with the longest shelf life first, and type 2 is another way around.

I also tried to write the code for assembler, in which i want to make it when the consumer type is 1, to choose products with 3 days remaining shelf life first then 2 days then 1 days. Then when consumer type is 2, it does it in another way around. Also in my model I have assumed that products from DC directly send to the 3 days remaining shelf life shelf, and after each supermarket opening day, the staff remove shelf 3 days to 2 days, and from 2 days to one days.

My problem is now, there is no products show at Queue atoms that represent shelves 2 days and 1 days. Also there is no products show up at the sink represent to lots sales and failed orders.

Can you please have a look at my model for me ?

Thanks a lot for your kind help

Mia
Attachments
coding-for-assembler.docx
coding for trigger on entry for assembler
(12.9 KiB) Downloaded 342 times
model..mod
(83.31 KiB) Downloaded 332 times
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: trigger on entry for assembler

Post by HarryBunnik »

Ha Mia,

When looking at your model there are a few things that I'm wondering about. First of all:

I see a process time on the DC order pick which is a normal distribution, which results in orders passing through with a negative process time. So I think that needs some adjusting, but it can be that this is still on your ToDo list ;-).

But to come to your problem. I would say that the moment a consumer arrives (Trigger on entry channel 1, where you already had placed code) you loop over the remaining incoming channels (from channel 4 downwards for consumer type 2 and upwards from 2 for consumer type 1).

Secondly you have to manipulate the B.O.M. to let the assembler understand that it needs also some fruit.

Code: Select all

Do(
  var([valFruitFound], vbValue), 
  
  LoopUntil(
    valFruitFound > 0,
    If(
      Label([ConsumerTpe], i) = 1, 
      If(
        Content(in(1 + count, c)) > 0, 
        valFruitFound := 1 + Count
      ), 
      If(
        Content(in(NrIC(c) + 1 - count, c)) > 0, 
        valFruitFound := NrIC(c) + 1 - Count
      )
    ), 
    NrIc(c) - 1
  ), 

  If(
    valFruitFound > 0,      {Fruit has been found}
    Do(
      {Manipulating the assembler}
      Cell(valFruitFound {Row in B,O.M.}, 1 {Col in B,O.M.}, c) := 1 {1 piece of Fruit}
    )
  )
)
I'm sure it will need some extra tweaking, but I hope it helps you a bit further!

Regards,

Harry
Mia
Posts: 6
Joined: Monday 15 June, 2015 - 11:51

Re: trigger on entry for assembler

Post by Mia »

Hey Harry,

Thanks for your kind reply, but I got confused about the code that you wrote. Can you maybe explain a bit to me, I'm still not so familiar with some expression in 4DS.

First about the vbValue, is it represent the available stocks amount on shelf? then I suppose that valFruitFound should be the demand from consumers. and I don't understand the NrIC(c), what does this mean?

and I still cannot really find why that in Queues of shelf-life 2 day and 1 day don't have any products after each opening day. Also when check the finished order Sink for customer order with lots sales, there is a difference that suppose to show in Sink failed order, but there is nothing in Sink failed order.

Also, about the cycle time in assembler DC order pick, you are right about the normal distribution. I just set this as a fixed figure now, because it's not something that I want to test with my model.

Hope that i don't bother you too much with those questions :)

Mia
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: trigger on entry for assembler

Post by HarryBunnik »

Ha Mia,

It's no problem asking questions. And I was skipping a few steps. ;-)

Code: Select all

var([valFruitFound], vbValue), 
This I use to declare a local variable. In this case a variable with the name valFruitFound and it contains a value (other possibilities are: vbAtom, vbString, vbConstant and some more obscure ones.)

Code: Select all

NrIC(c)
Is returning the number of incoming channels (in your case 4) of the current atom (c, "pick up customer orders"). In this case I used it in the LoopUntil as a third parameter to prevent a never ending loop. I can of course write 3 as a hard coded value, but if you then adjust the number of shelves, the code has to be changed. So I always try to avoid that.

The LoopUntil allows me to loop over the incoming channels of the "pick up customer orders" to check if one of them contains fruit the the customer is interested in (the first incoming channel is not of interest since it contains no fresh fruits). If I found a shelf containing fruit, I write it into my variable valFruitFound and use that to manipulate the B.O.M.


And now about your model. On the queue containing your products ("shelf-life 3 days") you've set the SendTo statement to all going through exit channel 1. And I think you want to send it to An Open Channel. Now it never checks if the second channel is open and whether it should (could) move that way. I did a quick test and that seems to help.

I hope it helps you again a bit further. :-)

Regards,

Harry
Mia
Posts: 6
Joined: Monday 15 June, 2015 - 11:51

Re: trigger on entry for assembler

Post by Mia »

Hey Harry,

Thanks for your explanation, I totally missed that send to rule for Queue, I forgot i should also adjust there. now I understand it better, but can I also name this local variable as valconsumer demand, so I can link it back to the Source Atom for consumer demand. Also, I wanted to also have a part that represent when there is no items available for consumers, then it is a shortage which will end up at the Sink for failed sale.

How can I code it based one ur coding for assembler? so when there is no fruit has been found that the order will show up in the Sink as failed order

Kind regards,
Mia
Mia
Posts: 6
Joined: Monday 15 June, 2015 - 11:51

Re: trigger on entry for assembler

Post by Mia »

Hey Harry,

Thanks for your explanation, I totally missed that send to rule for Queue, I forgot i should also adjust there. now I understand it better, but can I also name this local variable as valconsumer demand, so I can link it back to the Source Atom for consumer demand. Also, I wanted to also have a part that represent when there is no items available for consumers, then it is a shortage which will end up at the Sink for failed sale.

How can I code it based one ur coding for assembler? so when there is no fruit has been found that the order will show up in the Sink as failed order

Kind regards,
Mia
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: trigger on entry for assembler

Post by HarryBunnik »

Ha Mia,

You can name the variable as you want (no spaces and some other limitations with special characters...) I would start a variable with val, str, atm (valConsumerDemand (vbValue), strConsumerDemand (vbString), atmConsumerDemand (vbAtom)), so you can easily identify of which type the variable is. But that is more a coding convention.

In that case you send the order through with a demand (B.O.M.) of 0. This would mean that you have an empty order. If you then sort out all orders with a content(i) of 0 (so don't throw away products in the assembler) and route these to the sink "failed orders". That should work I think.

Regards,

Harry
Post Reply