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

Mobile Coverage points calculator #824

Merged
merged 115 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 109 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
c12cf58
add new crate for mobile reward coverage points calculations
michaeldjeffrey May 20, 2024
a752017
super simple calculate function
michaeldjeffrey May 20, 2024
a38119e
starting with indoor wifi coverage points
michaeldjeffrey May 20, 2024
c628887
base tests for all radio types
michaeldjeffrey May 21, 2024
92ac409
boosted hexes
michaeldjeffrey May 21, 2024
7c0956e
location trust score
michaeldjeffrey May 21, 2024
172d3a8
rank multiplier
michaeldjeffrey May 21, 2024
38e25d2
Start adding Assignment
michaeldjeffrey May 21, 2024
86af16f
oracle boosting assignment multiplier
michaeldjeffrey May 21, 2024
bd868f3
Comment which HIPs have impacted coverage_points calculation by field
michaeldjeffrey May 22, 2024
ce66053
use same verbiage as modeled coverage hip
michaeldjeffrey May 22, 2024
ac55763
Speedtest mutliplier
michaeldjeffrey May 23, 2024
c63cf03
reformat docs
michaeldjeffrey May 23, 2024
901dae7
remove to let use drive the interface
michaeldjeffrey May 23, 2024
f9fe094
LocalRadio -> RewardableRadio
michaeldjeffrey May 23, 2024
1a02c2f
integration tests to start messing with the API
michaeldjeffrey May 23, 2024
526a9d6
Make a full CoverageRewards struct that contains the points
michaeldjeffrey May 23, 2024
febe516
Make Rank 1-indexed
michaeldjeffrey May 23, 2024
5a69e11
assignments typo
michaeldjeffrey May 23, 2024
9ed0800
break up filter and map
michaeldjeffrey May 24, 2024
5f90176
Use more expected name for hex coverage points
michaeldjeffrey May 24, 2024
2fe76e8
remove unused code
michaeldjeffrey May 24, 2024
5f3f14a
Make calculating coverage points a top level function
michaeldjeffrey May 24, 2024
16dee05
flesh out speedtests
michaeldjeffrey May 24, 2024
c5018dd
make location trust into full struct
michaeldjeffrey May 24, 2024
18d1ca3
Location trust scores
michaeldjeffrey May 24, 2024
92f5c69
break out location
michaeldjeffrey May 25, 2024
347551f
to_mbps -> as_mbps
michaeldjeffrey May 25, 2024
d516120
Match HIP explicitly for latency values
michaeldjeffrey May 28, 2024
6eed581
add HIP specific tests
michaeldjeffrey May 28, 2024
c4d842a
Change verified radio threshold to enum
michaeldjeffrey May 28, 2024
073a0ee
more explicit name for precomputed multiplier values
michaeldjeffrey May 28, 2024
df0b365
name calculcator consistently with other packages
michaeldjeffrey May 29, 2024
84b10f3
Add a user definable key for radios
michaeldjeffrey May 29, 2024
af08ee9
add cell for covered hex
michaeldjeffrey May 30, 2024
913005d
helpers for mobile rewards report
michaeldjeffrey May 30, 2024
29b1dc6
put all the boosted hex filtering in one place
michaeldjeffrey May 30, 2024
34fd895
coverage map trait takes key directly
michaeldjeffrey May 31, 2024
b3f7924
SubscriberThreshold -> RadioThreshold
michaeldjeffrey May 31, 2024
3fdaf60
move boosted hexes iter to the mobile-verifier
michaeldjeffrey May 31, 2024
69568bb
use hex_assignments crate
michaeldjeffrey Jun 1, 2024
7547025
do not handle cleaning values for reports
michaeldjeffrey Jun 1, 2024
6f6d06a
clippy
michaeldjeffrey Jun 1, 2024
0f01422
include hex_assignments crate
michaeldjeffrey Jun 3, 2024
3195958
Include coverage-map to start integration
michaeldjeffrey Jun 3, 2024
3f721e1
Use SignalLevel from coverage_map
michaeldjeffrey Jun 3, 2024
38584b6
Remove unused radio trait
michaeldjeffrey Jun 4, 2024
b9f985e
remove coveragemap trait
michaeldjeffrey Jun 4, 2024
a62b276
use RankedCoverage from coverage map
michaeldjeffrey Jun 4, 2024
36af33e
do not panic for incorrect signal levels
michaeldjeffrey Jun 4, 2024
821be75
starting to reorder things for readability
michaeldjeffrey Jun 4, 2024
dd613bc
Cleanup after overview
michaeldjeffrey Jun 5, 2024
0b6df3d
Restrict construction of RewardableRadio
michaeldjeffrey Jun 5, 2024
a6ee102
enforce maximum used speedtetss
michaeldjeffrey Jun 5, 2024
7821a86
move multiplier calculation into location crate
michaeldjeffrey Jun 5, 2024
efa1c37
bring in speedtest and location changes
michaeldjeffrey Jun 5, 2024
d113dd4
reorder doc links by HIP#
michaeldjeffrey Jun 5, 2024
47999df
move hexes to their own module
michaeldjeffrey Jun 5, 2024
28a0aa0
construct new location trust for boosted version
michaeldjeffrey Jun 5, 2024
51150b2
add notable conditions to docs
michaeldjeffrey Jun 5, 2024
fb1da40
represent boosted hex eligiblity with an enum
michaeldjeffrey Jun 5, 2024
ac3a77f
intersperse speedtests to make success clearer
michaeldjeffrey Jun 5, 2024
19956c0
I think the shorter name is just as good
michaeldjeffrey Jun 5, 2024
847a1fa
coverage points impl is not important enough to be that high in the file
michaeldjeffrey Jun 5, 2024
4541393
flesh out docs for RewardableRadio and CoveragePoints
michaeldjeffrey Jun 5, 2024
8a8b3ca
assert against expected points in integration
michaeldjeffrey Jun 5, 2024
36d93b5
remove type alias
michaeldjeffrey Jun 5, 2024
1aadb87
move helpers behind tests
michaeldjeffrey Jun 5, 2024
ff38db3
Use inner line comment to describe crate
michaeldjeffrey Jun 6, 2024
cb6b3ef
Clean up constructors
michaeldjeffrey Jun 6, 2024
a9e4846
remove unused iter function until it is needed
michaeldjeffrey Jun 6, 2024
5d7bd20
If a type can trivially be copy, let's make it copy
michaeldjeffrey Jun 6, 2024
03dfe72
move error closer to Result it takes part in
michaeldjeffrey Jun 6, 2024
1730802
remove need for managing rank as a index into a list
michaeldjeffrey Jun 6, 2024
d96ddab
add actual comments for fields in CoveredHex
michaeldjeffrey Jun 6, 2024
f94def7
Unverified is a single word
michaeldjeffrey Jun 6, 2024
4601b74
question was answered, negative
michaeldjeffrey Jun 6, 2024
33e7573
fix doc references to code
michaeldjeffrey Jun 6, 2024
6a43d7b
include rstest
michaeldjeffrey Jun 6, 2024
7004083
more natural function name to read
michaeldjeffrey Jun 6, 2024
963e9c3
make unread fields public
michaeldjeffrey Jun 6, 2024
4780bf3
remove radio information from returned coverage points
michaeldjeffrey Jun 6, 2024
bac1804
try not to compare directly against values
michaeldjeffrey Jun 6, 2024
d846d7d
provide a parameterized test for each type of radio
michaeldjeffrey Jun 6, 2024
3336070
coverage-map was updated to not use helium-crypto
michaeldjeffrey Jun 6, 2024
c4e43eb
remove Millis as a newtype
michaeldjeffrey Jun 6, 2024
7be97e9
SpeedtestTier is Copy, as well as BytePs
michaeldjeffrey Jun 6, 2024
55c530c
add test to make sure minimum required speedtests are enforced
michaeldjeffrey Jun 6, 2024
4684bb0
switchup location testing angle
michaeldjeffrey Jun 6, 2024
fca8c2f
pass radios as references in test
michaeldjeffrey Jun 6, 2024
aada11f
remove Meters as a newtype
michaeldjeffrey Jun 6, 2024
479e932
name base_coverage_points consistently
michaeldjeffrey Jun 6, 2024
6fa795d
parameterize ranked tests
michaeldjeffrey Jun 6, 2024
3d3cd08
use correct radio type for test
michaeldjeffrey Jun 6, 2024
389134b
clippy does not like overlapping ranges
michaeldjeffrey Jun 6, 2024
df93e3d
exchange struct constructor for function
michaeldjeffrey Jun 7, 2024
81e7e25
Don't let the comments fall behind
michaeldjeffrey Jun 7, 2024
ff65ac8
move radio_threshold earlier in argument list
michaeldjeffrey Jun 7, 2024
83b0a21
include all fields in coverage points
michaeldjeffrey Jun 7, 2024
b35f2ae
provide single function as API to calculator
michaeldjeffrey Jun 7, 2024
6e8fd68
remove RewardableRadio struct
michaeldjeffrey Jun 7, 2024
3c696c3
remove wrapping struct for location trust scores
michaeldjeffrey Jun 7, 2024
5991da7
remove wrapping CoveredHexes struct
michaeldjeffrey Jun 7, 2024
bfa23d2
remove wrapping struct from speedtests
michaeldjeffrey Jun 7, 2024
3da915f
add more links to docs
michaeldjeffrey Jun 7, 2024
958b2d1
move calcuating coverage points into constructor
michaeldjeffrey Jun 7, 2024
dc02abc
Removing derive Default for Speedtest
michaeldjeffrey Jun 7, 2024
75e3d4b
Fix incorrect speedtests conversion
michaeldjeffrey Jun 10, 2024
1abeb84
Take responsibility of rounding shares and total coverage points
michaeldjeffrey Jun 11, 2024
f252947
Remove rounding
michaeldjeffrey Jun 11, 2024
ec39a07
hip-103: oracles and provider boosting crossover
michaeldjeffrey Jun 11, 2024
cfc884a
Bring over scenario tests
michaeldjeffrey Jun 11, 2024
419b273
BytesPs is Copy, no need to .clone()
michaeldjeffrey Jun 11, 2024
87b6b3a
hip-103: provider boost increases oracle boost always
michaeldjeffrey Jun 12, 2024
0399213
move collections to the end
michaeldjeffrey Jun 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ debug = true
members = [
"boost_manager",
"coverage_map",
"coverage_point_calculator",
"custom_tracing",
"db_store",
"denylist",
Expand Down
20 changes: 20 additions & 0 deletions coverage_point_calculator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "coverage-point-calculator"
version = "0.1.0"
description = "Calculate Coverage Points for hotspots in the Mobile Network"
authors.workspace = true
license.workspace = true
edition.workspace = true

[dependencies]
chrono = { workspace = true }
hextree = { workspace = true }
rust_decimal = { workspace = true }
rust_decimal_macros = { workspace = true }
thiserror = { workspace = true }
hex-assignments = { path = "../hex_assignments" }
coverage-map = { path = "../coverage_map" }

[dev-dependencies]
helium-crypto = { workspace = true }
rstest = { version = "0.21.0", default-features = false }
78 changes: 78 additions & 0 deletions coverage_point_calculator/src/hexes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
use coverage_map::RankedCoverage;
use hex_assignments::assignment::HexAssignments;
use rust_decimal::Decimal;
use rust_decimal_macros::dec;

use crate::{BoostedHexStatus, RadioType, Result};

#[derive(Debug, Clone)]
pub struct CoveredHex {
pub hex: hextree::Cell,
/// Default points received from (RadioType, SignalLevel) pair.
pub base_coverage_points: Decimal,
/// Coverage points including assignment, rank, and boosted hex multipliers.
pub calculated_coverage_points: Decimal,
/// Oracle boosted Assignments
pub assignments: HexAssignments,
pub assignment_multiplier: Decimal,
/// [RankedCoverage::rank] 1-based
pub rank: usize,
pub rank_multiplier: Decimal,
/// Provider boosted multiplier. Will be None if the Radio does not qualify
/// for boosted rewards.
pub boosted_multiplier: Option<Decimal>,
}

pub(crate) fn clean_covered_hexes(
radio_type: RadioType,
ranked_coverage: Vec<RankedCoverage>,
boosted_hex_status: BoostedHexStatus,
) -> Result<Vec<CoveredHex>> {
let ranked_coverage = if !boosted_hex_status.is_eligible() {
ranked_coverage
.into_iter()
.map(|ranked| RankedCoverage {
boosted: None,
..ranked
})
.collect()
} else {
ranked_coverage
};

// verify all hexes can obtain a base coverage point
let covered_hexes = ranked_coverage
.into_iter()
.map(|ranked| {
let base_coverage_points = radio_type.base_coverage_points(&ranked.signal_level)?;
let rank_multiplier = radio_type.rank_multiplier(ranked.rank);
let assignment_multiplier = ranked.assignments.boosting_multiplier();
let boosted_multiplier = ranked.boosted.map(|boost| boost.get()).map(Decimal::from);

let calculated_coverage_points = base_coverage_points
* assignment_multiplier
* rank_multiplier
* boosted_multiplier.unwrap_or(dec!(1));

Ok(CoveredHex {
hex: ranked.hex,
base_coverage_points,
calculated_coverage_points,
assignments: ranked.assignments,
assignment_multiplier,
rank: ranked.rank,
rank_multiplier,
boosted_multiplier,
})
})
.collect::<Result<Vec<_>>>()?;

Ok(covered_hexes)
}

pub(crate) fn calculated_coverage_points(covered_hexes: &[CoveredHex]) -> Decimal {
covered_hexes
.iter()
.map(|hex| hex.calculated_coverage_points)
.sum()
}
Loading