Skip to content

Commit

Permalink
Merge pull request #43 from Swarm-Bachelor/calc-on-output
Browse files Browse the repository at this point in the history
Calc on output
  • Loading branch information
filigott authored Apr 14, 2023
2 parents 694da99 + ce5c2b2 commit 9dd2c32
Show file tree
Hide file tree
Showing 15 changed files with 1,342 additions and 293 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# vendor/

.idea/**
.results/*.txt
**/results/*.txt

**/states.json
**/routes.txt
Expand Down
18 changes: 15 additions & 3 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#### Experiments ####
#### Global Configurations ####

# Global configuration options, defaults in comment
ConfOptions:
Expand Down Expand Up @@ -44,6 +44,18 @@ ConfOptions:
DebugInterval: 1_000_000
# NumGoroutines: -1, number of active goroutines, leave at -1 for automatically using numCPU
NumGoroutines: -1
# Enabled the outputWorker which handles writing output to file and analysis of results
OutputEnabled: true
# Which logic should be used in the outputWorker
OutputOptions:
MeanRewardPerForward: true
AverageNumberOfHops: false
AverageFractionOfTotalRewardsK8: false
AverageFractionOfTotalRewardsK16: false
RewardFairnessForForwardingAction: false
RewardFairnessForStoringAction: false
RewardFairnessForAllActions: false
NegativeIncome: false

# Experiments to choose from:
# omega: maxPoCheckEnabled
Expand All @@ -52,10 +64,10 @@ ConfOptions:
# custom: custom, defined below

Experiment:
ExperimentName: "custom"
Name: "custom"

# Defines your own custom experiment
Custom:
CustomExperiment:
# ThresholdEnabled: true, enabling the maximum limit of debt an edge can have in one direction
ThresholdEnabled: true
# ForgivenessEnabled: true, edge debt gets forgiven some amount on an interval (amortized)
Expand Down
108 changes: 44 additions & 64 deletions config/config_types.go
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
package config

type Yml struct {
ConfOptions ConfVariables `yaml:"ConfOptions"`
Experiment Experiment `yaml:"Experiment"`
Custom CustomVariables `yaml:"Custom"`
ConfOptions confOptions `yaml:"ConfOptions"`
Experiment experiment `yaml:"Experiment"`
CustomExperiment experimentOptions `yaml:"CustomExperiment"`
}

type Experiment struct {
ExperimentName string `yaml:"ExperimentName"`
type experiment struct {
Name string `yaml:"Name"`
}

type ConfVariables struct {
Iterations int `yaml:"Iterations"`
Bits int `yaml:"Bits"`
NetworkSize int `yaml:"NetworkSize"`
BinSize int `yaml:"BinSize"`
RangeAddress int `yaml:"RangeAddress"`
Originators int `yaml:"Originators"`
RefreshRate int `yaml:"RefreshRate"`
Threshold int `yaml:"Threshold"`
RandomSeed int64 `yaml:"RandomSeed"`
MaxProximityOrder int `yaml:"MaxProximityOrder"`
Price int `yaml:"Price"`
RequestsPerSecond int `yaml:"RequestsPerSecond"`
EdgeLock bool `yaml:"EdgeLock"`
SameOriginator bool `yaml:"SameOriginator"`
PrecomputeRespNodes bool `yaml:"PrecomputeRespNodes"`
WriteRoutesToFile bool `yaml:"WriteRoutesToFile"`
WriteStatesToFile bool `yaml:"WriteStatesToFile"`
IterationMeansUniqueChunk bool `yaml:"IterationMeansUniqueChunk"`
DebugPrints bool `yaml:"DebugPrints"`
DebugInterval int `yaml:"DebugInterval"`
NumGoroutines int `yaml:"NumGoroutines"`
type VariablesType struct {
confOptions confOptions
experimentOptions experimentOptions
}

type confOptions struct {
Iterations int `yaml:"Iterations"`
Bits int `yaml:"Bits"`
NetworkSize int `yaml:"NetworkSize"`
BinSize int `yaml:"BinSize"`
RangeAddress int `yaml:"RangeAddress"`
Originators int `yaml:"Originators"`
RefreshRate int `yaml:"RefreshRate"`
Threshold int `yaml:"Threshold"`
RandomSeed int64 `yaml:"RandomSeed"`
MaxProximityOrder int `yaml:"MaxProximityOrder"`
Price int `yaml:"Price"`
RequestsPerSecond int `yaml:"RequestsPerSecond"`
EdgeLock bool `yaml:"EdgeLock"`
SameOriginator bool `yaml:"SameOriginator"`
PrecomputeRespNodes bool `yaml:"PrecomputeRespNodes"`
WriteRoutesToFile bool `yaml:"WriteRoutesToFile"`
WriteStatesToFile bool `yaml:"WriteStatesToFile"`
IterationMeansUniqueChunk bool `yaml:"IterationMeansUniqueChunk"`
DebugPrints bool `yaml:"DebugPrints"`
DebugInterval int `yaml:"DebugInterval"`
NumGoroutines int `yaml:"NumGoroutines"`
OutputEnabled bool `yaml:"OutputEnabled"`
OutputOptions outputOptions `yaml:"OutputOptions"`
}

type CustomVariables struct {
type experimentOptions struct {
ThresholdEnabled bool `yaml:"ThresholdEnabled"`
ForgivenessEnabled bool `yaml:"ForgivenessEnabled"`
ForgivenessDuringRouting bool `yaml:"ForgivenessDuringRouting"`
Expand All @@ -51,40 +58,13 @@ type CustomVariables struct {
PayIfOrigPays bool `yaml:"PayIfOrigPays"`
}

type VariablesType struct {
Iterations int
Bits int
NetworkSize int
BinSize int
RangeAddress int
Originators int
RefreshRate int
Threshold int
RandomSeed int64
MaxProximityOrder int
Price int
RequestsPerSecond int
ThresholdEnabled bool
ForgivenessEnabled bool
ForgivenessDuringRouting bool
PaymentEnabled bool
MaxPOCheckEnabled bool
WaitingEnabled bool
OnlyOriginatorPays bool
PayOnlyForCurrentRequest bool
PayIfOrigPays bool
ForwardersPayForceOriginatorToPay bool
RetryWithAnotherPeer bool
CacheIsEnabled bool
PreferredChunks bool
AdjustableThreshold bool
EdgeLock bool
SameOriginator bool
PrecomputeRespNodes bool
WriteRoutesToFile bool
WriteStatesToFile bool
IterationMeansUniqueChunk bool
DebugPrints bool
DebugInterval int
NumGoroutines int
type outputOptions struct {
MeanRewardPerForward bool `yaml:"MeanRewardPerForward"`
AverageNumberOfHops bool `yaml:"AverageNumberOfHops"`
AverageFractionOfTotalRewardsK8 bool `yaml:"AverageFractionOfTotalRewardsK8"`
AverageFractionOfTotalRewardsK16 bool `yaml:"AverageFractionOfTotalRewardsK16"`
RewardFairnessForForwardingAction bool `yaml:"RewardFairnessForForwardingAction"`
RewardFairnessForStoringAction bool `yaml:"RewardFairnessForStoringAction"`
RewardFairnessForAllActions bool `yaml:"RewardFairnessForAllActions"`
NegativeIncome bool `yaml:"NegativeIncome"`
}
89 changes: 54 additions & 35 deletions config/default_variables.go
Original file line number Diff line number Diff line change
@@ -1,39 +1,58 @@
package config

func GetDefaultVariables() VariablesType {
return defaultVariables
}

var defaultVariables = VariablesType{
Iterations: 10_000_000, // 10_000_000
Bits: 16, // 16
NetworkSize: 10000, // 10000
BinSize: 16, // 16
RangeAddress: 65536, // 2 ** Bits
Originators: 1000, // 0.01 * NetworkSize
RefreshRate: 8, // 8
Threshold: 16, // 16
RandomSeed: 123456789, // 123456789
MaxProximityOrder: 16, // 16
Price: 1, // 1
RequestsPerSecond: 12500, // 12500
ThresholdEnabled: true, // true
ForgivenessEnabled: true, // true
ForgivenessDuringRouting: true, // true
PaymentEnabled: false, // false
MaxPOCheckEnabled: false, // false
OnlyOriginatorPays: false, // false
PayOnlyForCurrentRequest: false, // false
PayIfOrigPays: false, // false
ForwardersPayForceOriginatorToPay: false, // false
WaitingEnabled: false, // false
RetryWithAnotherPeer: false, // false
CacheIsEnabled: false, // false
PreferredChunks: false, // false
AdjustableThreshold: false, // false
EdgeLock: true, // false
SameOriginator: false, // false
PrecomputeRespNodes: true, // false
WriteRoutesToFile: false, // false
WriteStatesToFile: false, // false
IterationMeansUniqueChunk: false, // false
DebugPrints: false, // false
DebugInterval: 1000000, // 1000000
NumGoroutines: -1, // -1, gets overwritten by numCPU
confOptions: confOptions{
Iterations: 10_000_000, // 10_000_000
Bits: 16, // 16
NetworkSize: 10000, // 10000
BinSize: 16, // 16
RangeAddress: 65536, // 2 ** Bits
Originators: 1000, // 0.01 * NetworkSize
RefreshRate: 8, // 8
Threshold: 16, // 16
RandomSeed: 123456789, // 123456789
MaxProximityOrder: 16, // 16
Price: 1, // 1
RequestsPerSecond: 12500, // 12500
EdgeLock: true, // false
SameOriginator: false, // false
PrecomputeRespNodes: true, // false
WriteRoutesToFile: false, // false
WriteStatesToFile: false, // false
IterationMeansUniqueChunk: false, // false
DebugPrints: false, // false
DebugInterval: 1000000, // 1000000
NumGoroutines: -1, // -1 means gets overwritten by numCPU
OutputEnabled: false, // false
OutputOptions: outputOptions{
MeanRewardPerForward: false, // false
AverageNumberOfHops: false, // false
AverageFractionOfTotalRewardsK8: false, // false
AverageFractionOfTotalRewardsK16: false, // false
RewardFairnessForForwardingAction: false, // false
RewardFairnessForStoringAction: false, // false
RewardFairnessForAllActions: false, // false
NegativeIncome: false, // false
},
},
experimentOptions: experimentOptions{
ThresholdEnabled: true, // true
ForgivenessEnabled: true, // true
ForgivenessDuringRouting: true, // true
PaymentEnabled: false, // false
MaxPOCheckEnabled: false, // false
OnlyOriginatorPays: false, // false
PayOnlyForCurrentRequest: false, // false
PayIfOrigPays: false, // false
ForwardersPayForceOriginatorToPay: false, // false
WaitingEnabled: false, // false
RetryWithAnotherPeer: false, // false
CacheIsEnabled: false, // false
PreferredChunks: false, // false
AdjustableThreshold: false, // false
},
}
38 changes: 19 additions & 19 deletions config/defined_experiments.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ package config
// These functions modify the respective fields based changes from default

func OmegaExperiment() {
Variables.ThresholdEnabled = false
Variables.ForgivenessEnabled = false
Variables.ForgivenessDuringRouting = false
Variables.MaxPOCheckEnabled = true
Variables.experimentOptions.ThresholdEnabled = false
Variables.experimentOptions.ForgivenessEnabled = false
Variables.experimentOptions.ForgivenessDuringRouting = false
Variables.experimentOptions.MaxPOCheckEnabled = true
}

func CustomExperiment(customExperiment CustomVariables) {
Variables.ThresholdEnabled = customExperiment.ThresholdEnabled
Variables.ForgivenessEnabled = customExperiment.ForgivenessEnabled
Variables.ForgivenessDuringRouting = customExperiment.ForgivenessDuringRouting
Variables.PaymentEnabled = customExperiment.PaymentEnabled
Variables.MaxPOCheckEnabled = customExperiment.MaxPOCheckEnabled
Variables.OnlyOriginatorPays = customExperiment.OnlyOriginatorPays
Variables.PayOnlyForCurrentRequest = customExperiment.PayOnlyForCurrentRequest
Variables.ForwardersPayForceOriginatorToPay = customExperiment.ForwardersPayForceOriginatorToPay
Variables.WaitingEnabled = customExperiment.WaitingEnabled
Variables.RetryWithAnotherPeer = customExperiment.RetryWithAnotherPeer
Variables.CacheIsEnabled = customExperiment.CacheIsEnabled
Variables.PreferredChunks = customExperiment.PreferredChunks
Variables.AdjustableThreshold = customExperiment.AdjustableThreshold
Variables.PayIfOrigPays = customExperiment.PayIfOrigPays
func CustomExperiment(customExperiment experimentOptions) {
Variables.experimentOptions.ThresholdEnabled = customExperiment.ThresholdEnabled
Variables.experimentOptions.ForgivenessEnabled = customExperiment.ForgivenessEnabled
Variables.experimentOptions.ForgivenessDuringRouting = customExperiment.ForgivenessDuringRouting
Variables.experimentOptions.PaymentEnabled = customExperiment.PaymentEnabled
Variables.experimentOptions.MaxPOCheckEnabled = customExperiment.MaxPOCheckEnabled
Variables.experimentOptions.OnlyOriginatorPays = customExperiment.OnlyOriginatorPays
Variables.experimentOptions.PayOnlyForCurrentRequest = customExperiment.PayOnlyForCurrentRequest
Variables.experimentOptions.ForwardersPayForceOriginatorToPay = customExperiment.ForwardersPayForceOriginatorToPay
Variables.experimentOptions.WaitingEnabled = customExperiment.WaitingEnabled
Variables.experimentOptions.RetryWithAnotherPeer = customExperiment.RetryWithAnotherPeer
Variables.experimentOptions.CacheIsEnabled = customExperiment.CacheIsEnabled
Variables.experimentOptions.PreferredChunks = customExperiment.PreferredChunks
Variables.experimentOptions.AdjustableThreshold = customExperiment.AdjustableThreshold
Variables.experimentOptions.PayIfOrigPays = customExperiment.PayIfOrigPays
}
Loading

0 comments on commit 9dd2c32

Please sign in to comment.