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 17:37:01 UTC

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

i3wangyi 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_r330680528
 
 

 ##########
 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 see. You'd like to have a more distinguished value distribution from 1% - 100%. I could leave the alpha and let each soft constraint that's focused on **usage percentage** to have a default alpha of something. 

----------------------------------------------------------------
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