jch 2 tygodni temu
rodzic
commit
6a31ec8f34

+ 34 - 16
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBasic.java

@@ -49,8 +49,11 @@ public abstract class RankStrategyBasic implements RankStrategy {
     @ApolloJsonValue("${h5.score.suppress:{}}")
     @ApolloJsonValue("${h5.score.suppress:{}}")
     private Map<String, Double> h5ScoreSuppress;
     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:[]}")
     @ApolloJsonValue("${rerank.root.session.id.tail.config:[]}")
     private List<RootSessionIdExpConfig> rerankRootSessionIdConfig;
     private List<RootSessionIdExpConfig> rerankRootSessionIdConfig;
@@ -1355,8 +1358,11 @@ public abstract class RankStrategyBasic implements RankStrategy {
                     }
                     }
                     hit.add(rerankStrategy);
                     hit.add(rerankStrategy);
                     switch (rerankStrategy) {
                     switch (rerankStrategy) {
-                        case "flowControl":
-                            calFlowControlWeight(layer, items);
+                        case "flowCtlC":
+                            calFlowControlWeight(rerankStrategy, layer, items, flowCtlCustomerParams);
+                            break;
+                        case "flowCtlA":
+                            calFlowControlWeight(rerankStrategy, layer, items, flowCtlAgentParams);
                             break;
                             break;
                         default:
                         default:
                             break;
                             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 {
         try {
             if (org.springframework.util.CollectionUtils.isEmpty(flowControlParams)) {
             if (org.springframework.util.CollectionUtils.isEmpty(flowControlParams)) {
                 return;
                 return;
             }
             }
-
             double cpmPow = flowControlParams.getOrDefault("cpmPow", 0.3);
             double cpmPow = flowControlParams.getOrDefault("cpmPow", 0.3);
             double lowerCpmWeight = flowControlParams.getOrDefault("lowerCpmWeight", 1.0);
             double lowerCpmWeight = flowControlParams.getOrDefault("lowerCpmWeight", 1.0);
             double upperCpmWeight = flowControlParams.getOrDefault("upperCpmWeight", 1.2);
             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 plusViewRate = flowControlParams.getOrDefault("plusViewRate", 20.0);
             double viewRatePow = flowControlParams.getOrDefault("viewRatePow", 0.2);
             double viewRatePow = flowControlParams.getOrDefault("viewRatePow", 0.2);
             double viewRateScale = flowControlParams.getOrDefault("viewRateScale", 0.5491);
             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) {
         } catch (Exception e) {
             log.error("cal flow control weight error", 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 cpmPow, double lowerCpmWeight, double upperCpmWeight,
                                         double flowPow, double lowerFlowWeight, double upperFlowWeight,
                                         double flowPow, double lowerFlowWeight, double upperFlowWeight,
                                         double hitViewRate, double plusViewRate, double viewRatePow, double viewRateScale) {
                                         double hitViewRate, double plusViewRate, double viewRatePow, double viewRateScale) {
         try {
         try {
-            String profession = item.getProfession();
-            String customerId = String.valueOf(item.getCustomerId());
-            Pair<Double, Double> pair = LayerCustomerFlowControlDataHelper.getWeight(layer, profession, customerId);
             if (null != pair) {
             if (null != pair) {
                 double cpmWeight = 1;
                 double cpmWeight = 1;
                 double flowWeight = 1;
                 double flowWeight = 1;

+ 3 - 2
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBy847.java

@@ -402,14 +402,15 @@ public class RankStrategyBy847 extends RankStrategyBasic {
                     expLowerWeight, expUpperWeight, expScale);
                     expLowerWeight, expUpperWeight, expScale);
 
 
             // 控制流量权重
             // 控制流量权重
-            double flowWeight = item.getScoreMap().getOrDefault("flow", 1.0);
+            double flowCtlC = item.getScoreMap().getOrDefault("flowCtlC", 1.0);
+            double flowCtlA = item.getScoreMap().getOrDefault("flowCtlA", 1.0);
 
 
             String layerAndCreativeWeightMapKey = getLayerAndCreativeWeightMapKey(peopleLayer, String.valueOf(item.getAdId()));
             String layerAndCreativeWeightMapKey = getLayerAndCreativeWeightMapKey(peopleLayer, String.valueOf(item.getAdId()));
             // 人群分层&创意的权重
             // 人群分层&创意的权重
             double layerAndCreativeWeight = getLayerAndCreativeWeight(layerAndCreativeWeightMapKey);
             double layerAndCreativeWeight = getLayerAndCreativeWeight(layerAndCreativeWeightMapKey);
             double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
             double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
             double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
             double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
-            double score = flowWeight * h5Weight * expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
+            double score = flowCtlC * flowCtlA * h5Weight * expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
             item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
             item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
             item.getScoreMap().put("cpa", item.getCpa());
             item.getScoreMap().put("cpa", item.getCpa());
             item.getScoreMap().put("cpm", item.getCpm());
             item.getScoreMap().put("cpm", item.getCpm());

+ 3 - 2
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBy849.java

@@ -401,14 +401,15 @@ public class RankStrategyBy849 extends RankStrategyBasic {
                     expLowerWeight, expUpperWeight, expScale);
                     expLowerWeight, expUpperWeight, expScale);
 
 
             // 控制流量权重
             // 控制流量权重
-            double flowWeight = item.getScoreMap().getOrDefault("flow", 1.0);
+            double flowCtlC = item.getScoreMap().getOrDefault("flowCtlC", 1.0);
+            double flowCtlA = item.getScoreMap().getOrDefault("flowCtlA", 1.0);
 
 
             String layerAndCreativeWeightMapKey = getLayerAndCreativeWeightMapKey(peopleLayer, String.valueOf(item.getAdId()));
             String layerAndCreativeWeightMapKey = getLayerAndCreativeWeightMapKey(peopleLayer, String.valueOf(item.getAdId()));
             // 人群分层&创意的权重
             // 人群分层&创意的权重
             double layerAndCreativeWeight = getLayerAndCreativeWeight(layerAndCreativeWeightMapKey);
             double layerAndCreativeWeight = getLayerAndCreativeWeight(layerAndCreativeWeightMapKey);
             double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
             double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
             double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
             double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
-            double score = flowWeight * h5Weight * expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
+            double score = flowCtlC * flowCtlA * h5Weight * expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
             item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
             item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
             item.getScoreMap().put("cpa", item.getCpa());
             item.getScoreMap().put("cpa", item.getCpa());
             item.getScoreMap().put("cpm", item.getCpm());
             item.getScoreMap().put("cpm", item.getCpm());

+ 3 - 2
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBy851.java

@@ -409,14 +409,15 @@ public class RankStrategyBy851 extends RankStrategyBasic {
                     expLowerWeight, expUpperWeight, expScale);
                     expLowerWeight, expUpperWeight, expScale);
 
 
             // 控制流量权重
             // 控制流量权重
-            double flowWeight = item.getScoreMap().getOrDefault("flow", 1.0);
+            double flowCtlC = item.getScoreMap().getOrDefault("flowCtlC", 1.0);
+            double flowCtlA = item.getScoreMap().getOrDefault("flowCtlA", 1.0);
 
 
             String layerAndCreativeWeightMapKey = getLayerAndCreativeWeightMapKey(peopleLayer, String.valueOf(item.getAdId()));
             String layerAndCreativeWeightMapKey = getLayerAndCreativeWeightMapKey(peopleLayer, String.valueOf(item.getAdId()));
             // 人群分层&创意的权重
             // 人群分层&创意的权重
             double layerAndCreativeWeight = getLayerAndCreativeWeight(layerAndCreativeWeightMapKey);
             double layerAndCreativeWeight = getLayerAndCreativeWeight(layerAndCreativeWeightMapKey);
             double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
             double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
             double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
             double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
-            double score = flowWeight * h5Weight * expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
+            double score = flowCtlC * flowCtlA * h5Weight * expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
             item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
             item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
             item.getScoreMap().put("cpa", item.getCpa());
             item.getScoreMap().put("cpa", item.getCpa());
             item.getScoreMap().put("cpm", item.getCpm());
             item.getScoreMap().put("cpm", item.getCpm());