1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! # Approval Threshold Models
//!
//! Implements different models for how approval thresholds change over time,
//! allowing for quick early consensus while requiring higher scrutiny later.
use ;
/// Models for how approval thresholds change over time.
///
/// Each model provides a different progression curve:
/// - Linear: Steady increase over time
/// - Exponential: Rapid early increase, slower later
/// - Sigmoid: S-curve progression with smooth transitions
/// Calculates the approval threshold at a given time using the specified model.
///
/// All models enforce bounds between 0.35 and 0.9 to ensure reasonable
/// threshold ranges regardless of parameters.
///
/// # Arguments
/// * `model` - The threshold model to use
/// * `t` - Time elapsed since voting started (seconds)
/// * `total` - Total voting period duration (seconds)
///
/// # Returns
/// Approval threshold between 0.35 and 0.9
///
/// # Examples
/// ```
/// use verdyce_core::threshold::{ThresholdModel, threshold_calc};
///
/// // Linear threshold starting at 0.5, increasing by 0.0001 per second
/// let threshold = threshold_calc(&ThresholdModel::Linear(0.0001, 0.5), 1800, 3600);
/// assert!((threshold - 0.68).abs() < 0.01);
/// ```