News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

Relation of factories and passengers/mail reworked

Started by Dwachs, April 04, 2011, 06:33:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dwachs

As you may have noticed, there was a major change mde by Knightly some days ago. There is also a historic discussion related to this: http://forum.simutrans.com/index.php?topic=1638.0 .

The main part is: arriving passengers and mail at factories may boost production / consumption. In addition, factory production may increase over time (if factorory is producing).

A secondary change: passenger and mail level at factories needs now to be specified in absolute numbers. That is, how many workers does the factory need per month and production.

There are also some related gui changes: a new factory statistics window (button in factory window), goods going to factories are shown to have their destination at the factory (and not at the stop nearest to the factory).

New dat-file parameters for factories (need new makeobj...)
Parameters related to base production increase for producing factories

# Probability that production increases (same meaning as probability_to_spawn for fields)
# a value of 10000 (or more) equals  100 % probability
expand_probability = 10
# Minimum amount production increases
expand_minimum = 10
# Additional randomized increase will be in the range 0 .. expand_range-1
expand_range = 10
# How often production can be increased
expand_times = 1
# all these parameters default to 0 if not supplied

Parameters for electricity based production boost

# Increase of production in permill if electricity demand is supplied
electricity_boost = 1000
# Max electricity per production unit consumption
electricity_amount = 65535
# (default values are 1000 and 65535)

Parameters for passenger and mail related demand and production boost

# Demand on passengers and mail per production unit and time
# default values are 65535 (fall back to old behavior)
passenger_demand = 65535
mail_demand = 65535
# if these demand figures are not supplied, then passenger_demand = pax_level, mail_demand = pax_level / 4 is taken
#
# Increase of production in permill if passenger / mail demand is supplied
passenger_boost = 0
mail_boost = 0


I would be glad if someone could add this to the wiki.

Enjoy!

Parsley, sage, rosemary, and maggikraut.

Combuijs

QuoteAs you may have noticed, there was a major change mde by Knightly some days ago

Ah, so Knightly has not stopped working for Simutrans. That's good news. I wish he would come back to the forums as well. He was a good contributor to the discussions.

Nice change by the way, good compatibility with older situations, only a bit worried about micromanagement.
Bob Marley: No woman, no cry

Programmer: No user, no bugs



VS

So, factories could improve... hmmm... more numbers to push on poor players... ;D

Knightly, if you see this, thanks!

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

jamespetts

This is very interesting. I haven't had time to review the code in detail, so some questions, if I may:

1. Will the increase in production still be within the factory's pre-set production "range"? Is this "range" value still used?

2. Will there be an announcement that production has increased?

3. Does "expand_times" specify a factory lifetime number of production increases?

4. If the factory expands production after passengers are supplied, and then passengers stop being supplied, does the production revert to its previous levels? If not, are there any anti-exploit mechanisms?

5. For an expand_probability of 100%, over what period of time is there a 100% probability that production will expand?

6. How does the specification of passenger/mail numbers in absolute terms interact with the passenger factor setting in simuconf.tab?

7. What exactly does "Max electricity per production unit consumption" mean? Does this allow adjustment of the electricity demand per production unit (and is thus equivalent to Experimental's "electricity_proportion" parameter?

8. How do "passenger_boost" and "mail_boost" interact with the expansion of production events?

9. How do "passenger_boost" and "mail_boost" interact with the "range" parameter for production?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

TurfIt

1. No. Range still used in setting the base production upon factory creation.
2. No. Probably should be though...
3. Yes.
4. Factory expansion is separate from the passenger/mail boost. A steady supply of passengers/mail is needed to maintain the boosted production. Expansion is a permanent increase.
5. Same as for fields being added.
6. Factory demands do not scale with the passenger_factor setting. Surplus factory destined passengers/mail (in excess of the specified demand amounts) are redirected to a destination within their source city.
7. Don't know where that came from. The intent of the electric_amount parameter was to directly specify the electricity demand or production of the factory.
8. They don't.
9. They don't.

Also, pax_level parameter is no longer used if the new passenger_demand and mail_demand parameters are specified.
For old paks without the new parameters, simuconf.tab new setting factory_enforce_demand=0 will provide similar to the past behaviour.

jamespetts

Thank you very much for your helpful responses. One concern arising out of that is the de-coupling of passenger demand and the passenger factor setting. You have explained how it works when the factory demand is lower than the passenger factor setting might imply, but what of the case when the factory demand is higher than is commensurate with a passenger factor setting specified in simuconf.tab? I am worried that this setting might unbalance a game's passenger settings. One thing that might work is to take the new number for passengers/mail and multiply it by 16 / the passenger factor (that is, 1 where the passenger factor is the default 16). That way, the number of passengers generated by industry would scale exactly with the other passengers in the game, avoiding imbalances.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

wlindley

Would the internal "productivity factor" that leads to factory expansion, also be a reasonable substitute for the algorithm in Experimental that causes factories to close?  It would be more logical if factories that were doing well would tend to stay open, and factories that are doing poorly would be the ones tending to close.

TurfIt

Quote from: jamespetts on April 05, 2011, 02:12:56 AM
but what of the case when the factory demand is higher than is commensurate with a passenger factor setting specified in simuconf.tab? I am worried that this setting might unbalance a game's passenger settings.
passenger_factor controls the total number of passengers available relative to the world population.
factory_worker_percentage controls how many are destined for factories - the supply.
If factory demand > supply, the full specified boost can't be achieved. As the connected cities grow, the supply grows too increasing the factory production.
If factory demand < supply, factory_worker_percentage is effectively reduced as pax are redirected.



Dwachs

Quote from: wlindley on April 05, 2011, 02:18:56 AM
Would the internal "productivity factor" that leads to factory expansion, also be a reasonable substitute for the algorithm in Experimental that causes factories to close?  It would be more logical if factories that were doing well would tend to stay open, and factories that are doing poorly would be the ones tending to close.
This internal factor is more like a flag to indicate 'factory currently producing', ie to trigger smoke, spawn new fields and increase production.
Parsley, sage, rosemary, and maggikraut.

uci

In order to benefit right from the beginning of the passenger/mail boost mechanism, without changing every factory source in a pak, I would suggest to consider nonzero default values for these parameters, something like

passenger_boost = 400
mail_boost = 100


prissi

No, the default value was for paks which were balanced without this in mind. And pak64 will have a boost only for selected factories. Why should a forest grow faster when it gets mail?

Djohaal

Quote from: prissi on April 16, 2011, 07:05:47 PM
No, the default value was for paks which were balanced without this in mind. And pak64 will have a boost only for selected factories. Why should a forest grow faster when it gets mail?

The mail is magic fertilizer in disguise! :p

jamespetts

#12
Or maybe they send the fertiliser through the post? ;-)
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

cfds

This new model would also solve a problem from the German forum: It allows for electricity-intensive industries like aluminium extraction.

colonyan

Nothing particular to add for moment but I will take time to say this.
Thank you very much for adding this wonderful new feature to Simutrans.
Also good to see this made into trunk.

Does Knightly or Dwach have idea to expand on this kind of feature in future?

paco_m

Thanks for this great expansion, I'll try around with it - maybe this weekend ;)

Severous

Hi.

This feature is present in the latest release V111 and for the first time was an important factor in a scenario.

I do not understand the code used above.  If I ask questions of a gaming nature could someone answer to help me understand correctly please?

1) Are Mail and Passenger bonuses worked out in the same way?

2) Why will my industry have a higher mail production bonus than passenger production bonus?  Both bonus seem to be in effect.

3) Where do I have to deliver the passengers? To any stop which has the industry in its area, anywhere in the city, 8x8 radius of the industry?

4) If I make one station cover a whole city and the industry (expand with many bus stops) does that allow passengers walk within city - would that 'deliver' the passengers for the purpose of industry production increase?

5) Does 10 passengers delivered add 10 to production rate? Is the extra 10 produced immediately?

6) If I ran out of raw materials so couldn't produce, would any passenger and mail supply be remembered? So that production would resume at higher levels as soon as materials were supplied?

7) When an industry is supplied with materials the amount of material stored for later use is shown.  Are supplied passengers and mail shown in the same way?  How will I know when they have run out? How do I know they are about to run out?


Thanks for any explanations.
Regards
Sev.

prissi

1) & 2) can be queried in the statistics window of a factor. If the mail boost value is 10% then by mail only 10% boost can be achieved if the demand is met.

Think for instance of a newspaper: Mail is very important for buisness, thus it will need lots of mail. Also less factories need mail, thus the remaining factories will have it easier to satisfy their demand.

3) The industry need to be connected to the stops, as written in the info window.

4) Yes

5) No, id depends of the demand; if the demand is 50, then those will add 20% boost (of passenger boost is 100%) or 40% if boost factor is (200%)

6) Partly, but not for very long.

7) Since those increase only production they are not shown. If I rember correctly, they are present for about 1/4 month in the current bits_per_month=20 setting.

VS

Something important is missing from this discussion, so I'll add it here for discussion before wikifying - powerplant behaviour.

Suffix "kraftwerk" keeps its function, BUT one has to specify the generated power in electricity_amount. The number given there is the same as for consumption, and is shown as megawatts.

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

prissi

pak64 did not defined this and still gets electricity like the nominal (bits_per_mont=18) production, as intended.

jameskuyper

Quote from: Dwachs on April 04, 2011, 06:33:18 PM

# Increase of production in permill if electricity demand is supplied
electricity_boost = 1000
# Max electricity per production unit consumption
electricity_amount = 65535
# (default values are 1000 and 65535)

The electricity amounts seem huge - could there be a scaling factor of say, 1000 involved? I suppose if it if multiplies both producers and consumers, it's a wash.
Does the default electricity_amount of 65535 mean the same thing as it does in the demands for passengers and mail: "fall back to old behavior"? If so, what was the old behavior?

prissi

The electricity default is the fallback to the old behaviour, i.e. consume in proportion to the companies productivity (which is randomly set at contruction).

jameskuyper

Well, the new behavior also produces electricity consumption proportional to productivity. I presume that the difference is that the proportionality factor used to be a constant? If so, what was that constant?

DrSuperGood

Electricity is defined by values specified in the pakset. If no such values are specified then automatically computed default values are used. An example of specified power consumptions is pak128 where many factories like forests consume no power at all while power stations output huge amounts of power. An example of computed power is pak64 where the Coal Mine factory can use more power than a Coal-Fired Power Station can provide due to its huge production.

Electricity is then scaled by factory base production. This is because factory production is subject to random variance so some attempt is made at equalizing power per unit here.

In JIT0 and 1 modes the electricity used does scale with base production but does not scale with actual work done. A factory or producer will consume full power if any output is less than 75% full. A consumer will consume full power if any input is working. Only electricity producers factor in boost amounts with their electricity production. Electricity consumers do not factor in boosts meaning that they become more energy efficient the larger the power, mail and passenger boosts they have. In a game with all industries connected to the same power network and being used one may expect peak loads to massively overload the power network with massive continuous fluctuations as factories turn power consumption on and off.

In JIT2 mode the electricity used scales with work done. A factory will only consume full power if all outputs are being fully utilized. A consumer will only consume full power if all inputs are being fully utilized. Boosts factor into both electricity producers and consumers meaning that electricity cost per unit of work done remains constant. In a game with all industries connected to the same power network and being used one may expect a constant power usage with only a few % variation in load as long as all factories are well supplied and there may even be enough power for everything.

There is a minor bug with JIT2 power logic in the current release causing consumers and producers to have slightly incorrect power amounts (off by a small amount with 1 MW noise). There is also a bug in the power network logic causing oscillations in power supply. Both are fixed in nightly builds.

TurfIt

Quote from: jameskuyper on November 25, 2015, 05:07:16 PM
Well, the new behavior also produces electricity consumption proportional to productivity. I presume that the difference is that the proportionality factor used to be a constant? If so, what was that constant?
If electric demand is not specified (=65535), the old behaviour results in demand equal to productivity for loads, and 4 times productivity for generators. There is a 16 factor between displayed productivities and the displayed MW values.

DrSuperGood

QuoteThere is a 16 factor between displayed productivities and the displayed MW values.
Logically this means that power is internally a fixed point fraction. I am not sure if people were unaware of fixed point when writing the code (stumbled into the domain) or if they were so used to them they did not bother to clarify when they were used.

jameskuyper

Quote from: TurfIt on November 25, 2015, 06:28:29 PM
If electric demand is not specified (=65535), the old behaviour results in demand equal to productivity for loads, and 4 times productivity for generators. There is a 16 factor between displayed productivities and the displayed MW values.
I'm glad I asked. I'd been guessing that Prissi might have simply used "proportional" when "equal" would have been equally correct and more specific. Since the only factories with unspecified electric_amount on my current map are loads, that would have given me the correct answer, but if I ever needed to use a generator with electric_amount unspecified, I would have been really confused.

Ters

Quote from: DrSuperGood on November 25, 2015, 07:18:50 PM
Logically this means that power is internally a fixed point fraction. I am not sure if people were unaware of fixed point when writing the code (stumbled into the domain) or if they were so used to them they did not bother to clarify when they were used.

Even when being aware of fixed point, one still has be know / figure out what kind of fixed point. Simutrans has many varieties, both binary and decimal. This makes for a lot of "fun" when they meet in a single formula, such as in the speed bonus calculation.

DrSuperGood

QuoteEven when being aware of fixed point, one still has be know / figure out what kind of fixed point. Simutrans has many varieties, both binary and decimal. This makes for a lot of "fun" when they meet in a single formula, such as in the speed bonus calculation.
Generally it is a good idea to stick with binary fixed point. This is because the division and multiplications involved with scaling the number can optimize to bit shifts which in theory should be faster.

Apparently one can make readable and well optimized fixed point implementations using templates to provide the scaling information at compile time. I am unsure what C++ standard is required for the necessary template functionality however, since many features of templates are added in newer and currently unsupported by Simutrans versions of C++.

Ters

Modern currencies are pretty much by their very definition in decimal fixed point. I don't think changing that will make things clearer, nor that they a bottleneck. Percentages is the other decimal fixed point value in Simutrans that I know of.

I think any C++ capable of doing templates like Simutrans already have, should be able to make templated fixed point types as far as I know. Whether all compilers really manage to generate as optimized machine code as when one just uses a naked primitive, is what I'm more unsure of. They ought to, because it isn't that difficult.