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 2 commits into
base: master
Choose a base branch
from

Conversation

@nielsmh
Copy link
Contributor

@nielsmh 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
Copy link

@stale 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
Copy link
Contributor

@planetmaker 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
Copy link
Contributor Author

@nielsmh 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
Copy link
Contributor

@planetmaker 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
src/saveload/afterload.cpp Outdated Show resolved Hide resolved
src/vehicle_base.h Outdated Show resolved Hide resolved
@nielsmh
Copy link
Contributor Author

@nielsmh 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
Copy link
Contributor Author

@nielsmh 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 marked this pull request as ready for review Jul 14, 2019
@nielsmh
Copy link
Contributor Author

@nielsmh 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 cargotiles branch 3 times, most recently from 28a2c33 to c7e772f Sep 15, 2019
src/group_gui.cpp Outdated Show resolved Hide resolved
src/economy.cpp Show resolved Hide resolved
src/saveload/afterload.cpp Outdated Show resolved Hide resolved
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
Copy link
Contributor Author

@nielsmh 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.

@nielsmh nielsmh dismissed LordAro’s stale review Dec 23, 2019

All points addressed

@nielsmh
Copy link
Contributor Author

@nielsmh nielsmh commented Dec 23, 2019

I'm not sure if this should be merged before 1.10 branches. My original idea with this was to also change the performance rating calculation so the (often impossible) "all vehicles have >£10k profit" item could be replaced with something like "all vehicles have >40% efficiency", but I removed the performance rating change from the branch again. The new plan is to make a GS interface for performance rating overrides instead, and I think this PR is not quite worth releasing without also having GS performance ratings. (And I haven't gone much further than ideas stage for that part.)

@LordAro LordAro added this to the 1.11.0 milestone Dec 23, 2019
@LordAro LordAro added the stale label Sep 24, 2020
@LordAro
Copy link
Member

@LordAro LordAro commented Sep 24, 2020

Rebase needed

nielsmh added 2 commits Dec 22, 2020
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.
@TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Dec 22, 2020

I found a funny issue, I think: if a vehicle takes more than a year to do a round-trip, the values get non-useful. For example, I have a train with 300% efficiency! And the next year 0%.
This made me wonder, shouldn't this be a sliding window instead, or something? As measuring efficiency per year .. 1st of January it is now always zero for all vehicles. This feels counter-intuitive.

I need some more thinking about this myself, but just wanted to leave it here. I did rebase this PR, but it was not as clean as I would like, so I had to modify some things .. hopefully I did it correct :D

@andythenorth
Copy link
Contributor

@andythenorth andythenorth commented Dec 23, 2020

Test save attached for demo purposes. Only uses grfs from bananas.

7353 Transport.sav.zip

@TrueBrain TrueBrain removed this from the 1.11.0 milestone Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants