Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Measure vehicle capacity utilisation efficiency #7353

Open
wants to merge 13 commits into
base: master
from

Conversation

@nielsmh
Copy link
Contributor

nielsmh commented Mar 9, 2019

Measure the capacity utilisation efficiency of vehicles by measuring the actual distance traveled, and multiplying by capacity. When deliveries are made, accumulate the cargo-distance delivered. (Distance delivered is the Manhattan-distance between source and destination.) Dividing cargo-distance delivered over capacity-distance traveled gives a utilisation efficiency.

A vehicle traveling full everywhere, by the shortest possible route, would have (near) 100% efficiency, while a vehicle traveling empty half the time (e.g. minerals train from mine to smelter) and going by a winding route might only hit 30% efficiency.

Vehicles waiting for their turn to load cargo are also counted as wasting potential capacity.

Overall the intention of this patch is to calculate a figure that might better indicate the economic viability of a vehicle than the simple profit-last-year figure. ("Is this vehicle actually doing something useful?") Part of the intention is as an alternative to the "false" profit sharing algorithm for feeder routes, especially the large negative profits it can apply to e.g. buses making the last leg from a long-haul air route, despite the buses actually being vital.

image

In addition to this (and this part should probably at the very least be split into a separate commit), the patch adds a new element to the company performance rating calculation, but with a switch so the performance rating uses either lowest vehicle profit, or lowest vehicle efficiency, as a measure for the rating, but not both.

To do:

  • Calculate cargo distance delivered on unload
  • Calculate tiles traveled as vehicles move
  • Add penalty tiles traveled when vehicles are idle loading
  • Add penalty tiles traveled when vehicles are waiting at signals/other
  • Show total efficiency per vehicle group
  • Make data available to GS and AI
@stale

This comment has been minimized.

Copy link

stale bot commented Apr 10, 2019

This pull request has been automatically marked as stale because it has not had any activity in the last month.
Please feel free to give a status update now, ping for review, or re-open when it's ready.
It will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added the stale label Apr 10, 2019
@planetmaker

This comment has been minimized.

Copy link
Contributor

planetmaker commented Apr 10, 2019

I don't think this should sink. It could be a nice goal for players and highscores / goals. It also gives increased purpose to versatile, refittable vehicles / wagons.

@stale stale bot removed the stale label Apr 10, 2019
@nielsmh nielsmh force-pushed the nielsmh:cargotiles branch from 831d4d7 to 56de944 Apr 10, 2019
@nielsmh

This comment has been minimized.

Copy link
Contributor Author

nielsmh commented Apr 10, 2019

Here's a rebase to current master for now. I think I'll take out the company rating stuff for now and just make the efficiency measurement something you can view and sort by, but not affecting the scoring. I'll rather address company ratings in a separate patch that could then also add GS custom ratings.

@planetmaker

This comment has been minimized.

Copy link
Contributor

planetmaker commented Apr 10, 2019

Here's a rebase to current master for now. I think I'll take out the company rating stuff for now and just make the efficiency measurement something you can view and sort by, but not affecting the scoring. I'll rather address company ratings in a separate patch that could then also add GS custom ratings.

That sounds actually like a good plan. It's two different things.

src/lang/english.txt Show resolved Hide resolved
@@ -3121,6 +3121,8 @@ bool AfterLoadGame()
}
}

if (IsSavegameVersionBefore(SLV_VEHICLE_CARGOTILES)) _settings_game.economy.idle_loading_ct_penalty = 2;

This comment has been minimized.

Copy link
@nielsmh

nielsmh Apr 10, 2019

Author Contributor

This is just the default value from settings.ini, maybe this conversion isn't strictly necessary?

This comment has been minimized.

Copy link
@LordAro

LordAro Oct 21, 2019

Member

Would've thought not necessary, yes

This comment has been minimized.

Copy link
@nielsmh

nielsmh Oct 22, 2019

Author Contributor

Based on experience from a different patch, without this the converted save will take the current newgame setting. I think I will slightly prefer removing this line, so the player's newgame preference is used.

src/vehicle_base.h Outdated Show resolved Hide resolved
@nielsmh

This comment has been minimized.

Copy link
Contributor Author

nielsmh commented Apr 11, 2019

Should penalty for waiting for load (without receiving cargo) and penalty for waiting at signals (and maybe also whatever road vehicles can wait at) be controlled by separate settings?

@nielsmh nielsmh force-pushed the nielsmh:cargotiles branch from e019d14 to 97f9f66 Apr 11, 2019
@nielsmh nielsmh force-pushed the nielsmh:cargotiles branch from 97f9f66 to 31ca7c5 Apr 27, 2019
@nielsmh

This comment has been minimized.

Copy link
Contributor Author

nielsmh commented Apr 27, 2019

I'm not entirely happy with the group GUI yet.

image

The extra lines in the group statistics (lower left) makes the window sizing somewhat awkward, and the extra text in the per-vehicle statistics makes the lines very long and may often clip.

@nielsmh nielsmh force-pushed the nielsmh:cargotiles branch from ac71ada to 9e8154e May 4, 2019
@nielsmh nielsmh force-pushed the nielsmh:cargotiles branch from 9e8154e to ba123b8 May 11, 2019
@nielsmh nielsmh force-pushed the nielsmh:cargotiles branch from ba123b8 to 68797a9 Jul 14, 2019
@nielsmh nielsmh marked this pull request as ready for review Jul 14, 2019
@nielsmh

This comment has been minimized.

Copy link
Contributor Author

nielsmh commented Jul 14, 2019

I'm marking this ready for review as I believe it's feature complete and basically correct. I'm still unsure about several of the GUI changes, and there may be some balancing required on the penalty for waiting.
The commit history also needs some squashing.

@nielsmh nielsmh force-pushed the nielsmh:cargotiles branch 3 times, most recently from 28a2c33 to c7e772f Sep 9, 2019
@LordAro LordAro removed the needs review label Oct 21, 2019
src/group_gui.cpp Outdated Show resolved Hide resolved
src/economy.cpp Show resolved Hide resolved
@@ -3121,6 +3121,8 @@ bool AfterLoadGame()
}
}

if (IsSavegameVersionBefore(SLV_VEHICLE_CARGOTILES)) _settings_game.economy.idle_loading_ct_penalty = 2;

This comment has been minimized.

Copy link
@LordAro

LordAro Oct 21, 2019

Member

Would've thought not necessary, yes

src/script/api/script_group.cpp Outdated Show resolved Hide resolved
src/script/api/script_group.cpp Outdated Show resolved Hide resolved
src/vehicle_base.h Show resolved Hide resolved
src/vehicle.cpp Outdated Show resolved Hide resolved
src/vehicle.cpp Outdated Show resolved Hide resolved
src/vehicle_base.h Outdated Show resolved Hide resolved
src/vehicle.cpp Outdated Show resolved Hide resolved
nielsmh added 6 commits Feb 2, 2018
This is calculated as the ratio of "ton-miles delivered" over
"ton-miles travelled". The former is calculated as amount of cargo
delivered multiplied by Manhattan-distance between pick-up and
delivery station, and the latter is total cargo capacity multiplied
by actual distance driven.

This rating favours vehicles running at close to capacity, with
more direct (less winding) routes.
@nielsmh nielsmh force-pushed the nielsmh:cargotiles branch from c7e772f to ff4dbdf Nov 30, 2019
@nielsmh

This comment has been minimized.

Copy link
Contributor Author

nielsmh commented Nov 30, 2019

This should address all the points. I intend to clean up all the small commits later, leaving them in for now for review purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.