The International Simutrans Forum

PakSets and Customization => General Resources and Tools => Topic started by: Flemmbrav on February 02, 2020, 05:32:37 PM

Title: Searching for the formula of the speedbonus
Post by: Flemmbrav on February 02, 2020, 05:32:37 PM
Hello,
I've been doing some research on this but did not end up finding it. Would love to know how to calculate and I can't really get behind it sadly.
Title: Re: Searching for the formula of the speedbonus
Post by: Andarix on February 02, 2020, 06:41:51 PM
https://sourceforge.net/p/simutrans/code/HEAD/tree/pak64/vehicle/ (https://sourceforge.net/p/simutrans/code/HEAD/tree/pak64/vehicle/)

in the cars.xls the column Income1/Income2
Title: Re: Searching for the formula of the speedbonus
Post by: Ters on February 03, 2020, 06:59:56 AM
The formula I've dug out of the code contains an unexplained division by three not reflected in that Excel file. Also, that Excel file doesn't explain some of the inputs to the formula, all of which are pak set dependent in one way or another. (The columns labeled income are also actually profits, since running costs are subtracted.)
Title: Re: Searching for the formula of the speedbonus
Post by: Leartin on February 03, 2020, 07:57:56 AM
Formula in that file: "=(1+((100*D2/Q2)-100)*(R2/1000))*(D2/100)"
D2 is max vehicle speed, Q2 the required speed of the speedbonus at vehicle introduction, and R2 the given bonus.

To go through it step by step:

Compare the speed you can reach with the speed you should reach.
Multiply by a hundred and subtract a hundred. Therefore, you get a negative value if you don't reach the required speed.
Multiply by the bonus value in promille. Therefore, the higher the bonus, the more effect.
Add one. This represents the base value that gets altered by the speedbonus.
- so far, so good.
But why multiply by the vehicles speed/100? That would mean even if the vehicle goes faster than the speedbonus requires, as long as it goes under 100km/h, it might still gain less than the base value...
Title: Re: Searching for the formula of the speedbonus
Post by: Andarix on February 03, 2020, 10:20:00 AM
Quote from: Ters on February 03, 2020, 06:59:56 AM
The formula I've dug out of the code contains an unexplained division by three not reflected in that Excel file. ...

This is probably related to the information in the goods files. There masn specifies 3 times the price.
Title: Re: Searching for the formula of the speedbonus
Post by: DrSuperGood on February 03, 2020, 10:33:26 AM
I have mentioned it several times and the revised speed bonus dialog should make it very clear what is happening (if I ever committed it, I forget).

Speed bonus is percentage bonus income per 10% faster maximum speed than current average speed.

Say the average speed is 100 km/h, the maximum speed of the vehicle is 200 km/h and the speed bonus is 5%.

200/100 = 2: The vehicle is twice the average speed.
2 - 1 = 1: The vehicle is 100% faster than the average speed.
100 / 10 = 10: The speed bonus is multiplied by 10 times.
5 * 10 = 50: The speed bonus total is 50%.
100 + 50 = 150: The per km earned for the good is 150% of its base.
If the good is worth £1.00 per km, then it is worth £1.50 per km due to speed bonus.

This also works for negative speed bonus. The only difference is that the minimum value of a good is capped at some nominal amount (cannot go negative).
Title: Re: Searching for the formula of the speedbonus
Post by: Leartin on February 03, 2020, 10:52:08 AM
So...
V = Max speed of the vehicle
A = Base speed set for a specific year
B = Speedbonus of a good in question

((V/A)-1)*10B+100 for the value in percent?
((V/A)-1)*(B/10)+1 for the value as a multiplier?

Title: Re: Searching for the formula of the speedbonus
Post by: DrSuperGood on February 03, 2020, 06:06:10 PM
Quote from: Leartin on February 03, 2020, 10:52:08 AM((V/A)-1)*10B+100 for the value in percent?((V/A)-1)*(B/10)+1 for the value as a multiplier?
Yes, assuming B is in %.
Title: Re: Searching for the formula of the speedbonus
Post by: Flemmbrav on February 05, 2020, 10:57:04 PM
Thanks a lot for all the help!