Documentation ¶
Index ¶
- func AccumulateWeights(inference *emissionstypes.Inference, weight alloraMath.Dec, ...) (alloraMath.Dec, alloraMath.Dec, error)
- func CalcNetworkLosses(stakesByReputer map[Worker]Stake, ...) (emissions.ValueBundle, error)
- func CalcTopicInitialRegret(regrets []alloraMath.Dec, epsilon alloraMath.Dec, pNorm alloraMath.Dec, ...) (alloraMath.Dec, 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, ...) []*emissionstypes.WorkerAttributedValue
- func ConvertValueBundleToNetworkLossesByWorker(valueBundle emissions.ValueBundle) networkLossesByWorker
- func ConvertWeightsToArrays(workers []Worker, weights map[Worker]Weight) []*emissionstypes.RegretInformedWeight
- func CosmosIntOneE18() cosmosMath.Int
- 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 []*emissionstypes.Forecast) map[Worker]*emissionstypes.Forecast
- func MakeMapFromInfererToTheirInference(inferences []*emissionstypes.Inference) map[Worker]*emissionstypes.Inference
- type BlockHeight
- type InferenceValue
- 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 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 ¶
func AccumulateWeights( inference *emissionstypes.Inference, weight alloraMath.Dec, 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 CalcTopicInitialRegret ¶ added in v0.2.13
func CalcTopicInitialRegret(regrets []alloraMath.Dec, epsilon alloraMath.Dec, pNorm alloraMath.Dec, cNorm alloraMath.Dec) (alloraMath.Dec, error)
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, ) (emissions.TimestampedValue, error)
func ConvertForecastImpliedInferencesToArrays ¶ added in v0.2.7
func ConvertForecastImpliedInferencesToArrays( workers []Worker, forecastImpliedInferenceByWorker map[string]*emissionstypes.Inference, ) []*emissionstypes.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 ¶ added in v0.2.7
func ConvertWeightsToArrays(workers []Worker, weights map[Worker]Weight) []*emissionstypes.RegretInformedWeight
It is assumed every key of `weights` is contained within the `workers` slice
func CosmosIntOneE18 ¶
func CosmosIntOneE18() cosmosMath.Int
func GetCalcSetNetworkRegrets ¶
func GetCalcSetNetworkRegrets( ctx sdk.Context, k keeper.Keeper, topicId TopicId, networkLosses emissions.ValueBundle, nonce emissions.Nonce, alpha alloraMath.Dec, cNorm alloraMath.Dec, pNorm alloraMath.Dec, epsilon 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 ¶
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 []*emissionstypes.Forecast) map[Worker]*emissionstypes.Forecast
Create a map from worker address to their inference or forecast-implied inference
func MakeMapFromInfererToTheirInference ¶
func MakeMapFromInfererToTheirInference(inferences []*emissionstypes.Inference) map[Worker]*emissionstypes.Inference
Create a map from worker address to their inference or forecast-implied inference
Types ¶
type BlockHeight ¶
type BlockHeight = int64
type InferenceValue ¶
type InferenceValue = alloraMath.Dec
type Loss ¶
type Loss = alloraMath.Dec
type NetworkInferenceBuilder ¶
type NetworkInferenceBuilder struct {
// contains filtered or unexported fields
}
func NewNetworkInferenceBuilderFromSynthRequest ¶
func NewNetworkInferenceBuilderFromSynthRequest( req SynthRequest, ) (*NetworkInferenceBuilder, error)
func (*NetworkInferenceBuilder) Build ¶
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 ¶
func (b *NetworkInferenceBuilder) CalcAndSetNetworkInferences() *NetworkInferenceBuilder
func (*NetworkInferenceBuilder) SetCombinedValue ¶
func (b *NetworkInferenceBuilder) SetCombinedValue() *NetworkInferenceBuilder
Calculates the network combined inference I_i, Equation 9
func (*NetworkInferenceBuilder) SetForecasterValues ¶
func (b *NetworkInferenceBuilder) SetForecasterValues() *NetworkInferenceBuilder
Map forecast-implied inferences to a WorkerAttributedValue array and set
func (*NetworkInferenceBuilder) SetInfererValues ¶
func (b *NetworkInferenceBuilder) SetInfererValues() *NetworkInferenceBuilder
Map inferences to a WorkerAttributedValue array and set
func (*NetworkInferenceBuilder) SetNaiveValue ¶
func (b *NetworkInferenceBuilder) SetNaiveValue() *NetworkInferenceBuilder
Calculates the network naive inference I^-_i
func (*NetworkInferenceBuilder) SetOneInValues ¶
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 ¶
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 ¶
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 SynthPalette ¶
type SynthPalette struct { Ctx sdk.Context K keeper.Keeper Logger log.Logger TopicId TopicId AllInferersAreNew bool // 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]*alloraMath.Dec // 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]*alloraMath.Dec NetworkCombinedLoss Loss EpsilonTopic alloraMath.Dec EpsilonSafeDiv alloraMath.Dec PNorm alloraMath.Dec CNorm alloraMath.Dec }
func (*SynthPalette) BootstrapRegretData ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (p SynthPalette) Clone() SynthPalette
Clone creates a deep copy of the SynthPalette.
func (*SynthPalette) GetForecasterRegretsSlice ¶
func (p *SynthPalette) GetForecasterRegretsSlice() []alloraMath.Dec
func (*SynthPalette) GetInfererRegretsSlice ¶
func (p *SynthPalette) GetInfererRegretsSlice() []alloraMath.Dec
func (*SynthPalette) UpdateForecastImpliedInferences ¶
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 ¶
type SynthPaletteFactory struct{}
func (*SynthPaletteFactory) BuildPaletteFromRequest ¶
func (f *SynthPaletteFactory) BuildPaletteFromRequest(req SynthRequest) (SynthPalette, error)
Could use Builder pattern in the future to make this cleaner
type SynthRequest ¶
type SynthRequest struct { Ctx sdk.Context K keeper.Keeper TopicId TopicId Inferences *emissions.Inferences Forecasts *emissions.Forecasts NetworkCombinedLoss Loss EpsilonTopic alloraMath.Dec EpsilonSafeDiv alloraMath.Dec PNorm alloraMath.Dec CNorm alloraMath.Dec }
type Weight ¶
type Weight = alloraMath.Dec