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

Geographic coverage differs from increase in coverage #632

Open
manumoreira opened this issue Apr 16, 2021 · 0 comments
Open

Geographic coverage differs from increase in coverage #632

manumoreira opened this issue Apr 16, 2021 · 0 comments

Comments

@manumoreira
Copy link

manumoreira commented Apr 16, 2021

Steps to reproduce:

  • Create a project with no providers
  • Create a scenario
  • Create a new provider with capacity equal to required capacity (unsatisfied demand)
  • The increase in coverage should be equal to population under coverage but it is not

The best workaround to fix this was 00cacf7
by giving more precision to the calculation the difference reduces dramatically. But the difference is still there.

Why is this happening? Because population under coverage and increasement in coverage are calculated in different ways, which can be affected by numerical rounding errors.

  • Population under coverage is measured as population under coverage (from all changed providers) from the baseline demand raster.
  • Increasement in coverage is measured as the difference between the initial unsatisfied demand for the whole region, and the unsatisfied demand of the scenario after accounting for the changes.

The values being accumulated in both cases are orders of magnitude lower than the totals, and there is a large number of pixels. Depending on the order in which the pixel values are accumulated, this can lead to a sizeable numerical error depending on the precision of the operands and the difference between them (eg. number of significant digits of the mantissa vs. differences in the exponents). Raster pixels are always 32-bit floats.

And there is also a difference between the number of pixels involved in each computation: the population under coverage by definition is calculated from a smaller (sometimes a lot smaller) number of pixels than the unsatisfied demand for the whole region.

A better possible solution for this would be measuring the increasement in coverage only for the population under coverage. This requires loading the initial scenario unsatisfied demand raster into memory in addition to the other two needed now: the base demand raster and the current scenario demand (which is being computed). (NB: initial unsatisfied demand and base demand are not the same, as the scenario might have initial providers)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant