|
|
@@ -49,8 +49,11 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
@ApolloJsonValue("${h5.score.suppress:{}}")
|
|
|
private Map<String, Double> h5ScoreSuppress;
|
|
|
|
|
|
- @ApolloJsonValue("${rerank.strategy.flow.control:{}}")
|
|
|
- private Map<String, Double> flowControlParams;
|
|
|
+ @ApolloJsonValue("${rerank.strategy.flow.ctl.customer:{}}")
|
|
|
+ private Map<String, Double> flowCtlCustomerParams;
|
|
|
+
|
|
|
+ @ApolloJsonValue("${rerank.strategy.flow.ctl.agent:{}}")
|
|
|
+ private Map<String, Double> flowCtlAgentParams;
|
|
|
|
|
|
@ApolloJsonValue("${rerank.root.session.id.tail.config:[]}")
|
|
|
private List<RootSessionIdExpConfig> rerankRootSessionIdConfig;
|
|
|
@@ -1355,8 +1358,11 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
}
|
|
|
hit.add(rerankStrategy);
|
|
|
switch (rerankStrategy) {
|
|
|
- case "flowControl":
|
|
|
- calFlowControlWeight(layer, items);
|
|
|
+ case "flowCtlC":
|
|
|
+ calFlowControlWeight(rerankStrategy, layer, items, flowCtlCustomerParams);
|
|
|
+ break;
|
|
|
+ case "flowCtlA":
|
|
|
+ calFlowControlWeight(rerankStrategy, layer, items, flowCtlAgentParams);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
@@ -1369,12 +1375,11 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
}
|
|
|
|
|
|
// 控制流量
|
|
|
- protected void calFlowControlWeight(String layer, List<AdRankItem> items) {
|
|
|
+ protected void calFlowControlWeight(String flowCtlType, String layer, List<AdRankItem> items, Map<String, Double> flowControlParams) {
|
|
|
try {
|
|
|
if (org.springframework.util.CollectionUtils.isEmpty(flowControlParams)) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
double cpmPow = flowControlParams.getOrDefault("cpmPow", 0.3);
|
|
|
double lowerCpmWeight = flowControlParams.getOrDefault("lowerCpmWeight", 1.0);
|
|
|
double upperCpmWeight = flowControlParams.getOrDefault("upperCpmWeight", 1.2);
|
|
|
@@ -1386,26 +1391,39 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
double plusViewRate = flowControlParams.getOrDefault("plusViewRate", 20.0);
|
|
|
double viewRatePow = flowControlParams.getOrDefault("viewRatePow", 0.2);
|
|
|
double viewRateScale = flowControlParams.getOrDefault("viewRateScale", 0.5491);
|
|
|
- for (AdRankItem item : items) {
|
|
|
- double flowWeight = getFlowControlWeight(layer, item,
|
|
|
- cpmPow, lowerCpmWeight, upperCpmWeight,
|
|
|
- flowPow, lowerFlowWeight, upperFlowWeight,
|
|
|
- hitViewRate, plusViewRate, viewRatePow, viewRateScale);
|
|
|
- item.getScoreMap().put("flow", flowWeight);
|
|
|
+ if ("flowCtlC".equals(flowCtlType)) {
|
|
|
+ for (AdRankItem item : items) {
|
|
|
+ String profession = item.getProfession();
|
|
|
+ String customerId = String.valueOf(item.getCustomerId());
|
|
|
+ Pair<Double, Double> pair = LayerCustomerFlowControlDataHelper.getWeight(layer, profession, customerId);
|
|
|
+ double flowWeight = getFlowControlWeight(pair,
|
|
|
+ cpmPow, lowerCpmWeight, upperCpmWeight,
|
|
|
+ flowPow, lowerFlowWeight, upperFlowWeight,
|
|
|
+ hitViewRate, plusViewRate, viewRatePow, viewRateScale);
|
|
|
+ item.getScoreMap().put(flowCtlType, flowWeight);
|
|
|
+ }
|
|
|
+ } else if ("flowCtlA".equals(flowCtlType)) {
|
|
|
+ for (AdRankItem item : items) {
|
|
|
+ String profession = item.getProfession();
|
|
|
+ String agentId = String.valueOf(item.getAgentId());
|
|
|
+ Pair<Double, Double> pair = LayerCustomerFlowControlDataHelper.getWeight(layer, profession, agentId);
|
|
|
+ double flowWeight = getFlowControlWeight(pair,
|
|
|
+ cpmPow, lowerCpmWeight, upperCpmWeight,
|
|
|
+ flowPow, lowerFlowWeight, upperFlowWeight,
|
|
|
+ hitViewRate, plusViewRate, viewRatePow, viewRateScale);
|
|
|
+ item.getScoreMap().put(flowCtlType, flowWeight);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error("cal flow control weight error", e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private double getFlowControlWeight(String layer, AdRankItem item,
|
|
|
+ private double getFlowControlWeight(Pair<Double, Double> pair,
|
|
|
double cpmPow, double lowerCpmWeight, double upperCpmWeight,
|
|
|
double flowPow, double lowerFlowWeight, double upperFlowWeight,
|
|
|
double hitViewRate, double plusViewRate, double viewRatePow, double viewRateScale) {
|
|
|
try {
|
|
|
- String profession = item.getProfession();
|
|
|
- String customerId = String.valueOf(item.getCustomerId());
|
|
|
- Pair<Double, Double> pair = LayerCustomerFlowControlDataHelper.getWeight(layer, profession, customerId);
|
|
|
if (null != pair) {
|
|
|
double cpmWeight = 1;
|
|
|
double flowWeight = 1;
|