News:

Simutrans Forum Archive
A complete record of the old Simutrans Forum.

Understanding JIT2 consumption-only factory behavior

Started by R1dO, June 10, 2019, 01:13:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

R1dO

Although I'm currently having quite some fun with a game using JIT2, it seems there are some concepts i lack understanding of. Hence this post.

In this case it is about a consumer 'factory' not consuming although it has quite some goods in it's internal storage (see attached image).
I guess this is because the printer works does not produce anything (since it is out of printer ink).
-> Is this intended behavior for JIT2 (asking because on first glance it seems kinda odd that the bookshop does not consume)

Related to this. As you can see the input storage of both factories are both at (or near) it's limit, this has a different effect on arriving goods based on the factory.
Whenever a new convoy of paper arrives it is all discarded (but payment is received for the trouble of transporting it, which is nice from a continuity perspective of the paperworks).
When a shipment of books arrive at the bookshop which would require more storage than available the excess books remain in the convoy (not discarded).
-> Is this also intended behavior for JIT2

Thanks in advance for your answers.

P.s. In the attached image the bookshop is the only connected consumer to the printerworks (furthermore it only has 1 producer for the ink and 1 for the paper).

makie

From my point of view:
A end consumer should consume at full speed until (his) internal storage is empty.
No mater, if the delivering factory can work or not.

Did I understand that correctly? jit = 2 stops the consumption, if the supplying factory can not work. Regardless of the stock in the incoming warehouse.

DrSuperGood

#2
Quote from: R1dO on June 10, 2019, 01:13:40 PMIn this case it is about a consumer 'factory' not consuming although it has quite some goods in it's internal storage (see attached image).I guess this is because the printer works does not produce anything (since it is out of printer ink). -> Is this intended behavior for JIT2 (asking because on first glance it seems kinda odd that the bookshop does not consume)
This is intended behaviour. Logically it is because the book shop has to close as it has effectively no suppliers so cannot make an estimation as to how much stock to put on shelves so as to remain open every day.

I do agree that the behaviour could be slightly better. I will think about making changes to it in the future.
Quote from: R1dO on June 10, 2019, 01:13:40 PMRelated to this. As you can see the input storage of both factories are both at (or near) it's limit, this has a different effect on arriving goods based on the factory.Whenever a new convoy of paper arrives it is all discarded (but payment is received for the trouble of transporting it, which is nice from a continuity perspective of the paperworks).When a shipment of books arrive at the bookshop which would require more storage than available the excess books remain in the convoy (not discarded).-> Is this also intended behavior for JIT2
Excess product is discarded since there is no space to store it. This was to try and discourage people delivering multiple years worth of supplies to a tiny corner shop with a 12 tile long train. This works well for most pak128 factories but not really for pak64 since the input storages are so low compared with end game transport options.
Quote from: R1dO on June 10, 2019, 01:13:40 PMWhen a shipment of books arrive at the bookshop which would require more storage than available the excess books remain in the convoy (not discarded).
This should not happen. The books are either destined for another stop, or this is a bug.

Ters

Quote from: DrSuperGood on June 12, 2019, 04:34:28 AMThis is intended behaviour. Logically it is because the book shop has to close as it has effectively no suppliers so cannot make an estimation as to how much stock to put on shelves so as to remain open every day.
I don't see why a book shop would rather close while they still have books, rather than wait until they are actually out of books. And it makes no sense for markets, where they realistically would have to sell the fresh food before it spoils.

R1dO

Thank you for your feedback @DrSuperGood. This really helps me in understanding the behavior of JIT2.
As for potential future improvement in this matter. That is off course up to you, i can only applaud it ;)

Quote from: DrSuperGood on June 12, 2019, 04:34:28 AMThis should not happen. The books are either destined for another stop, or this is a bug.
Turns out the bug was sitting in front of the screen.
I recently extended the station (to allow for a slightly bigger train) with two tiles from the wrong direction, creating 2 separate stations. The last wagon of the convoy was unable to unload. Something i missed initially.

Quote from: DrSuperGood on June 12, 2019, 04:34:28 AMExcess product is discarded since there is no space to store it. This was to try and discourage people delivering multiple years worth of supplies to a tiny corner stop with a 12 tile long train. This works well for most pak128 factories but not really for pak64 since the input storages are so low compared with end game transport options.
I understand your reason for discarding it. In this case i might have stumbled upon an unintended side effect.
By discarding the goods (while still paying for it) the paper line is allowed to keep operating. My guess is that the discarded goods lower the "in transit" value just enough so that that the paperworks will never cease to operate, so the line will keep transporting goods that are discarded upon arrival.
For what it's worth, i use "pay_for_total_distance = 1" in this game.

makie

Quote from: R1dO on June 12, 2019, 03:11:17 PMTurns out the bug was sitting in front of the screen.
I recently extended the station (to allow for a slightly bigger train) with two tiles from the wrong directio
I suspected that, I have never observed such behavior, unless the platform was too short. Good that you clear it up.
QuoteLogically it is because the book shop has to close as it has effectively no suppliers so cannot make an estimation as to how much stock to put on shelves so as to remain open every day.
That may explain the strange production breakdowns on my map with JIT2.
I have big factories and small markets. The big factories only need to work briefly to meet the needs of the small markets. If the small markets stop selling, if the factory does not work, then they almost never sell and therefore have hardly any consumption.

that should be changed

DrSuperGood

#6
Quote from: Ters on June 12, 2019, 08:40:06 AMI don't see why a book shop would rather close while they still have books, rather than wait until they are actually out of books. And it makes no sense for markets, where they realistically would have to sell the fresh food before it spoils.
Because it does not know how much to put on the shelves to remain open every day as it has no supply options. This means it does not know how much of the shop to corner off (to save power) as well as how many salesmen it needs to hire etc. In real life such a shop would be forced to close down due to lack of supply and the books being sold would likely be a clearance sale.

I do agree a more correct behaviour would be for it to try to guess how much to sell and ramp down until stock is 0. However this would need extra logic already complicating the code and was not considered when I first wrote supply limiting code.
Quote from: R1dO on June 12, 2019, 03:11:17 PMBy discarding the goods (while still paying for it) the paper line is allowed to keep operating. My guess is that the discarded goods lower the "in transit" value just enough so that that the paperworks will never cease to operate, so the line will keep transporting goods that are discarded upon arrival.
In transit is the number of goods in transit towards the factory. It is unrelated to discarded product. When all goods arrive they are all removed from the in transit amount irrespective of how many get discarded.

Every product discarded decrements the demand counter meaning that less will be ordered in total. This has at least a cost to the player of 100% of the wares discarded not being shipped. The cost is further amplified in intermediate factories by also meaning less product is produced and so less profit is earned shipping product. As such it is technically not exploitable since discarding no product will in theory earn more money than discarding any product. If this reflects pakset balance is another question.
Quote from: makie on June 12, 2019, 04:57:39 PMThat may explain the strange production breakdowns on my map with JIT2. I have big factories and small markets. The big factories only need to work briefly to meet the needs of the small markets. If the small markets stop selling, if the factory does not work, then they almost never sell and therefore have hardly any consumption.that should be changed
The big factories will work at a rate appropriate to shops connected to it. As long as the factory has sufficient storage in its output then all shops connected to it will be working at 100% efficiency. The exception is if you over supply the shops (overflow their input storage) in which case the shops will not order some product as penalty until their demand burns up the order penalty.

To make it clear how it works here is a brief explanation. The rate of production for a factory with a product is based on how full the output storage is. Shops always have 100% production as they have no output storage. Totally full means no production as there is a demand limit while less than 2 shipments means full production as there is no demand limit. This is then further limited by the rate of supply available for inputs for the factory (or shop). Each input has a hidden demand counter which represents how much the factory would like to buy. If the demand counter is 0 or negative then there is no supply limit and nothing currently wants to be brought. If it is some fraction of the input storage (I forget details, see source code) then it is limited by having no supply and a lot will want to be brought. The rate at which production occurs (amount consumed) is limited to the minimum of both supply and demand limit. Orders are placed for inputs to maintain the rate of production.

This means that a factory where little of its products are in demand will order little and a factory where one or more of its inputs are undersupplied will produce little. The result is that in both cases the factory will try to produce continuously at an appropriate rate for the supply of inputs or to meet the demand of consumers.

The issue with consumers is that under this logic their production rate of an input is determined by the supply limit of the input meaning that if the input is under supplied (maximum demand counter) the input will not be consumed even if stock is available. A sensible solution would be to allow consumption to still occur based on the current storage percentage (maximum of supply limit and stock limit) however this would require more, less general logic to implement in an already overly complex function.

In the original implementation there was no concept of "supply limit", with demand being the only limiting factor for production. The result was that under supplied factories or shops would pulse width modulate operation between off and maximum production to achieve similar results which played havok on managing an electrical network and organizing flows of transport. Yes there was no problem of bookshops sitting on stock not selling any of it but instead there were problems of bookshops burning through all stock very fast and then having nothing to sell for extended periods.

The input demand counters used to be visible. However the numbers were quite confusing and in the end of the day were not very meaningful to users as they represented how much the factory would like to buy and would frequently be negative when no supply limit is present. As such I replaced them with the @ percentage display we have now. When an input is @ 100% it means no supply limit is present while when it is @ 0% is means the supply is extremely limited (as good as nothing being shipped towards the factory). For factories with products the supply limit used to determine production is the minimum of all input supply limits, while with shops each supply limit operates separately. Like wise demand limits are represented by @ percentage on outputs, with @ 100% meaning no limit is present (all product being sold) and @ 0% meaning completely demand limited (no products being sold, storage full). Each output works separately from each other and the weighted average of the output demand limits is used to determine general factory production.

The implementation is excessively complex at the moment. I think the function is over 500 lines. Especially seeing how the same code also has to support JIT0 and 1 operation as well! It really needs another rewrite...

Leartin

Quote from: DrSuperGood on June 12, 2019, 10:28:01 PM
Because it does not know how much to put on the shelves to remain open every day as it has no supply options. This means it does not know how much of the shop to corner off (to save power) as well as how many salesmen it needs to hire etc. In real life such a shop would be forced to close down due to lack of supply and the books being sold would likely be a clearance sale.

Take any of the stores with several inputs. If they don't receive one of their inputs, they will sell the other stuff and are just out of stock for the rest.
Take any end consumer that isn't a store. A library could be end consumer to books, yet can operate without receiving new books. A waste incinerator would burn up what's there and then shut down completely.
Take a car dealership. In reality, it would often take used cars back as part of the payment for the new cars. Those will again be sold. The stock of used cars is never visible to the player, because the player has nothing to do with it. Furthermore, the dealership can still sell cars that are not made yet and operate for quite a long time without receiving a shipping.
Even with a one-input normal store, it makes no sense to hold goods back just because there is a shortage, unless you plan to sell them for a higher price. Rationing only makes sense if it's a crisis, eg. you are the only convenience store and there is no food delivery, but these things have no place in Simutrans.
Why would you ever tell a customer off if you could sell them what they want? What's the logic there? "Sorry, I already sold 3 books today, come back tomorrow - yes, I know the store is open, of course it is, I'm just not selling so I can sell it to you tomorrow. I randomly limit myself to 3 books a day because I don't know when a new delivery will come, if ever, and I rather have the store open every day and tell people every day they can't buy the goods I offer, since I don't want to come in a situation where I have to tell people I don't have the goods they want"
You only open yourself up to getting an unexpectedly early delivery with your storage still somewhat full of all the things you did not sell, but could have, which is a loss to you.

Ters

Quote from: DrSuperGood on June 12, 2019, 10:28:01 PMBecause it does not know how much to put on the shelves to remain open every day as it has no supply options. This means it does not know how much of the shop to corner off (to save power) as well as how many salesmen it needs to hire etc. In real life such a shop would be forced to close down due to lack of supply and the books being sold would likely be a clearance sale.
If it sells everything, it doesn't need to corner off anything, as the entire shop will be empty. All power can be saved, except maybe to keep the building from freezing over in winter. They also don't have to pay for insurance on the wares in store. The problem with the employees are the same irrespective of when income stops. Especially in Simutrans where industries don't die for any reason whatsoever.