Last active
December 10, 2021 12:14
-
-
Save samueleresca/5f404cd9d90d449a6f80ecaafa42fb35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (qs QuorumSystem) loadOptimalStrategy( | |
optimize OptimizeType, | |
readQuorums []ExprSet, | |
writeQuorums []ExprSet, | |
readFraction DistributionValues, | |
loadLimit *float64, | |
networkLimit *float64, | |
latencyLimit *float64) (*Strategy, error) { | |
... | |
buildNetworkDef := func(networkLimit *float64) lpDefinition { | |
def := newDefinitionWithVarsAndConstraints(readQuorumVars, writeQuorumVars) | |
objExpr := make([]float64, len(def.Vars)) | |
// network_def - inf <= network_def <= +inf | |
for _, v := range readQuorumVars { | |
objExpr[v.Index] = fr * float64(len(v.Quorum)) | |
} | |
for _, v := range writeQuorumVars { | |
objExpr[v.Index] = (1 - fr) * float64(len(v.Quorum)) | |
} | |
objExpr = append([]float64{ninf}, objExpr...) | |
if networkLimit == nil { | |
objExpr = append(objExpr, pinf) | |
} else { | |
objExpr = append(objExpr, *networkLimit) | |
} | |
def.Objectives = append(def.Objectives, objExpr) | |
return def | |
} | |
... | |
return &newStrategy, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment