Struct piston_mix_economy::Economy [] [src]

pub struct Economy {
    pub players: Vec<f64>,
    pub tax: f64,
    pub start_fortune: f64,
}

Represents the whole economy.

Each player has a normalized fortune against an upper soft limit. The difference from the upper limit is charging the economy.

The tax tells how fast to burn money of fortunes above the soft limit, and how much to give each player below the soft limit per time interval.

The start fortune is given to new players.

Call Economy::update at regular time intervals to distribute wealth, using a fixed tax rate. The Gini index can vary depending on economic activity.

Call Economy::solve at regular time intervals to distribute wealth, using a target Gini coefficient. The tax is automatically adjusted to meet the target.

Fields

The fortunes of the players.

The progressive tax factor, as the square root of fortune above 1.

The initial fortune. Should be in the range [0, 1].

Methods

impl Economy
[src]

Creates a new economy.

Adds a player to the economy.

Finds the minimum and maximum fortune.

Find the Gini coefficient (see https://en.wikipedia.org/wiki/Gini_coefficient).

Does a transaction between two people.

Updates the economy using the fixed tax rate. The Gini index can vary depending on economic activity.

Updates the economy using a target Gini coefficient. The tax is automatically adjusted to meet the target. Uses convergent binary search to find the tax.

The solver is less accurate for high Gini (~0.5 or higher) in some cases. A very low Gini (<0.1) might not work at all, because the algorithm is incentivizing (players that have more gets more below the upper soft limit).

The smooth_target parameter is a value in range [0.5, 1). 0.5 gives binary search behavior, which assumes strict monotonic Gini (tax should be lowered if target Gini is above). Higher values weakens the assumption, interpreted as the mix-algorithm "tends to have" monotonic Gini.

The min_tax parameter is a value usually above 0, to prevent the solver from getting stuck in 0% scenarios.

Trait Implementations

impl Clone for Economy
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more