You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2019/10/02 00:17:51 UTC

[GitHub] [helix] jiajunwang commented on a change in pull request #488: Implement soft constraint based on f(x) = tanh(1/x)

jiajunwang commented on a change in pull request #488: Implement soft constraint based on f(x) = tanh(1/x)
URL: https://github.com/apache/helix/pull/488#discussion_r330329303
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/SoftConstraint.java
 ##########
 @@ -86,11 +60,11 @@ float getAssignmentNormalizedScore(AssignableNode node, AssignableReplica replic
   }
 
   /**
-   * The default scaler function that squashes any score within (min_score, max_score) to (0, 1);
+   * The default normalize function f(x) = tanh(1/(\alpha * x)) that squashes any score >= 0 to (0, 1]
+   * The hyper parameter determines the converging rate of scores to 0 when X gets larger
    * Child class could override the method and customize the method on its own
-   * @return The MinMaxScaler instance by default
    */
   NormalizeFunction getNormalizeFunction() {
-    return (score) -> (score - getMinScore()) / (getMaxScore() - getMinScore());
+    return score -> (score == 0f ? 1f : (float) Math.tanh(1 / score));
 
 Review comment:
   I tried this formula a little bit. So the range is (0, 1], as expected. One concern is that while I try Math.tanh((float)20), the value returned by Math lib is 1. That means any utilization between 0% and 5% would be evaluated the same by this implementation, right?
   Can we make it more accurate, at least to 1% or even 0.1%. I think we can setup the alpha for this, right?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org