rounds

package
v1.0.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	BlockIterations = 100
	FloorIterations = 1000 // Below it the single sim and a stat sweep's lanes stop only at their cap; a sweep looks for its capped step at it and counts Max in it.
	Z95             = 1.96
	Z90             = 1.645
	// The iterations the blocks of a single sim must have reported before their spread forecasts its total, ahead of
	// the first decided round: a total forecast too low is shown, and the bar then holds until the run catches up.
	ForecastFloorIterations = 200
)
View Source
const DefaultTargetErrorPct = 0.2 // The UI's default Target ±, and Batch's tie margin in a run with a count.

Variables

This section is empty.

Functions

func CeilDiv

func CeilDiv(a, b int64) int64

func ErrorPct

func ErrorPct(sums Sums) float64

The single sim's 95 % ± of the mean in percent of the mean. It stays 0 with no iterations, no spread or a mean of 0 or less.

func HalfWidth

func HalfWidth(z, sd, n float64) float64

func MetricIndex

func MetricIndex(metric proto.PrecisionMetric) int

The metric's index in Metrics; DPS for a metric it does not name.

func Metrics

func Metrics(player *proto.UnitMetrics) [5]*proto.DistributionMetrics

A player's DPS, HPS, TPS, DTPS and TMI, the order every five-metric array of the rules keeps.

func ProjectedIterations

func ProjectedIterations(sums Sums, target float64, maxIterations int32) int64

The iterations at which the sums' error would reach the target, in whole blocks, at most maxIterations.

func Run

func Run[B any](options RunOptions[B]) *proto.ErrorOutcome

Runs blocks round first, at most Workers at a time, and takes blocks of the next round for the lanes live now while a round is still running. A block of a lane that leaves is aborted, and Run aborts every block still running when it returns or panics. A block that panics makes Run panic, on the caller's goroutine.

func WholeBlocks

func WholeBlocks(x float64) float64

Types

type Decision

type Decision struct {
	Leave               []int32 // Lanes that take no block after this round, ascending.
	End                 bool    // No lane takes another block.
	ProjectedIterations int64   // The iterations the run is expected to reach, every lane together. Sizes the progress bar, and a one-lane run counts only the blocks that start below it; 0 counts every block.
}

type Fixed

type Fixed struct {
	Combine func(*proto.RaidSimResult) // Hears every block of the decided rounds, in block order.
	// contains filtered or unexported fields
}

The single sim's rule for a fixed count: every block up to the count, combined in block order.

func NewFixed

func NewFixed(count, blockIterations int32) *Fixed

func (*Fixed) Decide

func (f *Fixed) Decide(round int32, _ []int32, blocks []*proto.RaidSimResult) Decision

func (*Fixed) Extract

func (f *Fixed) Extract(_ int32, result *proto.RaidSimResult) *proto.RaidSimResult

type Ledger

type Ledger[B any] struct {
	// contains filtered or unexported fields
}

Takes blocks in any order and decides each round by the rule once every live lane's block of it is in, rounds in order, so a decision sees the same blocks whatever order they arrived in.

func NewLedger

func NewLedger[B any](lanes int32, rule Rule[B]) *Ledger[B]

func (*Ledger[B]) Add

func (l *Ledger[B]) Add(lane, round int32, result *proto.RaidSimResult) (decisions []Decision, err *proto.ErrorOutcome)

The decisions of every round block `round` of `lane` completes, in round order. A block of a lane that has left, or one that arrives after the run ended, is dropped. A block's error fails the run only when its round is decided with its lane still live.

func (*Ledger[B]) Ended

func (l *Ledger[B]) Ended() bool

func (*Ledger[B]) IsLive

func (l *Ledger[B]) IsLive(lane int32) bool

func (*Ledger[B]) Live

func (l *Ledger[B]) Live() []int32

The live lanes, ascending. The slice is the ledger's own.

func (*Ledger[B]) Round

func (l *Ledger[B]) Round() int32

The rounds decided so far.

type MetricValues

type MetricValues [5][]float64

A block's per-iteration values of the first player's five metrics, in Metrics order.

func MetricValuesOf

func MetricValuesOf(result *proto.RaidSimResult) MetricValues

type PrecisionTarget

type PrecisionTarget struct {
	Combine  func(*proto.RaidSimResult) // Hears every block of the decided rounds, in block order; nil hears none.
	ErrorPct float64                    // The ± at the last decided round.
	// contains filtered or unexported fields
}

The single sim's rule: it stops once the 95 % ± of the role metric's mean is at most the target percent, or at the cap, and never before FloorIterations below the cap.

func NewPrecisionTarget

func NewPrecisionTarget(precision *proto.SimPrecision, maxIterations int32) *PrecisionTarget

func (*PrecisionTarget) Decide

func (s *PrecisionTarget) Decide(round int32, _ []int32, blocks []PrecisionTargetBlock) Decision

func (*PrecisionTarget) Extract

func (*PrecisionTarget) Forecast

func (s *PrecisionTarget) Forecast(dps, hps Sums) int64

The run's total as the blocks that have reported forecast it before a round is decided, from the raid's DPS or HPS sums over their iterations, held between the floor and the cap as Decide holds its own. 0 for no forecast: under ForecastFloorIterations, with no spread, or for a metric the blocks do not report while they run.

func (*PrecisionTarget) Load

func (s *PrecisionTarget) Load(state *proto.RoundState)

func (*PrecisionTarget) MetricOf

func (*PrecisionTarget) Save

func (s *PrecisionTarget) Save() *proto.RoundState

What the rule needs to go on after the rounds it decided. Rounds is left for the caller to set.

type PrecisionTargetBlock

type PrecisionTargetBlock struct {
	Sums   Sums
	Result *proto.RaidSimResult
}

The role metric of one block, beside the block's result.

type Progress

type Progress struct {
	Completed, Total int64 // Iterations, every lane together.
	LanesDone, Lanes int32 // LanesDone have left the run.
	Projected        int64 // The total as the rule projects it, before it is lowered to hold the fraction shown: what a time left reads.
	// The raid's DPS and HPS sums over the counted blocks whose round is not decided, which a one-lane run shows with
	// those of its decided rounds.
	PendingDps, PendingHps Sums
	IsForecast             bool  // Forecast gave the total: no round is decided and the blocks' spread forecasts it.
	DecidedRounds          int32 // The rounds the rule has decided.
}

type Rule

type Rule[B any] interface {
	// What the rule keeps of one lane's block. Called as the block arrives, in any order, and never for a block that
	// holds an error.
	Extract(lane int32, result *proto.RaidSimResult) B
	// Folds round `round`: blocks holds block `round` of every lane in live, in the same ascending order.
	Decide(round int32, live []int32, blocks []B) Decision
}

type RunOptions

type RunOptions[B any] struct {
	LaneCount       int32
	MaxRounds       int32 // No lane runs block MaxRounds or later.
	BlockIterations int32 // Block k starts at iteration k·BlockIterations.
	Workers         int
	Rule            Rule[B]
	// Runs one block and returns its result. report hears the block's finished iterations and the sums of its raid DPS
	// and HPS over them as its sim reports them.
	Block func(lane, round int32, abort simsignals.Signals, report func(done int32, dps, hps Sums)) *proto.RaidSimResult
	// Called on the goroutine that calls Run, the one that calls Extract and Decide.
	OnProgress   func(Progress)
	InitialTotal int64 // The progress bar's total until the first decision: exact or an upper bound, as a fraction shown against a lower total is held. A one-lane run counts only the blocks that start below it; 0 counts every block.
	// Until round 0 is decided, the bar's total as the sums of every block that has reported forecast it, counted or
	// not; 0 keeps the total it had. Called on the goroutine that calls OnProgress.
	Forecast func(dps, hps Sums) int64
	Signals  simsignals.Signals
	InWasm   bool
}

type Sums

type Sums struct {
	N     int32
	Sum   float64
	SumSq float64
}

Every product that feeds a sum is wrapped in float64(...), which Go defines as a rounding point, so no platform fuses it into a multiply-add and native and wasm fold the same values to the same bits.

func SumsOf

func SumsOf(p *proto.MetricSums) Sums

func SumsOfMetric

func SumsOfMetric(metric *proto.DistributionMetrics) Sums

A finished run's metric as sums; empty for a metric that is not there.

func (*Sums) Add

func (s *Sums) Add(v float64)

func (*Sums) AddDifferences

func (s *Sums) AddDifferences(values, base []float64)

func (Sums) HalfWidth

func (s Sums) HalfWidth(z float64) float64

func (Sums) Mean

func (s Sums) Mean() float64

func (Sums) Proto

func (s Sums) Proto() *proto.MetricSums

func (Sums) Stdev

func (s Sums) Stdev() float64

func (Sums) Variance

func (s Sums) Variance() float64

Not floored at 0, so a sample's stdev keeps a plain sim's bits.

type Sweep

type Sweep struct {
	ErrorCi float64 // With a target, the widest 90 % ± among the lanes the last round decided, those dropped at the capped step left out; 0 before the first round.
	// contains filtered or unexported fields
}

The stat sweep's rule over one stat's steps. Each lane folds its five metrics one value at a time, so a lane's result is a plain sim's of its request at the same seed and count. A lane decides alone: without a target every lane runs the count; with one a lane leaves once it has FloorIterations and its metric's 90 % ± is at most the target, or at the cap. In the round where the lanes reach FloorIterations, or the count when it is lower, an upward lane whose five sums equal the lane below's bit for bit is a repeat; at the first lane i where lanes i-1 and i both repeat, step i-2 is the capped step, lane i leaves with its iterations and every upward lane above it leaves with no result.

func NewSweep

func NewSweep(rule *proto.RoundRule) *Sweep

func (*Sweep) Decide

func (s *Sweep) Decide(round int32, live []int32, blocks []MetricValues) Decision

func (*Sweep) Extract

func (s *Sweep) Extract(_ int32, result *proto.RaidSimResult) MetricValues

func (*Sweep) IsPrecisionRun

func (s *Sweep) IsPrecisionRun() bool

Whether the lanes run to a target: a target_ci above 0.

func (*Sweep) Live

func (s *Sweep) Live() []int32

The lanes that have not left, ascending.

func (*Sweep) Load

func (s *Sweep) Load(state *proto.RoundState)

func (*Sweep) Result

func (s *Sweep) Result() *proto.StatSweepResult

Every lane that has left: its metrics as a plain sim of its request reports them, or that it was dropped; and the capped step.

func (*Sweep) Save

func (s *Sweep) Save() *proto.RoundState

What the rule needs to go on after the rounds it decided. Rounds is left for the caller to set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL