Parcourir la source

Merge branch 'h5_cid_suppress' of algorithm/ad-engine into master

jiachanghui il y a 1 jour
Parent
commit
553284340d

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

@@ -42,6 +42,9 @@ public abstract class RankStrategyBasic implements RankStrategy {
     @ApolloJsonValue("${creative.model.score.coefficient:{}}")
     private Map<Long, Double> creativeScoreCoefficient;
 
+    @ApolloJsonValue("${h5.score.suppress:{}}")
+    private Map<String, Double> h5ScoreSuppress;
+
     @Value("${guarantee.exp:742}")
     protected String guaranteeExp;
 
@@ -431,11 +434,11 @@ public abstract class RankStrategyBasic implements RankStrategy {
 
     protected boolean getIsGuaranteedFlow(ScoreParam scoreParam) {
         // 817实验不要保量
-        if( scoreParam.getEngineInfo() != null && "817".equals(scoreParam.getEngineInfo().get("model"))){
+        if (scoreParam.getEngineInfo() != null && "817".equals(scoreParam.getEngineInfo().get("model"))) {
             return false;
         }
         // 819实验不要保量
-        if( valid819Ab(scoreParam)){
+        if (valid819Ab(scoreParam)) {
             return false;
         }
         if (System.currentTimeMillis() < guaranteeSwitchingTime) {
@@ -446,7 +449,7 @@ public abstract class RankStrategyBasic implements RankStrategy {
         return i < guaranteeWeight;
     }
 
-    private boolean valid819Ab(ScoreParam scoreParam){
+    private boolean valid819Ab(ScoreParam scoreParam) {
         // 819实验判断
         boolean in819Ab = scoreParam.getEngineInfo() != null
                 && "819".equals(scoreParam.getEngineInfo().get("ecpm_model"))
@@ -1044,6 +1047,22 @@ public abstract class RankStrategyBasic implements RankStrategy {
         }
     }
 
+    // h5 权重
+    protected double getH5SuppressWeight(AdRankItem item) {
+        try {
+            if (null != h5ScoreSuppress && null != item) {
+                Integer landingPageType = item.getLandingPageType();
+                String profession = item.getProfession();
+                if (null != landingPageType && landingPageType.equals(2) && h5ScoreSuppress.containsKey(profession)) {
+                    return h5ScoreSuppress.get(profession);
+                }
+            }
+        } catch (Exception e) {
+            log.error("获取h5权重失败", e);
+        }
+        return 1.0;
+    }
+
     // 安全的数值转换
     private double safeDouble(Double value, Double min) {
         return (value == null || value == 0) ? min : value;

+ 5 - 1
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBy688.java

@@ -350,18 +350,22 @@ public class RankStrategyBy688 extends RankStrategyBasic {
                 isGuaranteeType = true;
             }
 
+            // h5 降权
+            double h5Weight = this.getH5SuppressWeight(item);
+
             String layerAndCreativeWeightMapKey = getLayerAndCreativeWeightMapKey(peopleLayer, String.valueOf(item.getAdId()));
             // 人群分层&创意的权重
             double layerAndCreativeWeight = getLayerAndCreativeWeight(layerAndCreativeWeightMapKey);
             double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
             double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
-            double score = item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
+            double score = h5Weight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
             item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
             item.getScoreMap().put("cpa", item.getCpa());
             item.getScoreMap().put("cpm", item.getCpm());
             item.getScoreMap().put("bid", bid);
             item.getScoreMap().put("cpmCoefficient", cpmCoefficient);
             item.getScoreMap().put("scoreCoefficient", scoreCoefficient);
+            item.getScoreMap().put("h5", h5Weight);
             item.getFeatureMap().putAll(userFeatureMap);
             item.getFeatureMap().putAll(sceneFeatureMap);
 

+ 6 - 1
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBy833.java

@@ -182,6 +182,7 @@ public class RankStrategyBy833 extends RankStrategyBasic {
                     adRankItem.setSkuId(dto.getSkuId());
                     adRankItem.setCustomerId(dto.getCustomerId());
                     adRankItem.setProfession(dto.getProfession());
+                    adRankItem.setLandingPageType(dto.getLandingPageType());
                     adRankItem.setRandom(random.nextInt(1000));
                     if (noApiAdVerIds.contains(dto.getAdVerId())) {
                         adRankItem.getExt().put("isApi", "0");
@@ -365,6 +366,9 @@ public class RankStrategyBy833 extends RankStrategyBasic {
                 isGuaranteeType = true;
             }
 
+            // h5 降权
+            double h5Weight = this.getH5SuppressWeight(item);
+
             // 控制曝光权重
             Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(String.valueOf(item.getAdId()), EMPTY_NESTED_MAP);
             Map<String, String> b3Feature = cidFeature.getOrDefault("alg_cid_feature_cid_action", EMPTY_STRING_MAP);
@@ -378,13 +382,14 @@ public class RankStrategyBy833 extends RankStrategyBasic {
             double layerAndCreativeWeight = getLayerAndCreativeWeight(layerAndCreativeWeightMapKey);
             double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
             double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
-            double score = expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
+            double score = h5Weight * expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
             item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
             item.getScoreMap().put("cpa", item.getCpa());
             item.getScoreMap().put("cpm", item.getCpm());
             item.getScoreMap().put("bid", bid);
             item.getScoreMap().put("cpmCoefficient", cpmCoefficient);
             item.getScoreMap().put("scoreCoefficient", scoreCoefficient);
+            item.getScoreMap().put("h5", h5Weight);
             item.getFeatureMap().putAll(userFeatureMap);
             item.getFeatureMap().putAll(sceneFeatureMap);
 

+ 6 - 1
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBy840.java

@@ -182,6 +182,7 @@ public class RankStrategyBy840 extends RankStrategyBasic {
                     adRankItem.setSkuId(dto.getSkuId());
                     adRankItem.setCustomerId(dto.getCustomerId());
                     adRankItem.setProfession(dto.getProfession());
+                    adRankItem.setLandingPageType(dto.getLandingPageType());
                     adRankItem.setRandom(random.nextInt(1000));
                     if (noApiAdVerIds.contains(dto.getAdVerId())) {
                         adRankItem.getExt().put("isApi", "0");
@@ -365,6 +366,9 @@ public class RankStrategyBy840 extends RankStrategyBasic {
                 isGuaranteeType = true;
             }
 
+            // h5 降权
+            double h5Weight = this.getH5SuppressWeight(item);
+
             // 控制曝光权重
             Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(String.valueOf(item.getAdId()), EMPTY_NESTED_MAP);
             Map<String, String> b3Feature = cidFeature.getOrDefault("alg_cid_feature_cid_action", EMPTY_STRING_MAP);
@@ -378,13 +382,14 @@ public class RankStrategyBy840 extends RankStrategyBasic {
             double layerAndCreativeWeight = getLayerAndCreativeWeight(layerAndCreativeWeightMapKey);
             double scoreCoefficient = creativeScoreCoefficient.getOrDefault(item.getAdId(), 1d);
             double guaranteeScoreCoefficient = getGuaranteeScoreCoefficient(isGuaranteedFlow, item.getExt());
-            double score = expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
+            double score = h5Weight * expWeight * item.getLrScore() * bid * scoreCoefficient * guaranteeScoreCoefficient * layerAndCreativeWeight;
             item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
             item.getScoreMap().put("cpa", item.getCpa());
             item.getScoreMap().put("cpm", item.getCpm());
             item.getScoreMap().put("bid", bid);
             item.getScoreMap().put("cpmCoefficient", cpmCoefficient);
             item.getScoreMap().put("scoreCoefficient", scoreCoefficient);
+            item.getScoreMap().put("h5", h5Weight);
             item.getFeatureMap().putAll(userFeatureMap);
             item.getFeatureMap().putAll(sceneFeatureMap);