Documentation
¶
Index ¶
- Constants
- func CeilDiv(a, b int64) int64
- func ErrorPct(sums Sums) float64
- func HalfWidth(z, sd, n float64) float64
- func MetricIndex(metric proto.PrecisionMetric) int
- func Metrics(player *proto.UnitMetrics) [5]*proto.DistributionMetrics
- func ProjectedIterations(sums Sums, target float64, maxIterations int32) int64
- func Run[B any](options RunOptions[B]) *proto.ErrorOutcome
- func WholeBlocks(x float64) float64
- type Decision
- type Fixed
- type Ledger
- type MetricValues
- type PrecisionTarget
- func (s *PrecisionTarget) Decide(round int32, _ []int32, blocks []PrecisionTargetBlock) Decision
- func (s *PrecisionTarget) Extract(_ int32, result *proto.RaidSimResult) PrecisionTargetBlock
- func (s *PrecisionTarget) Forecast(dps, hps Sums) int64
- func (s *PrecisionTarget) Load(state *proto.RoundState)
- func (s *PrecisionTarget) MetricOf(player *proto.UnitMetrics) *proto.DistributionMetrics
- func (s *PrecisionTarget) Save() *proto.RoundState
- type PrecisionTargetBlock
- type Progress
- type Rule
- type RunOptions
- type Sums
- type Sweep
- func (s *Sweep) Decide(round int32, live []int32, blocks []MetricValues) Decision
- func (s *Sweep) Extract(_ int32, result *proto.RaidSimResult) MetricValues
- func (s *Sweep) IsPrecisionRun() bool
- func (s *Sweep) Live() []int32
- func (s *Sweep) Load(state *proto.RoundState)
- func (s *Sweep) Result() *proto.StatSweepResult
- func (s *Sweep) Save() *proto.RoundState
Constants ¶
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 )
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 ErrorPct ¶
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 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 ¶
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 ¶
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 (*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 (*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.
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 (s *PrecisionTarget) Extract(_ int32, result *proto.RaidSimResult) PrecisionTargetBlock
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 (s *PrecisionTarget) MetricOf(player *proto.UnitMetrics) *proto.DistributionMetrics
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 ¶
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) AddDifferences ¶
func (Sums) Proto ¶
func (s Sums) Proto() *proto.MetricSums
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 (*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 ¶
Whether the lanes run to a target: a target_ci above 0.
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.