Documentation ¶
Index ¶
- func CalcForecastImpliedInferences(args CalcForecastImpliedInferencesArgs) (forecasterToForecastImpliedInference map[Forecaster]*emissionstypes.Inference, ...)
- func CalcNetworkLosses(topicId uint64, blockHeight int64, stakesByReputer map[Worker]Stake, ...) (emissions.ValueBundle, error)
- func CalcTopicInitialRegret(regrets []alloraMath.Dec, epsilon alloraMath.Dec, pNorm alloraMath.Dec, ...) (initialRegret alloraMath.Dec, err 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 ConvertValueBundleToNetworkLossesByWorker(valueBundle emissions.ValueBundle) networkLossesByWorker
- func ConvertWeightsToArrays(workers []Worker, weights map[Worker]Weight) []*emissionstypes.RegretInformedWeight
- func CosmosIntOneE18() cosmosMath.Int
- func GetCalcSetNetworkRegrets(args GetCalcSetNetworkRegretsArgs) error
- func GetCombinedInference(args GetCombinedInferenceArgs) (weights RegretInformedWeights, combinedInference InferenceValue, err error)
- func GetNaiveInference(args GetNaiveInferenceArgs) (naiveInference alloraMath.Dec, err error)
- func GetOneInForecasterInferences(args GetOneInForecasterInferencesArgs) (oneInInferences []*emissions.WorkerAttributedValue, err error)
- func GetOneOutForecasterInferences(args GetOneOutForecasterInferencesArgs) (oneOutForecasterInferences []*emissions.WithheldWorkerAttributedValue, ...)
- func GetOneOutInfererInferences(args GetOneOutInfererInferencesArgs) (oneOutInfererInferences []*emissions.WithheldWorkerAttributedValue, err error)
- 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 CalcForecastImpliedInferencesArgs
- type CalcNetworkInferencesArgs
- type CalcOneOutForecasterInferenceArgs
- type CalcOneOutInfererInferenceArgs
- type Forecaster
- type GetCalcSetNetworkRegretsArgs
- type GetCombinedInferenceArgs
- type GetNaiveInferenceArgs
- type GetNetworkInferencesResult
- type GetOneInForecasterInferencesArgs
- type GetOneOutForecasterInferencesArgs
- type GetOneOutInfererInferencesArgs
- type InferenceValue
- type Inferer
- type Loss
- type Regret
- type RegretInformedWeights
- type RunningWeightedLoss
- type Stake
- type TopicId
- type Weight
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcForecastImpliedInferences ¶ added in v0.6.0
func CalcForecastImpliedInferences(args CalcForecastImpliedInferencesArgs) ( forecasterToForecastImpliedInference map[Forecaster]*emissionstypes.Inference, infererToRegretOut map[Inferer]*Regret, forecasterToRegretOut map[Forecaster]*Regret, err 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 (forecast 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
func CalcNetworkLosses ¶
func CalcNetworkLosses( topicId uint64, blockHeight int64, stakesByReputer map[Worker]Stake, reputerReportedLosses emissions.ReputerValueBundles, ) (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, quantile alloraMath.Dec, pNormDiv alloraMath.Dec, ) (initialRegret alloraMath.Dec, err error)
When using fallback regrets (not enough experienced workers / cold start):
initialRegret = percentile(regrets, 25)
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 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(args GetCalcSetNetworkRegretsArgs) error
Calculate the new network regrets by taking EMAs between the previous network regrets and the new regrets admitted by the inputted network losses NOTE: It is assumed the workers are uniquely represented in the network losses NOTE: It is assumed network losses are sorted (done in synth.CalcNetworkLosses())
func GetCombinedInference ¶ added in v0.6.0
func GetCombinedInference(args GetCombinedInferenceArgs) ( weights RegretInformedWeights, combinedInference InferenceValue, err error)
Calculates the network combined inference I_i, Equation 9
func GetNaiveInference ¶ added in v0.6.0
func GetNaiveInference(args GetNaiveInferenceArgs) (naiveInference alloraMath.Dec, err error)
Calculates the network naive inference I^-_i
func GetOneInForecasterInferences ¶ added in v0.6.0
func GetOneInForecasterInferences(args GetOneInForecasterInferencesArgs) ( oneInInferences []*emissions.WorkerAttributedValue, err error, )
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 GetOneOutForecasterInferences ¶ added in v0.6.0
func GetOneOutForecasterInferences(args GetOneOutForecasterInferencesArgs) ( oneOutForecasterInferences []*emissions.WithheldWorkerAttributedValue, err error, )
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 withhold one, then calculate the network inference less that withheld value
func GetOneOutInfererInferences ¶ added in v0.6.0
func GetOneOutInfererInferences(args GetOneOutInfererInferencesArgs) ( oneOutInfererInferences []*emissions.WithheldWorkerAttributedValue, err error, )
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 withhold one, then calculate the network inference less that withheld inference This involves recalculating the forecast-implied inferences for each withheld inferer
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 CalcForecastImpliedInferencesArgs ¶ added in v0.6.0
type CalcForecastImpliedInferencesArgs struct { Logger log.Logger TopicId uint64 AllInferersAreNew bool Inferers []Inferer InfererToInference map[Inferer]*emissionstypes.Inference InfererToRegret map[Inferer]*Regret Forecasters []Forecaster ForecasterToForecast map[Forecaster]*emissionstypes.Forecast ForecasterToRegret map[Forecaster]*Regret NetworkCombinedLoss alloraMath.Dec EpsilonTopic alloraMath.Dec PNorm alloraMath.Dec CNorm alloraMath.Dec }
Args for the CalcForecastImpliedInferences function
type CalcNetworkInferencesArgs ¶ added in v0.6.0
type CalcNetworkInferencesArgs struct { Ctx sdk.Context K emissionskeeper.Keeper Logger log.Logger TopicId uint64 Inferers []Inferer InfererToInference map[Inferer]*emissions.Inference InfererToRegret map[Inferer]*Regret AllInferersAreNew bool Forecasters []Forecaster ForecasterToForecast map[Forecaster]*emissions.Forecast ForecasterToRegret map[Forecaster]*Regret ForecasterToForecastImpliedInference map[Forecaster]*emissions.Inference NetworkCombinedLoss alloraMath.Dec EpsilonTopic alloraMath.Dec EpsilonSafeDiv alloraMath.Dec PNorm alloraMath.Dec CNorm alloraMath.Dec }
Arguments to CalcNetworkInferences
func GetCalcNetworkInferenceArgs ¶ added in v0.6.0
func GetCalcNetworkInferenceArgs( ctx sdk.Context, k emissionskeeper.Keeper, topicId uint64, inferences *emissions.Inferences, forecasts *emissions.Forecasts, topic emissions.Topic, networkLosses emissions.ValueBundle, moduleParams emissions.Params, ) ( calcArgs CalcNetworkInferencesArgs, err error, )
helper function for getting the args needed for calcNetworkInferences we have to convert the inferences and forecasts to maps and sort the inferers and forecasters so that GetNetworkInference can use them
type CalcOneOutForecasterInferenceArgs ¶ added in v0.6.0
type CalcOneOutForecasterInferenceArgs struct { Ctx sdk.Context K emissionskeeper.Keeper Logger log.Logger TopicId uint64 Inferers []Inferer InfererToInference map[Inferer]*emissions.Inference InfererToRegret map[Inferer]*Regret AllInferersAreNew bool Forecasters []Forecaster ForecasterToForecast map[Forecaster]*emissions.Forecast ForecasterToForecastImpliedInference map[Forecaster]*emissions.Inference EpsilonTopic alloraMath.Dec EpsilonSafeDiv alloraMath.Dec PNorm alloraMath.Dec CNorm alloraMath.Dec WithheldForecaster Forecaster }
Arguments for calcOneOutForecasterInference
type CalcOneOutInfererInferenceArgs ¶ added in v0.6.0
type CalcOneOutInfererInferenceArgs struct { Ctx sdk.Context K emissionskeeper.Keeper Logger log.Logger TopicId uint64 Inferers []Inferer InfererToInference map[Inferer]*emissions.Inference InfererToRegret map[Inferer]*Regret AllInferersAreNew bool Forecasters []Forecaster ForecasterToForecast map[Forecaster]*emissions.Forecast ForecasterToRegret map[Forecaster]*Regret NetworkCombinedLoss alloraMath.Dec EpsilonTopic alloraMath.Dec EpsilonSafeDiv alloraMath.Dec PNorm alloraMath.Dec CNorm alloraMath.Dec WithheldInferer Inferer }
Arguments for calcOneOutInfererInference
type Forecaster ¶ added in v0.6.0
type Forecaster = string
type GetCalcSetNetworkRegretsArgs ¶ added in v0.6.0
type GetCalcSetNetworkRegretsArgs struct { Ctx sdk.Context K keeper.Keeper TopicId TopicId NetworkLosses emissions.ValueBundle Nonce emissions.Nonce AlphaRegret alloraMath.Dec CNorm alloraMath.Dec PNorm alloraMath.Dec EpsilonTopic alloraMath.Dec InitialRegretQuantile alloraMath.Dec PNormSafeDiv alloraMath.Dec }
args for GetCalcSetNetworkRegrets
type GetCombinedInferenceArgs ¶ added in v0.6.0
type GetCombinedInferenceArgs struct { Logger log.Logger TopicId uint64 Inferers []Worker InfererToInference map[Worker]*emissions.Inference InfererToRegret map[Worker]*alloraMath.Dec AllInferersAreNew bool Forecasters []Worker ForecasterToRegret map[Worker]*alloraMath.Dec ForecasterToForecastImpliedInference map[Worker]*emissions.Inference EpsilonTopic alloraMath.Dec EpsilonSafeDiv alloraMath.Dec PNorm alloraMath.Dec CNorm alloraMath.Dec }
Arguments for GetCombinedInference
type GetNaiveInferenceArgs ¶ added in v0.6.0
type GetNaiveInferenceArgs struct { Ctx context.Context Logger log.Logger TopicId uint64 K emissionskeeper.Keeper Inferers []Worker InfererToInference map[Worker]*emissions.Inference AllInferersAreNew bool Forecasters []Worker ForecasterToRegret map[Worker]*alloraMath.Dec ForecasterToForecastImpliedInference map[Worker]*emissions.Inference EpsilonTopic alloraMath.Dec EpsilonSafeDiv alloraMath.Dec PNorm alloraMath.Dec CNorm alloraMath.Dec }
Arguments for GetNaiveInference
type GetNetworkInferencesResult ¶ added in v0.6.0
type GetNetworkInferencesResult struct { NetworkInferences *emissions.ValueBundle InfererToWeight map[Inferer]Weight ForecasterToWeight map[Forecaster]Weight InferenceBlockHeight int64 LossBlockHeight int64 }
func GetNetworkInferences ¶ added in v0.4.0
func GetNetworkInferences( ctx sdk.Context, k emissionskeeper.Keeper, topicId TopicId, inferencesNonce *BlockHeight, ) (*GetNetworkInferencesResult, error)
type GetOneInForecasterInferencesArgs ¶ added in v0.6.0
type GetOneInForecasterInferencesArgs struct { Ctx sdk.Context K emissionskeeper.Keeper Logger log.Logger TopicId uint64 Inferers []Inferer InfererToInference map[Inferer]*emissions.Inference AllInferersAreNew bool Forecasters []Forecaster ForecasterToForecast map[Forecaster]*emissions.Forecast ForecasterToForecastImpliedInference map[Forecaster]*emissions.Inference EpsilonTopic alloraMath.Dec EpsilonSafeDiv alloraMath.Dec PNorm alloraMath.Dec CNorm alloraMath.Dec }
Arguments to GetOneInForecasterInferences
type GetOneOutForecasterInferencesArgs ¶ added in v0.6.0
type GetOneOutForecasterInferencesArgs struct { Ctx sdk.Context K emissionskeeper.Keeper Logger log.Logger TopicId uint64 Inferers []Inferer InfererToInference map[Inferer]*emissions.Inference InfererToRegret map[Inferer]*Regret AllInferersAreNew bool Forecasters []Forecaster ForecasterToForecast map[Forecaster]*emissions.Forecast ForecasterToRegret map[Forecaster]*Regret ForecasterToForecastImpliedInference map[Forecaster]*emissions.Inference EpsilonTopic alloraMath.Dec EpsilonSafeDiv alloraMath.Dec PNorm alloraMath.Dec CNorm alloraMath.Dec }
GetOneOutForecasterInferencesArgs is the set of arguments for the GetOneOutForecasterInferences function
type GetOneOutInfererInferencesArgs ¶ added in v0.6.0
type GetOneOutInfererInferencesArgs struct { Ctx sdk.Context K emissionskeeper.Keeper Logger log.Logger TopicId uint64 Inferers []Inferer InfererToInference map[Inferer]*emissions.Inference InfererToRegret map[Inferer]*Regret AllInferersAreNew bool Forecasters []Forecaster ForecasterToForecast map[Forecaster]*emissions.Forecast ForecasterToRegret map[Forecaster]*Regret NetworkCombinedLoss alloraMath.Dec EpsilonTopic alloraMath.Dec EpsilonSafeDiv alloraMath.Dec PNorm alloraMath.Dec CNorm alloraMath.Dec }
args for GetOneOutInfererInferences
type InferenceValue ¶
type InferenceValue = alloraMath.Dec
type Loss ¶
type Loss = alloraMath.Dec
type Regret ¶
type Regret = alloraMath.Dec
type RegretInformedWeights ¶
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
func CalcNetworkInferences ¶ added in v0.6.0
func CalcNetworkInferences( args CalcNetworkInferencesArgs, ) ( inferenceBundle *emissions.ValueBundle, weights RegretInformedWeights, err 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). Could improve this with Builder pattern, as for other instances of generated ValueBundles.
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 Weight ¶
type Weight = alloraMath.Dec