@@ -5,7 +5,6 @@ use std::collections::HashMap;
55
66const DELEGATED_VOTE_DENOMINATOR : i32 = 2 ;
77const FIXED_POINT_SCALING_FACTOR : i32 = 100 ; // *10 to mitigate float precission loss, and *10 to allow integer division
8- const ZERO_SNAP_THRESHOLD : f64 = 0.001 ; // float-noise floor: |output| <= this collapses to 0
98#[ derive( Clone , Debug ) ]
109pub struct RetroVoteQualityNeuron {
1110 votes_per_round : HashMap < u32 , HashMap < String , HashMap < String , Vote > > > , // round -> submission -> user -> vote (Yes/No/Abstain/Delegate)
@@ -66,12 +65,7 @@ impl RetroVoteQualityNeuron {
6665 }
6766 }
6867 let raw_bonus = total_bonus as f64 / FIXED_POINT_SCALING_FACTOR as f64 ;
69- // Mirror the curve around 0: run |raw| through the logistic (baseline-shifted
70- // so raw=0 maps to 0) and flip the sign for negative raw bonuses, so penalties
71- // produce symmetric negative scores instead of being clipped at the a=0 floor.
72- let magnitude = logistic ( raw_bonus. abs ( ) ) - logistic ( 0.0 ) ;
73- let signed = if raw_bonus < 0.0 { -magnitude } else { magnitude } ;
74- if signed. abs ( ) <= ZERO_SNAP_THRESHOLD { 0.0 } else { signed }
68+ generalised_logistic_function ( -5.0 , 5.0 , 1.0 , 1.0 , 0.4 , 1.0 , 0.0 , raw_bonus)
7569 }
7670 fn resolve_delegated_vote (
7771 & self ,
@@ -107,9 +101,7 @@ impl RetroVoteQualityNeuron {
107101 None
108102 }
109103}
110- fn logistic ( raw_bonus : f64 ) -> f64 {
111- generalised_logistic_function ( 0.0 , 5.0 , 1.0 , 4.0 , 1.0 , 1.0 , 1.0 , raw_bonus)
112- }
104+
113105fn tranche_status_to_bonus ( tranche_status : & str ) -> i32 {
114106 match tranche_status {
115107 "Live on Stellar within 6 months" => 30 , // 0.3
@@ -150,11 +142,7 @@ mod tests {
150142 const FLOAT_EPS : f64 = 1e-12 ;
151143
152144 fn logistic_of ( raw_bonus : f64 ) -> f64 {
153- // Mirrors the production formula: logistic(|raw|) - logistic(0), negated
154- // for negative raw, so raw=0 maps to 0 and penalties stay symmetric.
155- let f = |x| generalised_logistic_function ( 0.0 , 5.0 , 1.0 , 4.0 , 1.0 , 1.0 , 1.0 , x) ;
156- let magnitude = f ( raw_bonus. abs ( ) ) - f ( 0.0 ) ;
157- if raw_bonus < 0.0 { -magnitude } else { magnitude }
145+ generalised_logistic_function ( -5.0 , 5.0 , 1.0 , 1.0 , 0.4 , 1.0 , 0.0 , raw_bonus)
158146 }
159147
160148 fn assert_close ( actual : f64 , expected : f64 ) {
@@ -397,7 +385,7 @@ mod tests {
397385 let neuron = build_neuron ( HashMap :: new ( ) , HashMap :: new ( ) , & [ ] ) ;
398386 let result = neuron. run_user ( "alice" ) ;
399387 assert ! ( result. abs( ) < 1e-12 , "expected 0 for empty contributions, got {result}" ) ;
400- let raw_baseline = generalised_logistic_function ( 0 .0, 5.0 , 1.0 , 4 .0, 1.0 , 1.0 , 1 .0, 0.0 ) ;
388+ let raw_baseline = generalised_logistic_function ( - 5 .0, 5.0 , 1.0 , 1 .0, 0.4 , 1.0 , 0 .0, 0.0 ) ;
401389 assert ! (
402390 ( raw_baseline - 0.421_119_042_004_487 ) . abs( ) < 1e-12 ,
403391 "logistic baseline drifted: got {raw_baseline}"
0 commit comments