Documentation ¶
Index ¶
- func AccumulateWeights(inference *emissionstypes.Inference, weight alloraMath.Dec, noPriorRegret bool, ...) (alloraMath.Dec, alloraMath.Dec, error)
- func CalcNetworkLosses(stakesByReputer map[Worker]Stake, ...) (emissions.ValueBundle, error)
- func CalcWeightFromNormalizedRegret(normalizedRegret alloraMath.Dec, maxNormalizedRegret alloraMath.Dec, ...) (alloraMath.Dec, error)
- func ComputeAndBuildEMRegret(lossA Loss, lossB Loss, previousRegret Regret, alpha alloraMath.Dec, ...) (emissions.TimestampedValue, error)
- func ConvertForecastImpliedInferencesToArrays(workers []Worker, forecastImpliedInferenceByWorker map[string]*types.Inference) []*types.WorkerAttributedValue
- func ConvertValueBundleToNetworkLossesByWorker(valueBundle emissions.ValueBundle) networkLossesByWorker
- func ConvertWeightsToArrays(workers []Worker, weights map[Worker]Weight) []*types.RegretInformedWeight
- func CosmosIntOneE18() cosmosMath.Int
- func FilterNoncesWithinEpochLength(n emissions.Nonces, blockHeight, epochLength int64) emissions.Nonces
- func GetCalcSetNetworkRegrets(ctx sdk.Context, k keeper.Keeper, topicId TopicId, ...) error
- func GetLatestNetworkInference(ctx sdk.Context, k keeper.Keeper, topicId TopicId) (*emissions.ValueBundle, map[string]*emissions.Inference, ...)
- func GetNetworkInferencesAtBlock(ctx sdk.Context, k keeper.Keeper, topicId TopicId, inferencesNonce BlockHeight, ...) (*emissions.ValueBundle, map[string]*emissions.Inference, ...)
- func Logger(ctx sdk.Context) log.Logger
- func MakeMapFromForecasterToTheirForecast(forecasts []*emissions.Forecast) map[Worker]*emissions.Forecast
- func MakeMapFromInfererToTheirInference(inferences []*emissions.Inference) map[Worker]*emissions.Inference
- func SelectTopNReputerNonces(reputerRequestNonces *emissions.ReputerRequestNonces, N int, ...) []*emissions.ReputerRequestNonce
- func SelectTopNWorkerNonces(workerNonces emissions.Nonces, N int) []*emissions.Nonce
- func SortByBlockHeight(r []*emissions.ReputerRequestNonce)
- type BlockHeight
- type InferenceValue
- type InferersNewStatus
- type Loss
- type NetworkInferenceBuilder
- func (b *NetworkInferenceBuilder) Build() *emissions.ValueBundle
- func (b *NetworkInferenceBuilder) CalcAndSetNetworkInferences() *NetworkInferenceBuilder
- func (b *NetworkInferenceBuilder) SetCombinedValue() *NetworkInferenceBuilder
- func (b *NetworkInferenceBuilder) SetForecasterValues() *NetworkInferenceBuilder
- func (b *NetworkInferenceBuilder) SetInfererValues() *NetworkInferenceBuilder
- func (b *NetworkInferenceBuilder) SetNaiveValue() *NetworkInferenceBuilder
- func (b *NetworkInferenceBuilder) SetOneInValues() *NetworkInferenceBuilder
- func (b *NetworkInferenceBuilder) SetOneOutForecasterValues() *NetworkInferenceBuilder
- func (b *NetworkInferenceBuilder) SetOneOutInfererValues() *NetworkInferenceBuilder
- type Regret
- type RegretInformedWeights
- type RunningWeightedLoss
- type Stake
- type StatefulRegret
- type StdDevRegrets
- type SynthPalette
- func (p *SynthPalette) BootstrapRegretData() error
- func (p *SynthPalette) CalcForecastImpliedInferences() (map[Worker]*emissionstypes.Inference, error)
- func (p *SynthPalette) CalcWeightedInference(weights RegretInformedWeights) (InferenceValue, error)
- func (p *SynthPalette) CalcWeightsGivenWorkers() (RegretInformedWeights, error)
- func (p SynthPalette) Clone() SynthPalette
- func (p *SynthPalette) GetForecasterRegretsSlice() []alloraMath.Dec
- func (p *SynthPalette) GetInfererRegretsSlice() []alloraMath.Dec
- func (p *SynthPalette) UpdateForecastImpliedInferences() error
- func (p *SynthPalette) UpdateForecastersInfo(newForecasters []Worker) error
- func (p *SynthPalette) UpdateInferersInfo(newInferers []Worker) error
- type SynthPaletteFactory
- type SynthRequest
- type TopicId
- type Weight
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccumulateWeights ¶ added in v0.2.6
func AccumulateWeights( inference *emissionstypes.Inference, weight alloraMath.Dec, noPriorRegret bool, allPeersAreNew bool, runningUnnormalizedI_i alloraMath.Dec, sumWeights alloraMath.Dec, ) (alloraMath.Dec, alloraMath.Dec, error)
func CalcNetworkLosses ¶
func CalcNetworkLosses( stakesByReputer map[Worker]Stake, reputerReportedLosses emissions.ReputerValueBundles, epsilon alloraMath.Dec, ) (emissions.ValueBundle, error)
Assumes stakes are all positive
func CalcWeightFromNormalizedRegret ¶
func CalcWeightFromNormalizedRegret( normalizedRegret alloraMath.Dec, maxNormalizedRegret alloraMath.Dec, pNorm alloraMath.Dec, cNorm alloraMath.Dec, ) (alloraMath.Dec, error)
func ComputeAndBuildEMRegret ¶
func ComputeAndBuildEMRegret( lossA Loss, lossB Loss, previousRegret Regret, alpha alloraMath.Dec, blockHeight BlockHeight, noPreviousRegret bool, ) (emissions.TimestampedValue, error)
func ConvertForecastImpliedInferencesToArrays ¶ added in v0.2.7
func ConvertForecastImpliedInferencesToArrays( workers []Worker, forecastImpliedInferenceByWorker map[string]*types.Inference, ) []*types.WorkerAttributedValue
It is assumed every key of `forecastImpliedInferenceByWorker` is contained within the `workers` slice
func ConvertValueBundleToNetworkLossesByWorker ¶
func ConvertValueBundleToNetworkLossesByWorker( valueBundle emissions.ValueBundle, ) networkLossesByWorker
Convert a ValueBundle to a networkLossesByWorker
func ConvertWeightsToArrays ¶
func ConvertWeightsToArrays(workers []Worker, weights map[Worker]Weight) []*types.RegretInformedWeight
It is assumed every key of `weights` is contained within the `workers` slice
func CosmosIntOneE18 ¶
func CosmosIntOneE18() cosmosMath.Int
func FilterNoncesWithinEpochLength ¶ added in v0.2.6
func FilterNoncesWithinEpochLength(n emissions.Nonces, blockHeight, epochLength int64) emissions.Nonces
Filter nonces that are within the epoch length of the current block height
func GetCalcSetNetworkRegrets ¶
func GetCalcSetNetworkRegrets( ctx sdk.Context, k keeper.Keeper, topicId TopicId, networkLosses emissions.ValueBundle, nonce emissions.Nonce, alpha alloraMath.Dec, ) error
Calculate the new network regrets by taking EMAs between the previous network regrets and the new regrets admitted by the inputted network losses It is assumed the workers are uniquely represented in the network losses
func GetLatestNetworkInference ¶ added in v0.2.8
func GetNetworkInferencesAtBlock ¶ added in v0.2.6
func GetNetworkInferencesAtBlock( ctx sdk.Context, k keeper.Keeper, topicId TopicId, inferencesNonce BlockHeight, previousLossNonce BlockHeight, ) ( *emissions.ValueBundle, map[string]*emissions.Inference, map[string]alloraMath.Dec, map[string]alloraMath.Dec, error, )
Calculates all network inferences in the set I_i given historical state (e.g. regrets) and data from workers (e.g. inferences, forecast-implied inferences) as of a specified block height
func MakeMapFromForecasterToTheirForecast ¶
func MakeMapFromForecasterToTheirForecast(forecasts []*emissions.Forecast) map[Worker]*emissions.Forecast
Create a map from worker address to their inference or forecast-implied inference
func MakeMapFromInfererToTheirInference ¶
func MakeMapFromInfererToTheirInference(inferences []*emissions.Inference) map[Worker]*emissions.Inference
Create a map from worker address to their inference or forecast-implied inference
func SelectTopNReputerNonces ¶ added in v0.2.6
func SelectTopNReputerNonces(reputerRequestNonces *emissions.ReputerRequestNonces, N int, currentBlockHeight int64, groundTruthLag int64) []*emissions.ReputerRequestNonce
Select the top N latest reputer nonces
func SelectTopNWorkerNonces ¶ added in v0.2.6
Select the top N latest worker nonces
func SortByBlockHeight ¶ added in v0.2.6
func SortByBlockHeight(r []*emissions.ReputerRequestNonce)
Types ¶
type BlockHeight ¶
type BlockHeight = int64
type InferenceValue ¶
type InferenceValue = alloraMath.Dec
type InferersNewStatus ¶ added in v0.2.6
type InferersNewStatus int
const ( InferersAllNew InferersNewStatus = iota InferersAllNewExceptOne InferersNotNew )
type Loss ¶
type Loss = alloraMath.Dec
type NetworkInferenceBuilder ¶ added in v0.2.6
type NetworkInferenceBuilder struct {
// contains filtered or unexported fields
}
func NewNetworkInferenceBuilderFromSynthRequest ¶ added in v0.2.6
func NewNetworkInferenceBuilderFromSynthRequest( req SynthRequest, ) (*NetworkInferenceBuilder, error)
func (*NetworkInferenceBuilder) Build ¶ added in v0.2.6
func (b *NetworkInferenceBuilder) Build() *emissions.ValueBundle
Calculates all network inferences in the set I_i given historical state (e.g. regrets) and data from workers (e.g. inferences, forecast-implied inferences). Could improve this with Builder pattern, as for other instances of generated ValueBundles.
func (*NetworkInferenceBuilder) CalcAndSetNetworkInferences ¶ added in v0.2.6
func (b *NetworkInferenceBuilder) CalcAndSetNetworkInferences() *NetworkInferenceBuilder
func (*NetworkInferenceBuilder) SetCombinedValue ¶ added in v0.2.6
func (b *NetworkInferenceBuilder) SetCombinedValue() *NetworkInferenceBuilder
Calculates the network combined inference I_i, Equation 9
func (*NetworkInferenceBuilder) SetForecasterValues ¶ added in v0.2.6
func (b *NetworkInferenceBuilder) SetForecasterValues() *NetworkInferenceBuilder
Map forecast-implied inferences to a WorkerAttributedValue array and set
func (*NetworkInferenceBuilder) SetInfererValues ¶ added in v0.2.6
func (b *NetworkInferenceBuilder) SetInfererValues() *NetworkInferenceBuilder
Map inferences to a WorkerAttributedValue array and set
func (*NetworkInferenceBuilder) SetNaiveValue ¶ added in v0.2.6
func (b *NetworkInferenceBuilder) SetNaiveValue() *NetworkInferenceBuilder
Calculates the network naive inference I^-_i
func (*NetworkInferenceBuilder) SetOneInValues ¶ added in v0.2.6
func (b *NetworkInferenceBuilder) SetOneInValues() *NetworkInferenceBuilder
Set all one-in inferences that are possible given the provided input Assumed that there is at most 1 inference per worker. Also assume that there is at most 1 forecast-implied inference per worker.
func (*NetworkInferenceBuilder) SetOneOutForecasterValues ¶ added in v0.2.6
func (b *NetworkInferenceBuilder) SetOneOutForecasterValues() *NetworkInferenceBuilder
Set all one-out-forecaster inferences that are possible given the provided input Assume that there is at most 1 forecast-implied inference per forecaster Loop over all forecast-implied inferences and withold one, then calculate the network inference less that witheld value
func (*NetworkInferenceBuilder) SetOneOutInfererValues ¶ added in v0.2.6
func (b *NetworkInferenceBuilder) SetOneOutInfererValues() *NetworkInferenceBuilder
Set all one-out-inferer inferences that are possible given the provided input Assumed that there is at most 1 inference per inferer Loop over all inferences and withold one, then calculate the network inference less that witheld inference This involves recalculating the forecast-implied inferences for each withheld inferer
type Regret ¶
type Regret = alloraMath.Dec
type RegretInformedWeights ¶
type RegretInformedWeights struct {
// contains filtered or unexported fields
}
Need to differentiate between the two types of regrets because workers may complete tasks for both roles and may have different regrets for those different roles
type RunningWeightedLoss ¶
func RunningWeightedAvgUpdate ¶
func RunningWeightedAvgUpdate( runningWeightedAvg *RunningWeightedLoss, nextWeight Weight, nextValue Weight, ) (RunningWeightedLoss, error)
Update the running information needed to calculate weighted loss per worker
type Stake ¶
type Stake = cosmosMath.Int
type StatefulRegret ¶ added in v0.2.6
type StatefulRegret struct {
// contains filtered or unexported fields
}
type StdDevRegrets ¶ added in v0.2.6
type StdDevRegrets struct {
// contains filtered or unexported fields
}
type SynthPalette ¶ added in v0.2.6
type SynthPalette struct { Ctx sdk.Context K keeper.Keeper Logger log.Logger TopicId TopicId // Should use this as a source of truth regarding for which inferers to have data calculated // i.e. if an inferer is not present here, calculate a network inference without their data // Must be unique values Inferers []Worker InferenceByWorker map[Worker]*emissions.Inference // Must respect the order of sister `inferers` property InfererRegrets map[Worker]*StatefulRegret // Should use this as a source of truth regarding for which forecasters to have data calculated // i.e. if an forecaster is not present here, calculate a network inference without their data // Must be unique values Forecasters []Worker ForecastByWorker map[Worker]*emissions.Forecast ForecastImpliedInferenceByWorker map[Worker]*emissions.Inference // Must respect the order of sister `forecasters` property ForecasterRegrets map[Worker]*StatefulRegret InferersNewStatus InferersNewStatus SingleNotNewInferer Worker NetworkCombinedLoss Loss Epsilon alloraMath.Dec PNorm alloraMath.Dec CNorm alloraMath.Dec }
func (*SynthPalette) BootstrapRegretData ¶ added in v0.2.6
func (p *SynthPalette) BootstrapRegretData() error
Bootstraps xRegrets, allxsAreNew (x="inferer"|"forecasters") for the inferers and forecasters in the palette Just requires these props:: ctx, k, topicId, inferers, forecasts
func (*SynthPalette) CalcForecastImpliedInferences ¶ added in v0.2.6
func (p *SynthPalette) CalcForecastImpliedInferences() (map[Worker]*emissionstypes.Inference, error)
Calculate the forecast-implied inferences I_ik given inferences, forecasts and network losses. Calculates R_ijk, w_ijk, and I_ik for each forecast k and forecast element (forcast of worker loss) j
Forecast without inference => weight in calculation of I_ik and I_i set to 0. Use latest available regret R_i-1,l Inference without forecast => only weight in calculation of I_ik set to 0 A value of 0 => no inference corresponded to any of the forecasts from a forecaster
Requires: forecasts, inferenceByWorker, allInferersAreNew, networkCombinedLoss, epsilon, pNorm, cNorm Updates: forecastImpliedInferenceByWorker
func (*SynthPalette) CalcWeightedInference ¶ added in v0.2.6
func (p *SynthPalette) CalcWeightedInference(weights RegretInformedWeights) (InferenceValue, error)
Calculates network combined inference I_i, network per worker regret R_i-1,l, and weights w_il from the litepaper: I_i = Σ_l w_il I_il / Σ_l w_il w_il = φ'_p(\hatR_i-1,l) \hatR_i-1,l = R_i-1,l / |max_{l'}(R_i-1,l')| given inferences, forecast-implied inferences, and network regrets
func (*SynthPalette) CalcWeightsGivenWorkers ¶ added in v0.2.6
func (p *SynthPalette) CalcWeightsGivenWorkers() (RegretInformedWeights, error)
Given the current set of inferers and forecasters in the palette, calculate their weights using the current regrets
func (SynthPalette) Clone ¶ added in v0.2.6
func (p SynthPalette) Clone() SynthPalette
Clone creates a deep copy of the SynthPalette.
func (*SynthPalette) GetForecasterRegretsSlice ¶ added in v0.2.6
func (p *SynthPalette) GetForecasterRegretsSlice() []alloraMath.Dec
func (*SynthPalette) GetInfererRegretsSlice ¶ added in v0.2.6
func (p *SynthPalette) GetInfererRegretsSlice() []alloraMath.Dec
func (*SynthPalette) UpdateForecastImpliedInferences ¶ added in v0.2.6
func (p *SynthPalette) UpdateForecastImpliedInferences() error
Calculate the forecast-implied inferences I_ik given inferences, forecasts and network losses. See docs of CalcForecastImpliedInferences for more details on calculation. This calculates and then sets the forecastImpliedInferenceByWorker property of the palette. Requires: forecasts, inferenceByWorker, allInferersAreNew, networkCombinedLoss, epsilon, pNorm, cNorm Updates: forecastImpliedInferenceByWorker
func (*SynthPalette) UpdateForecastersInfo ¶ added in v0.2.12
func (p *SynthPalette) UpdateForecastersInfo(newForecasters []Worker) error
UpdateForecasters updates the forecasters and their related fields in the SynthPalette.
func (*SynthPalette) UpdateInferersInfo ¶ added in v0.2.12
func (p *SynthPalette) UpdateInferersInfo(newInferers []Worker) error
type SynthPaletteFactory ¶ added in v0.2.6
type SynthPaletteFactory struct{}
func (*SynthPaletteFactory) BuildPaletteFromRequest ¶ added in v0.2.6
func (f *SynthPaletteFactory) BuildPaletteFromRequest(req SynthRequest) (SynthPalette, error)
Could use Builder pattern in the future to make this cleaner
type SynthRequest ¶ added in v0.2.6
type SynthRequest struct { Ctx sdk.Context K keeper.Keeper TopicId TopicId Inferences *emissions.Inferences Forecasts *emissions.Forecasts NetworkCombinedLoss Loss Epsilon alloraMath.Dec PNorm alloraMath.Dec CNorm alloraMath.Dec }
type Weight ¶
type Weight = alloraMath.Dec