-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decrease the step size of GreedyBalancer
#1337
Decrease the step size of GreedyBalancer
#1337
Conversation
請問一下這樣做的目的是什麼?跟搜尋品質有關嗎 |
我的直覺是
我修改 double testOptimization(HasClusterCost costFunction, TestCase testcase) {
var newPlan =
Balancer.Official.Greedy.create(
AlgorithmConfig.builder()
.clusterCost(costFunction)
.metricSource(testcase::clusterBean)
.build())
.offer(testcase.clusterInfo(), Duration.ofMillis(300));
if(newPlan.solution().isEmpty())
return Double.NaN;
return newPlan.solution().get().proposalClusterCost().value();
}
@Test
void testCompositeOptimization() {
var testCase = new LargeTestCase(10, 300, 0xfeed);
var costFunction =
HasClusterCost.of(
Map.of(
ingressCost(), 1.0,
egressCost(), 1.0));
var summary = IntStream.range(0, 100)
.mapToDouble(i -> testOptimization(costFunction, testCase))
.filter(i -> !Double.isNaN(i))
.summaryStatistics();
System.out.println(summary.getAverage());
} 上面的 Code 建立一個 10 節點 300 Partition 的情境。重複跑 100 次 Balancer,算分數們的平均。使用的叢集分佈都是同一個,這部分測試結果可能會有點爭議,但問題應該不大。 叢集的初始分數: 1.0757599534006974
上面的簡單測試結果似乎證實了我的直覺,當 Max Step 開越大,我們分數收斂的速度就越慢這樣。 所以調低一點應該比較好。 |
你的直覺還蠻有道理的
請問這個時間是指哪一段?每一步的時間?現在看起來好像執行時間的影響程度還比較大一點? |
common/src/main/java/org/astraea/common/balancer/algorithms/GreedyBalancer.java
Show resolved
Hide resolved
Balancer#offer 傳入的 timeout。 我後來想了一下, Greedy 目前的實作有可能走到比較差的 local min, 所以第二個直覺不太能成立,想要跳脫還是要靠大步伐,但大步伐搭配 shuffle tweaker 走壞的機率很高,是有機會跳脫,但機率不高 |
如果是要討論local optimum 的話,greedy 的概念本來就是這樣,關鍵問題在於那個 local optimum 離 global optimum 有多遠?太遠的話就代表這個題目不適合用 greedy 來做。但很不幸的是global optimum 的估算也是 np-hard。
應該是說 shuffle tweaker 決定了演算法可以“怎麼走”,換言之, shuffle tweaker 其實在整個 balancer 扮演了最重要的角色,如果 shuffle tweaker 每次攤開的“步伐”品質都很差的話,後面演算法怎麼算都是在”很爛的區域內“找一個比較不爛的結果 |
common/src/main/java/org/astraea/common/balancer/algorithms/GreedyBalancer.java
Show resolved
Hide resolved
common/src/main/java/org/astraea/common/balancer/algorithms/GreedyBalancer.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
調低
GreedyBalancer
每次可以走的步長。