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

Landtype Boosting #789

Merged
merged 15 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 15 additions & 24 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 mobile_verifier/migrations/32_landtype.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE hexes ADD COLUMN landtype oracle_assignment;
117 changes: 64 additions & 53 deletions mobile_verifier/src/boosting_oracles/assignment.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
use helium_proto::services::poc_mobile::oracle_boosting_hex_assignment;
use helium_proto::services::poc_mobile::oracle_boosting_hex_assignment::Assignment as ProtoAssignment;
use rust_decimal::Decimal;
use rust_decimal_macros::dec;
use std::fmt;

#[derive(Debug, Clone, PartialEq, Eq, sqlx::FromRow)]
pub struct HexAssignments {
pub footfall: Assignment,
pub landtype: Assignment,
pub urbanized: Assignment,
}

#[derive(Copy, Clone, PartialEq, Eq, Debug, sqlx::Type)]
#[sqlx(type_name = "oracle_assignment")]
#[sqlx(rename_all = "lowercase")]
Expand All @@ -12,7 +19,7 @@ pub enum Assignment {
C,
}

impl From<Assignment> for oracle_boosting_hex_assignment::Assignment {
impl From<Assignment> for ProtoAssignment {
fn from(assignment: Assignment) -> Self {
match assignment {
Assignment::A => Self::A,
Expand All @@ -24,7 +31,17 @@ impl From<Assignment> for oracle_boosting_hex_assignment::Assignment {

impl From<Assignment> for i32 {
fn from(assignment: Assignment) -> i32 {
oracle_boosting_hex_assignment::Assignment::from(assignment) as i32
ProtoAssignment::from(assignment) as i32
}
}

impl From<ProtoAssignment> for Assignment {
fn from(value: ProtoAssignment) -> Self {
match value {
ProtoAssignment::A => Assignment::A,
ProtoAssignment::B => Assignment::B,
ProtoAssignment::C => Assignment::C,
}
}
}

Expand All @@ -40,59 +57,53 @@ impl fmt::Display for Assignment {
}
}

pub fn footfall_and_urbanization_multiplier(
footfall: Assignment,
urbanization: Assignment,
) -> Decimal {
use Assignment::*;
impl HexAssignments {
pub fn boosting_multiplier(&self) -> Decimal {
let HexAssignments {
footfall,
urbanized,
landtype,
} = self;

match (footfall, urbanization) {
(A, A) => dec!(1.0),
(A, B) => dec!(1.0),
(B, A) => dec!(0.75),
(B, B) => dec!(0.50),
(C, A) => dec!(0.40),
(C, B) => dec!(0.10),
(A, C) => dec!(0.00),
(B, C) => dec!(0.00),
(C, C) => dec!(0.00),
use Assignment::*;
match (footfall, landtype, urbanized) {
// yellow - POI ≥ 1 Urbanized
(A, A, A) => dec!(1.00),
(A, B, A) => dec!(1.00),
(A, C, A) => dec!(1.00),
// orange - POI ≥ 1 Not Urbanized
(A, A, B) => dec!(1.00),
(A, B, B) => dec!(1.00),
(A, C, B) => dec!(1.00),
// light green - Point of Interest Urbanized
(B, A, A) => dec!(0.70),
(B, B, A) => dec!(0.70),
(B, C, A) => dec!(0.70),
// dark green - Point of Interest Not Urbanized
(B, A, B) => dec!(0.50),
(B, B, B) => dec!(0.50),
(B, C, B) => dec!(0.50),
// light blue - No POI Urbanized
(C, A, A) => dec!(0.40),
(C, B, A) => dec!(0.30),
(C, C, A) => dec!(0.05),
// dark blue - No POI Not Urbanized
(C, A, B) => dec!(0.20),
(C, B, B) => dec!(0.15),
(C, C, B) => dec!(0.03),
// gray - Outside of USA
(_, _, C) => dec!(0.00),
}
Comment on lines +94 to +95
Copy link
Member

@kurotych kurotych Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean that all radios outside of the USA won't receive any coverage points?
What about Mexico?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIP-103 contains this paragraph, so radios in Mexico only get PoC if they are in a boosted hex and the oracle_multiplier is auto set to 1.

Further, the HIP authors acknowledge that areas that Service Providers boost through hex boosting are areas where coverage is needed the most. Therefore, if a res12 hex is boosted by a Service Provider of ≥1, the Oracle Multiplier will automatically be 1.00X, regardless of what combination value it is assigned.

}
}

#[allow(dead_code)]
pub fn boosting_oracles_multiplier(
footfall: Assignment,
landtype: Assignment,
urbanization: Assignment,
) -> Decimal {
use Assignment::*;

match (footfall, landtype, urbanization) {
// POI ≥ 1 Urbanized
(A, A, A) => dec!(1.00),
(A, B, A) => dec!(1.00),
(A, C, A) => dec!(1.00),
// POI ≥ 1 Not Urbanized
(A, A, B) => dec!(1.00),
(A, B, B) => dec!(1.00),
(A, C, B) => dec!(1.00),
// Point of Interest Urbanized
(B, A, A) => dec!(0.70),
(B, B, A) => dec!(0.70),
(B, C, A) => dec!(0.70),
// Point of Interest Not Urbanized
(B, A, B) => dec!(0.50),
(B, B, B) => dec!(0.50),
(B, C, B) => dec!(0.50),
// No POI Urbanized
(C, A, A) => dec!(0.40),
(C, B, A) => dec!(0.30),
(C, C, A) => dec!(0.05),
// No POI Not Urbanized
(C, A, B) => dec!(0.20),
(C, B, B) => dec!(0.15),
(C, C, B) => dec!(0.03),
// Outside of USA
(_, _, C) => dec!(0.00),
#[cfg(test)]
impl HexAssignments {
michaeldjeffrey marked this conversation as resolved.
Show resolved Hide resolved
pub fn test_best() -> Self {
Self {
footfall: Assignment::A,
urbanized: Assignment::A,
landtype: Assignment::A,
}
}
}
Loading
Loading