Skip to main content

CompetitiveSelectionSoft

Struct CompetitiveSelectionSoft 

Source
pub struct CompetitiveSelectionSoft {
    pub extra: Vec<u64>,
    pub scores: Vec<u64>,
    pub weight_total: u64,
    pub max_score: u64,
}
Expand description

Soft competitive selection: weights derived from an evolving extra via the reserved-floor sequential Webster award process, not chosen freely.

Fields§

§extra: Vec<u64>

Extra Webster awards by candidate index.

§scores: Vec<u64>

Candidate scores by candidate index.

§weight_total: u64

Total weight available for assignment.

§max_score: u64

MaxScore for this refinement profile.

Implementations§

Source§

impl CompetitiveSelectionSoft

Source

pub fn weight_at(&self, i: usize) -> u64

Executable accessor for the derived weight (1 + extra[i]).

Source

pub fn assigned_weight(&self) -> u64

Number of units currently assigned, including one reserved unit per candidate.

Source

pub fn init( scores: Vec<u64>, weight_total: u64, max_score: u64, ) -> CompetitiveSelectionSoft

TLA+ Init: scores are mutable state and every candidate begins with only its reserved unit. Unlike new, this does not run the award process to Terminal; it exposes the action-level carrier state.

Source

pub fn new( scores: Vec<u64>, weight_total: u64, max_score: u64, ) -> CompetitiveSelectionSoft

Construct the reserved-floor sequential Webster allocation over scores: one guaranteed unit per candidate, then Pool further units awarded one at a time to the current highest-priority candidate. Mirrors CompetitiveSelectionSoft.tla’s Init + AssignNext exactly.

Source

pub fn assign_next(&mut self) -> usize

Award one further pool unit (TLA+ AssignNext, one step): re-establishes every invariant that holds at every reachable state (ScoreOrderPreservation, TieBoundedness, UniversalContribution); Normalization only holds once the pool is exhausted, matching the TLA+ construction exactly.

Source

pub fn update_score(&mut self, c: usize, v: u64)

CompetitiveSelectionSoftMutableScores UpdateScore(c,v): update one mutable score and invalidate the partial apportionment in the same commit by resetting every extra award to the reserved floor.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.