|
@@ -83,272 +83,271 @@ public class RankStrategyBy852 extends RankStrategyBasic {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<AdRankItem> adItemRank(RankRecommendRequestParam request, ScoreParam scoreParam) {
|
|
public List<AdRankItem> adItemRank(RankRecommendRequestParam request, ScoreParam scoreParam) {
|
|
|
- try {
|
|
|
|
|
|
|
|
|
|
- Map<String, Double> weightParam = ObjUtil.nullOrDefault(weightMap, new HashMap<>());
|
|
|
|
|
|
|
+ Map<String, Double> weightParam = ObjUtil.nullOrDefault(weightMap, new HashMap<>());
|
|
|
|
|
|
|
|
|
|
|
|
|
- Map<Long, Double> creativeScoreCoefficient = getCreativeScoreCoefficient();
|
|
|
|
|
- Set<String> noApiAdVerIds = getNoApiAdVerIds();
|
|
|
|
|
|
|
+ Map<Long, Double> creativeScoreCoefficient = getCreativeScoreCoefficient();
|
|
|
|
|
+ Set<String> noApiAdVerIds = getNoApiAdVerIds();
|
|
|
|
|
|
|
|
- long ts = System.currentTimeMillis() / 1000;
|
|
|
|
|
|
|
+ long ts = System.currentTimeMillis() / 1000;
|
|
|
|
|
|
|
|
- String brand = scoreParam.getRequestContext().getMachineinfoBrand();
|
|
|
|
|
- if (StringUtils.isNotEmpty(brand)) {
|
|
|
|
|
- scoreParam.getRequestContext().setMachineinfoBrand(brand + "-n");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ String brand = scoreParam.getRequestContext().getMachineinfoBrand();
|
|
|
|
|
+ if (StringUtils.isNotEmpty(brand)) {
|
|
|
|
|
+ scoreParam.getRequestContext().setMachineinfoBrand(brand + "-n");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- long start = System.currentTimeMillis();
|
|
|
|
|
- //过滤创意
|
|
|
|
|
- filterRequestAdList(request, scoreParam);
|
|
|
|
|
- // 特征处理
|
|
|
|
|
-
|
|
|
|
|
- Map<String, String> reqFeature = this.getReqFeature(scoreParam, request);
|
|
|
|
|
- String userLayer = reqFeature.get("layer_l4");
|
|
|
|
|
- // feature1
|
|
|
|
|
- Feature feature = this.getFeatureV2(userLayer, scoreParam, request);
|
|
|
|
|
- if (feature == null) {
|
|
|
|
|
- log.warn("adItemRank: feature is null, skip processing. request={}", request);
|
|
|
|
|
- return new ArrayList<>();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
|
|
+ //过滤创意
|
|
|
|
|
+ filterRequestAdList(request, scoreParam);
|
|
|
|
|
+ // 特征处理
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> reqFeature = this.getReqFeature(scoreParam, request);
|
|
|
|
|
+ String userLayer = reqFeature.get("layer_l4");
|
|
|
|
|
+ // feature1
|
|
|
|
|
+ Feature feature = this.getFeatureV2(userLayer, scoreParam, request);
|
|
|
|
|
+ if (feature == null) {
|
|
|
|
|
+ log.warn("adItemRank: feature is null, skip processing. request={}", request);
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- Map<String, Map<String, String>> userFeature = feature.getUserFeature();
|
|
|
|
|
- Map<String, Map<String, String>> videoFeature = feature.getVideoFeature();
|
|
|
|
|
- Map<String, Map<String, Map<String, String>>> allAdVerFeature = feature.getAdVerFeature();
|
|
|
|
|
- Map<String, Map<String, Map<String, String>>> allCidFeature = feature.getCidFeature();
|
|
|
|
|
- Map<String, Map<String, Map<String, String>>> allSkuFeature = feature.getSkuFeature();
|
|
|
|
|
- Map<String, Map<String, Map<String, String>>> otherFeature = feature.getOtherFeature();
|
|
|
|
|
-
|
|
|
|
|
- Map<String, String> userFeatureMap = new HashMap<>();
|
|
|
|
|
- Map<String, String> c1Feature = userFeature.getOrDefault("alg_mid_feature_ad_action", EMPTY_STRING_MAP);
|
|
|
|
|
- List<TupleMapEntry<Tuple5>> midActionList = this.handleC1Feature(c1Feature, userFeatureMap);
|
|
|
|
|
-
|
|
|
|
|
- Map<String, Double> midTimeDiffMap = this.parseC1FeatureListToTimeDiffMap(midActionList, ts);
|
|
|
|
|
- Map<String, Double> actionStaticMap = this.parseC1FeatureListToActionStaticMap(midActionList);
|
|
|
|
|
-
|
|
|
|
|
- Map<String, String> d2Feature = videoFeature.getOrDefault("alg_cid_feature_vid_cf_rank", EMPTY_STRING_MAP);
|
|
|
|
|
- Map<String, String> d3Feature = videoFeature.getOrDefault("alg_vid_feature_basic_info", EMPTY_STRING_MAP);
|
|
|
|
|
-
|
|
|
|
|
- Map<String, Map<String, Double>> vidRankMaps = this.parseD2FeatureMap(d2Feature);
|
|
|
|
|
-
|
|
|
|
|
- Map<String, String> e1Feature = userFeature.getOrDefault("alg_mid_feature_return_tags", EMPTY_STRING_MAP);
|
|
|
|
|
- Map<String, String> e2Feature = userFeature.getOrDefault("alg_mid_feature_share_tags", EMPTY_STRING_MAP);
|
|
|
|
|
-
|
|
|
|
|
- Map<String, String> g1Feature = userFeature.getOrDefault("mid_return_video_cate", EMPTY_STRING_MAP);
|
|
|
|
|
- Map<String, String> g2Feature = userFeature.getOrDefault("mid_share_video_cate", EMPTY_STRING_MAP);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- userFeatureMap.put("brand", reqFeature.getOrDefault("brand", ""));
|
|
|
|
|
- userFeatureMap.put("region", reqFeature.getOrDefault("region", ""));
|
|
|
|
|
- userFeatureMap.put("city", reqFeature.getOrDefault("city", ""));
|
|
|
|
|
- userFeatureMap.put("vid", reqFeature.getOrDefault("vid", ""));
|
|
|
|
|
- userFeatureMap.put("apptype", reqFeature.getOrDefault("apptype", ""));
|
|
|
|
|
- userFeatureMap.put("is_first_layer", reqFeature.getOrDefault("is_first_layer", ""));
|
|
|
|
|
- userFeatureMap.put("root_source_scene", reqFeature.getOrDefault("root_source_scene", ""));
|
|
|
|
|
- userFeatureMap.put("root_source_channel", reqFeature.getOrDefault("root_source_channel", ""));
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- userFeatureMap.put("cate1", d3Feature.get("merge_first_level_cate"));
|
|
|
|
|
- userFeatureMap.put("cate2", d3Feature.get("merge_second_level_cate"));
|
|
|
|
|
- userFeatureMap.put("user_vid_return_tags_2h", e1Feature.getOrDefault("tags_2h", null));
|
|
|
|
|
- userFeatureMap.put("user_vid_return_tags_1d", e1Feature.getOrDefault("tags_1d", null));
|
|
|
|
|
- userFeatureMap.put("user_vid_return_tags_3d", e1Feature.getOrDefault("tags_3d", null));
|
|
|
|
|
- userFeatureMap.put("user_vid_return_tags_7d", e1Feature.getOrDefault("tags_7d", null));
|
|
|
|
|
- userFeatureMap.put("user_vid_return_tags_14d", e1Feature.getOrDefault("tags_14d", null));
|
|
|
|
|
- userFeatureMap.put("title_split", d3Feature.getOrDefault("title_split", null));
|
|
|
|
|
- userFeatureMap.put("user_vid_share_tags_1d", e2Feature.getOrDefault("tags_1d", null));
|
|
|
|
|
- userFeatureMap.put("user_vid_share_tags_14d", e2Feature.getOrDefault("tags_14d", null));
|
|
|
|
|
- userFeatureMap.put("user_vid_return_cate1_14d", g1Feature.getOrDefault("cate1_14d", null));
|
|
|
|
|
- userFeatureMap.put("user_vid_return_cate2_14d", g1Feature.getOrDefault("cate2_14d", null));
|
|
|
|
|
- userFeatureMap.put("user_vid_share_cate1_14d", g2Feature.getOrDefault("cate1_14d", null));
|
|
|
|
|
- userFeatureMap.put("user_vid_share_cate2_14d", g2Feature.getOrDefault("cate2_14d", null));
|
|
|
|
|
- userFeatureMap.put("user_layer", reqFeature.getOrDefault("layer_l4", ""));
|
|
|
|
|
- userFeatureMap.put("flag", "1");
|
|
|
|
|
-
|
|
|
|
|
- Map<String, String> sceneFeatureMap = this.handleSceneFeature(ts);
|
|
|
|
|
- long time1 = System.currentTimeMillis();
|
|
|
|
|
-
|
|
|
|
|
- boolean isGuaranteedFlow = getIsGuaranteedFlow(scoreParam);
|
|
|
|
|
- Map<String, GuaranteeView> map = getGuaranteeViewMap(request, isGuaranteedFlow);
|
|
|
|
|
- Map<Long, CorrectCpaParam> correctCpaMap = getCorrectCpaParamMap(request, scoreParam, reqFeature);
|
|
|
|
|
- List<AdRankItem> adRankItems = new ArrayList<>();
|
|
|
|
|
- Random random = new Random();
|
|
|
|
|
- List<Future<AdRankItem>> futures = new ArrayList<>();
|
|
|
|
|
- CountDownLatch cdl1 = new CountDownLatch(request.getAdIdList().size());
|
|
|
|
|
- for (AdPlatformCreativeDTO dto : request.getAdIdList()) {
|
|
|
|
|
- Future<AdRankItem> future = ThreadPoolFactory.feature().submit(() -> {
|
|
|
|
|
- AdRankItem adRankItem = new AdRankItem();
|
|
|
|
|
- try {
|
|
|
|
|
- adRankItem.setAdId(dto.getCreativeId());
|
|
|
|
|
- adRankItem.setCreativeCode(dto.getCreativeCode());
|
|
|
|
|
- adRankItem.setAdVerId(dto.getAdVerId());
|
|
|
|
|
- adRankItem.setVideoId(request.getVideoId());
|
|
|
|
|
- adRankItem.setCpa(dto.getCpa());
|
|
|
|
|
- adRankItem.setId(dto.getAdId());
|
|
|
|
|
- adRankItem.setCampaignId(dto.getCampaignId());
|
|
|
|
|
- adRankItem.setCpm(ObjUtil.nullOrDefault(dto.getCpm(), 90).doubleValue());
|
|
|
|
|
- adRankItem.setSkuId(dto.getSkuId());
|
|
|
|
|
- adRankItem.setCustomerId(dto.getCustomerId());
|
|
|
|
|
- adRankItem.setAgentId(dto.getAgentId());
|
|
|
|
|
- adRankItem.setProfession(dto.getProfession());
|
|
|
|
|
- adRankItem.setLandingPageType(dto.getLandingPageType());
|
|
|
|
|
- adRankItem.setTargetingConversion(dto.getTargetingConversion());
|
|
|
|
|
- adRankItem.setRandom(random.nextInt(1000));
|
|
|
|
|
- if (noApiAdVerIds.contains(dto.getAdVerId())) {
|
|
|
|
|
- adRankItem.getExt().put("isApi", "0");
|
|
|
|
|
- } else {
|
|
|
|
|
- adRankItem.getExt().put("isApi", "1");
|
|
|
|
|
- }
|
|
|
|
|
- adRankItem.getExt().put("recallsources", dto.getRecallSources());
|
|
|
|
|
- fillAdRankItemExt(adRankItem, dto);
|
|
|
|
|
- adRankItem.getExt().put("correctCpaMap", JSONObject.toJSONString(correctCpaMap.get(dto.getAdId())));
|
|
|
|
|
- adRankItem.getExt().put("correctionFactor", correctCpaMap.get(dto.getAdId()).getCorrectionFactor());
|
|
|
|
|
- setGuaranteeWeight(map, dto.getAdVerId(), adRankItem.getExt(), isGuaranteedFlow, reqFeature);
|
|
|
|
|
- String cidStr = dto.getCreativeId().toString();
|
|
|
|
|
- Map<String, String> cidFeatureMap = adRankItem.getFeatureMap();
|
|
|
|
|
- Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(cidStr, EMPTY_NESTED_MAP);
|
|
|
|
|
- Map<String, String> b1Feature = cidFeature.getOrDefault("alg_cid_feature_basic_info", EMPTY_STRING_MAP);
|
|
|
|
|
-
|
|
|
|
|
- Map<String, Map<String, String>> adVerFeature = allAdVerFeature.getOrDefault(dto.getAdVerId(), EMPTY_NESTED_MAP);
|
|
|
|
|
- Map<String, Map<String, String>> skuFeature = allSkuFeature.getOrDefault(String.valueOf(dto.getSkuId()), EMPTY_NESTED_MAP);
|
|
|
|
|
- Map<String, String> d1Feature = cidFeature.getOrDefault("alg_cid_feature_vid_cf", EMPTY_STRING_MAP);
|
|
|
|
|
-
|
|
|
|
|
- this.handleB1Feature(b1Feature, cidFeatureMap, cidStr);
|
|
|
|
|
- this.handleB2ToB5AndB8ToB9Feature(cidFeature, adVerFeature, cidFeatureMap);
|
|
|
|
|
- this.handleB6ToB7Feature(cidFeature, cidFeatureMap);
|
|
|
|
|
- this.handleJ1ToJ11Feature(userLayer, dto, otherFeature, cidFeatureMap);
|
|
|
|
|
- this.handleC1UIFeature(midTimeDiffMap, actionStaticMap, cidFeatureMap, cidStr);
|
|
|
|
|
- this.handleD1Feature(d1Feature, cidFeatureMap);
|
|
|
|
|
- this.handleD2Feature(vidRankMaps, cidFeatureMap, cidStr);
|
|
|
|
|
- this.handleH1AndH2Feature(skuFeature, adVerFeature, cidFeatureMap);
|
|
|
|
|
- cidFeatureMap.put("cid", dto.getCreativeId() != null ? String.valueOf(dto.getCreativeId()) : "");
|
|
|
|
|
- cidFeatureMap.put("adid", dto.getAdId() != null ? String.valueOf(dto.getAdId()) : "");
|
|
|
|
|
- cidFeatureMap.put("adverid", dto.getAdVerId() != null ? dto.getAdVerId() : "");
|
|
|
|
|
- cidFeatureMap.put("profession", dto.getProfession() != null ? dto.getProfession() : "");
|
|
|
|
|
- cidFeatureMap.put("category_name", dto.getCategoryName() != null ? dto.getCategoryName() : "");
|
|
|
|
|
- cidFeatureMap.put("material_md5", dto.getMaterialMd5() != null ? dto.getMaterialMd5() : "");
|
|
|
|
|
- cidFeatureMap.put("ad_profession_id", dto.getAdProfessionId() != null ? String.valueOf(dto.getAdProfessionId()) : "");
|
|
|
|
|
- cidFeatureMap.put("ad_profession_name", dto.getAdProfessionName() != null ? dto.getAdProfessionName() : "");
|
|
|
|
|
- cidFeatureMap.put("ad_category_name", dto.getAdCategoryName() != null ? dto.getAdCategoryName() : "");
|
|
|
|
|
- cidFeatureMap.put("ad_category_id", dto.getAdCategoryId() != null ? String.valueOf(dto.getAdCategoryId()) : "");
|
|
|
|
|
- cidFeatureMap.put("ad_sku_id", dto.getAdSkuId() != null ? String.valueOf(dto.getAdSkuId()) : "");
|
|
|
|
|
- cidFeatureMap.put("ad_sku_code", dto.getAdSkuCode() != null ? dto.getAdSkuCode() : "");
|
|
|
|
|
- cidFeatureMap.put("ad_sku_name", dto.getAdSkuName() != null ? dto.getAdSkuName() : "");
|
|
|
|
|
- cidFeatureMap.put("customer", dto.getCustomerId() != null ? String.valueOf(dto.getCustomerId()) : "");
|
|
|
|
|
- cidFeatureMap.put("landing", dto.getLandingPageType() != null ? String.valueOf(dto.getLandingPageType()) : "");
|
|
|
|
|
- //DNN模型没训练过的cid才不传入广告相关的稀疏特征
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(DnnCidDataHelper.getCidSet()) && !DnnCidDataHelper.getCidSet().contains(adRankItem.getAdId())) {
|
|
|
|
|
- cidFeatureMap.put("cid", "");
|
|
|
|
|
- cidFeatureMap.put("adid", "");
|
|
|
|
|
- cidFeatureMap.put("adverid", "");
|
|
|
|
|
- cidFeatureMap.put("customer", "");
|
|
|
|
|
- }
|
|
|
|
|
- return adRankItem;
|
|
|
|
|
- } finally {
|
|
|
|
|
- cdl1.countDown();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- futures.add(future);
|
|
|
|
|
- }
|
|
|
|
|
- try {
|
|
|
|
|
- cdl1.await(300, TimeUnit.MILLISECONDS);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("handleE1AndE2Feature and handleD3AndB1Feature wait timeout", e);
|
|
|
|
|
- }
|
|
|
|
|
- for (Future<AdRankItem> future : futures) {
|
|
|
|
|
|
|
+ Map<String, Map<String, String>> userFeature = feature.getUserFeature();
|
|
|
|
|
+ Map<String, Map<String, String>> videoFeature = feature.getVideoFeature();
|
|
|
|
|
+ Map<String, Map<String, Map<String, String>>> allAdVerFeature = feature.getAdVerFeature();
|
|
|
|
|
+ Map<String, Map<String, Map<String, String>>> allCidFeature = feature.getCidFeature();
|
|
|
|
|
+ Map<String, Map<String, Map<String, String>>> allSkuFeature = feature.getSkuFeature();
|
|
|
|
|
+ Map<String, Map<String, Map<String, String>>> otherFeature = feature.getOtherFeature();
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> userFeatureMap = new HashMap<>();
|
|
|
|
|
+ Map<String, String> c1Feature = userFeature.getOrDefault("alg_mid_feature_ad_action", EMPTY_STRING_MAP);
|
|
|
|
|
+ List<TupleMapEntry<Tuple5>> midActionList = this.handleC1Feature(c1Feature, userFeatureMap);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Double> midTimeDiffMap = this.parseC1FeatureListToTimeDiffMap(midActionList, ts);
|
|
|
|
|
+ Map<String, Double> actionStaticMap = this.parseC1FeatureListToActionStaticMap(midActionList);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> d2Feature = videoFeature.getOrDefault("alg_cid_feature_vid_cf_rank", EMPTY_STRING_MAP);
|
|
|
|
|
+ Map<String, String> d3Feature = videoFeature.getOrDefault("alg_vid_feature_basic_info", EMPTY_STRING_MAP);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Map<String, Double>> vidRankMaps = this.parseD2FeatureMap(d2Feature);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> e1Feature = userFeature.getOrDefault("alg_mid_feature_return_tags", EMPTY_STRING_MAP);
|
|
|
|
|
+ Map<String, String> e2Feature = userFeature.getOrDefault("alg_mid_feature_share_tags", EMPTY_STRING_MAP);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> g1Feature = userFeature.getOrDefault("mid_return_video_cate", EMPTY_STRING_MAP);
|
|
|
|
|
+ Map<String, String> g2Feature = userFeature.getOrDefault("mid_share_video_cate", EMPTY_STRING_MAP);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ userFeatureMap.put("brand", reqFeature.getOrDefault("brand", ""));
|
|
|
|
|
+ userFeatureMap.put("region", reqFeature.getOrDefault("region", ""));
|
|
|
|
|
+ userFeatureMap.put("city", reqFeature.getOrDefault("city", ""));
|
|
|
|
|
+ userFeatureMap.put("vid", reqFeature.getOrDefault("vid", ""));
|
|
|
|
|
+ userFeatureMap.put("apptype", reqFeature.getOrDefault("apptype", ""));
|
|
|
|
|
+ userFeatureMap.put("is_first_layer", reqFeature.getOrDefault("is_first_layer", ""));
|
|
|
|
|
+ userFeatureMap.put("root_source_scene", reqFeature.getOrDefault("root_source_scene", ""));
|
|
|
|
|
+ userFeatureMap.put("root_source_channel", reqFeature.getOrDefault("root_source_channel", ""));
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ userFeatureMap.put("cate1", d3Feature.get("merge_first_level_cate"));
|
|
|
|
|
+ userFeatureMap.put("cate2", d3Feature.get("merge_second_level_cate"));
|
|
|
|
|
+ userFeatureMap.put("user_vid_return_tags_2h", e1Feature.getOrDefault("tags_2h", null));
|
|
|
|
|
+ userFeatureMap.put("user_vid_return_tags_1d", e1Feature.getOrDefault("tags_1d", null));
|
|
|
|
|
+ userFeatureMap.put("user_vid_return_tags_3d", e1Feature.getOrDefault("tags_3d", null));
|
|
|
|
|
+ userFeatureMap.put("user_vid_return_tags_7d", e1Feature.getOrDefault("tags_7d", null));
|
|
|
|
|
+ userFeatureMap.put("user_vid_return_tags_14d", e1Feature.getOrDefault("tags_14d", null));
|
|
|
|
|
+ userFeatureMap.put("title_split", d3Feature.getOrDefault("title_split", null));
|
|
|
|
|
+ userFeatureMap.put("user_vid_share_tags_1d", e2Feature.getOrDefault("tags_1d", null));
|
|
|
|
|
+ userFeatureMap.put("user_vid_share_tags_14d", e2Feature.getOrDefault("tags_14d", null));
|
|
|
|
|
+ userFeatureMap.put("user_vid_return_cate1_14d", g1Feature.getOrDefault("cate1_14d", null));
|
|
|
|
|
+ userFeatureMap.put("user_vid_return_cate2_14d", g1Feature.getOrDefault("cate2_14d", null));
|
|
|
|
|
+ userFeatureMap.put("user_vid_share_cate1_14d", g2Feature.getOrDefault("cate1_14d", null));
|
|
|
|
|
+ userFeatureMap.put("user_vid_share_cate2_14d", g2Feature.getOrDefault("cate2_14d", null));
|
|
|
|
|
+ userFeatureMap.put("user_layer", reqFeature.getOrDefault("layer_l4", ""));
|
|
|
|
|
+ userFeatureMap.put("flag", "1");
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> sceneFeatureMap = this.handleSceneFeature(ts);
|
|
|
|
|
+ long time1 = System.currentTimeMillis();
|
|
|
|
|
+
|
|
|
|
|
+ boolean isGuaranteedFlow = getIsGuaranteedFlow(scoreParam);
|
|
|
|
|
+ Map<String, GuaranteeView> map = getGuaranteeViewMap(request, isGuaranteedFlow);
|
|
|
|
|
+ Map<Long, CorrectCpaParam> correctCpaMap = getCorrectCpaParamMap(request, scoreParam, reqFeature);
|
|
|
|
|
+ List<AdRankItem> adRankItems = new ArrayList<>();
|
|
|
|
|
+ Random random = new Random();
|
|
|
|
|
+ List<Future<AdRankItem>> futures = new ArrayList<>();
|
|
|
|
|
+ CountDownLatch cdl1 = new CountDownLatch(request.getAdIdList().size());
|
|
|
|
|
+ for (AdPlatformCreativeDTO dto : request.getAdIdList()) {
|
|
|
|
|
+ Future<AdRankItem> future = ThreadPoolFactory.feature().submit(() -> {
|
|
|
|
|
+ AdRankItem adRankItem = new AdRankItem();
|
|
|
try {
|
|
try {
|
|
|
- if (future.isDone()) {
|
|
|
|
|
- adRankItems.add(future.get());
|
|
|
|
|
- }
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("Feature handle error", e);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- long time2 = System.currentTimeMillis();
|
|
|
|
|
- // feature3
|
|
|
|
|
- // 请求级别的 tag 分词缓存,所有广告共享(同一用户的 tags 相同)
|
|
|
|
|
- Map<String, List<String>> tagWordsCache = new ConcurrentHashMap<>();
|
|
|
|
|
- CountDownLatch cdl2 = new CountDownLatch(adRankItems.size() * 2);
|
|
|
|
|
- for (AdRankItem item : adRankItems) {
|
|
|
|
|
- String cidStr = String.valueOf(item.getAdId());
|
|
|
|
|
- Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(cidStr, EMPTY_NESTED_MAP);
|
|
|
|
|
- Map<String, String> b1Feature = cidFeature.getOrDefault("alg_cid_feature_basic_info", EMPTY_STRING_MAP);
|
|
|
|
|
- String title = b1Feature.getOrDefault("cidtitle", "");
|
|
|
|
|
- ThreadPoolFactory.defaultPool().submit(() -> {
|
|
|
|
|
- try {
|
|
|
|
|
- this.handleE1AndE2Feature(e1Feature, e2Feature, title, item.getFeatureMap(), scoreParam, tagWordsCache);
|
|
|
|
|
- } finally {
|
|
|
|
|
- cdl2.countDown();
|
|
|
|
|
|
|
+ adRankItem.setAdId(dto.getCreativeId());
|
|
|
|
|
+ adRankItem.setCreativeCode(dto.getCreativeCode());
|
|
|
|
|
+ adRankItem.setAdVerId(dto.getAdVerId());
|
|
|
|
|
+ adRankItem.setVideoId(request.getVideoId());
|
|
|
|
|
+ adRankItem.setCpa(dto.getCpa());
|
|
|
|
|
+ adRankItem.setId(dto.getAdId());
|
|
|
|
|
+ adRankItem.setCampaignId(dto.getCampaignId());
|
|
|
|
|
+ adRankItem.setCpm(ObjUtil.nullOrDefault(dto.getCpm(), 90).doubleValue());
|
|
|
|
|
+ adRankItem.setSkuId(dto.getSkuId());
|
|
|
|
|
+ adRankItem.setCustomerId(dto.getCustomerId());
|
|
|
|
|
+ adRankItem.setAgentId(dto.getAgentId());
|
|
|
|
|
+ adRankItem.setProfession(dto.getProfession());
|
|
|
|
|
+ adRankItem.setLandingPageType(dto.getLandingPageType());
|
|
|
|
|
+ adRankItem.setTargetingConversion(dto.getTargetingConversion());
|
|
|
|
|
+ adRankItem.setRandom(random.nextInt(1000));
|
|
|
|
|
+ if (noApiAdVerIds.contains(dto.getAdVerId())) {
|
|
|
|
|
+ adRankItem.getExt().put("isApi", "0");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ adRankItem.getExt().put("isApi", "1");
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
- ThreadPoolFactory.defaultPool().submit(() -> {
|
|
|
|
|
- try {
|
|
|
|
|
- this.handleD3AndB1Feature(d3Feature, title, item.getFeatureMap(), scoreParam);
|
|
|
|
|
- } finally {
|
|
|
|
|
- cdl2.countDown();
|
|
|
|
|
|
|
+ adRankItem.getExt().put("recallsources", dto.getRecallSources());
|
|
|
|
|
+ fillAdRankItemExt(adRankItem, dto);
|
|
|
|
|
+ adRankItem.getExt().put("correctCpaMap", JSONObject.toJSONString(correctCpaMap.get(dto.getAdId())));
|
|
|
|
|
+ adRankItem.getExt().put("correctionFactor", correctCpaMap.get(dto.getAdId()).getCorrectionFactor());
|
|
|
|
|
+ setGuaranteeWeight(map, dto.getAdVerId(), adRankItem.getExt(), isGuaranteedFlow, reqFeature);
|
|
|
|
|
+ String cidStr = dto.getCreativeId().toString();
|
|
|
|
|
+ Map<String, String> cidFeatureMap = adRankItem.getFeatureMap();
|
|
|
|
|
+ Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(cidStr, EMPTY_NESTED_MAP);
|
|
|
|
|
+ Map<String, String> b1Feature = cidFeature.getOrDefault("alg_cid_feature_basic_info", EMPTY_STRING_MAP);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Map<String, String>> adVerFeature = allAdVerFeature.getOrDefault(dto.getAdVerId(), EMPTY_NESTED_MAP);
|
|
|
|
|
+ Map<String, Map<String, String>> skuFeature = allSkuFeature.getOrDefault(String.valueOf(dto.getSkuId()), EMPTY_NESTED_MAP);
|
|
|
|
|
+ Map<String, String> d1Feature = cidFeature.getOrDefault("alg_cid_feature_vid_cf", EMPTY_STRING_MAP);
|
|
|
|
|
+
|
|
|
|
|
+ this.handleB1Feature(b1Feature, cidFeatureMap, cidStr);
|
|
|
|
|
+ this.handleB2ToB5AndB8ToB9Feature(cidFeature, adVerFeature, cidFeatureMap);
|
|
|
|
|
+ this.handleB6ToB7Feature(cidFeature, cidFeatureMap);
|
|
|
|
|
+ this.handleJ1ToJ11Feature(userLayer, dto, otherFeature, cidFeatureMap);
|
|
|
|
|
+ this.handleC1UIFeature(midTimeDiffMap, actionStaticMap, cidFeatureMap, cidStr);
|
|
|
|
|
+ this.handleD1Feature(d1Feature, cidFeatureMap);
|
|
|
|
|
+ this.handleD2Feature(vidRankMaps, cidFeatureMap, cidStr);
|
|
|
|
|
+ this.handleH1AndH2Feature(skuFeature, adVerFeature, cidFeatureMap);
|
|
|
|
|
+ cidFeatureMap.put("cid", dto.getCreativeId() != null ? String.valueOf(dto.getCreativeId()) : "");
|
|
|
|
|
+ cidFeatureMap.put("adid", dto.getAdId() != null ? String.valueOf(dto.getAdId()) : "");
|
|
|
|
|
+ cidFeatureMap.put("adverid", dto.getAdVerId() != null ? dto.getAdVerId() : "");
|
|
|
|
|
+ cidFeatureMap.put("profession", dto.getProfession() != null ? dto.getProfession() : "");
|
|
|
|
|
+ cidFeatureMap.put("category_name", dto.getCategoryName() != null ? dto.getCategoryName() : "");
|
|
|
|
|
+ cidFeatureMap.put("material_md5", dto.getMaterialMd5() != null ? dto.getMaterialMd5() : "");
|
|
|
|
|
+ cidFeatureMap.put("ad_profession_id", dto.getAdProfessionId() != null ? String.valueOf(dto.getAdProfessionId()) : "");
|
|
|
|
|
+ cidFeatureMap.put("ad_profession_name", dto.getAdProfessionName() != null ? dto.getAdProfessionName() : "");
|
|
|
|
|
+ cidFeatureMap.put("ad_category_name", dto.getAdCategoryName() != null ? dto.getAdCategoryName() : "");
|
|
|
|
|
+ cidFeatureMap.put("ad_category_id", dto.getAdCategoryId() != null ? String.valueOf(dto.getAdCategoryId()) : "");
|
|
|
|
|
+ cidFeatureMap.put("ad_sku_id", dto.getAdSkuId() != null ? String.valueOf(dto.getAdSkuId()) : "");
|
|
|
|
|
+ cidFeatureMap.put("ad_sku_code", dto.getAdSkuCode() != null ? dto.getAdSkuCode() : "");
|
|
|
|
|
+ cidFeatureMap.put("ad_sku_name", dto.getAdSkuName() != null ? dto.getAdSkuName() : "");
|
|
|
|
|
+ cidFeatureMap.put("customer", dto.getCustomerId() != null ? String.valueOf(dto.getCustomerId()) : "");
|
|
|
|
|
+ cidFeatureMap.put("landing", dto.getLandingPageType() != null ? String.valueOf(dto.getLandingPageType()) : "");
|
|
|
|
|
+ //DNN模型没训练过的cid才不传入广告相关的稀疏特征
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(DnnCidDataHelper.getCidSet()) && !DnnCidDataHelper.getCidSet().contains(adRankItem.getAdId())) {
|
|
|
|
|
+ cidFeatureMap.put("cid", "");
|
|
|
|
|
+ cidFeatureMap.put("adid", "");
|
|
|
|
|
+ cidFeatureMap.put("adverid", "");
|
|
|
|
|
+ cidFeatureMap.put("customer", "");
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return adRankItem;
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ cdl1.countDown();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ futures.add(future);
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ cdl1.await(300, TimeUnit.MILLISECONDS);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("handleE1AndE2Feature and handleD3AndB1Feature wait timeout", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (Future<AdRankItem> future : futures) {
|
|
|
try {
|
|
try {
|
|
|
- cdl2.await(150, TimeUnit.MILLISECONDS);
|
|
|
|
|
|
|
+ if (future.isDone()) {
|
|
|
|
|
+ adRankItems.add(future.get());
|
|
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.error("handleE1AndE2Feature and handleD3AndB1Feature wait timeout", e);
|
|
|
|
|
|
|
+ log.error("Feature handle error", e);
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- long time3 = System.currentTimeMillis();
|
|
|
|
|
- // 分桶
|
|
|
|
|
- userFeatureMap = this.featureBucket(userFeatureMap);
|
|
|
|
|
- CountDownLatch cdl4 = new CountDownLatch(adRankItems.size());
|
|
|
|
|
- for (AdRankItem adRankItem : adRankItems) {
|
|
|
|
|
- ThreadPoolFactory.feature().submit(() -> {
|
|
|
|
|
- try {
|
|
|
|
|
- Map<String, String> featureMap = adRankItem.getFeatureMap();
|
|
|
|
|
- adRankItem.setFeatureMap(this.featureBucket(featureMap));
|
|
|
|
|
- } finally {
|
|
|
|
|
- cdl4.countDown();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- try {
|
|
|
|
|
- cdl4.await(100, TimeUnit.MILLISECONDS);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("handleE1AndE2Feature and handleD3AndB1Feature wait timeout", e);
|
|
|
|
|
- }
|
|
|
|
|
- long time4 = System.currentTimeMillis();
|
|
|
|
|
- // 打分排序
|
|
|
|
|
- // getScorerPipeline
|
|
|
|
|
|
|
+ long time2 = System.currentTimeMillis();
|
|
|
|
|
+ // feature3
|
|
|
|
|
+ // 请求级别的 tag 分词缓存,所有广告共享(同一用户的 tags 相同)
|
|
|
|
|
+ Map<String, List<String>> tagWordsCache = new ConcurrentHashMap<>();
|
|
|
|
|
+ CountDownLatch cdl2 = new CountDownLatch(adRankItems.size() * 2);
|
|
|
|
|
+ for (AdRankItem item : adRankItems) {
|
|
|
|
|
+ String cidStr = String.valueOf(item.getAdId());
|
|
|
|
|
+ Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(cidStr, EMPTY_NESTED_MAP);
|
|
|
|
|
+ Map<String, String> b1Feature = cidFeature.getOrDefault("alg_cid_feature_basic_info", EMPTY_STRING_MAP);
|
|
|
|
|
+ String title = b1Feature.getOrDefault("cidtitle", "");
|
|
|
|
|
+ ThreadPoolFactory.defaultPool().submit(() -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ this.handleE1AndE2Feature(e1Feature, e2Feature, title, item.getFeatureMap(), scoreParam, tagWordsCache);
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ cdl2.countDown();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ ThreadPoolFactory.defaultPool().submit(() -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ this.handleD3AndB1Feature(d3Feature, title, item.getFeatureMap(), scoreParam);
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ cdl2.countDown();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ cdl2.await(150, TimeUnit.MILLISECONDS);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("handleE1AndE2Feature and handleD3AndB1Feature wait timeout", e);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (CollectionUtils.isEmpty(adRankItems)) {
|
|
|
|
|
- log.error("adRankItems is empty");
|
|
|
|
|
- }
|
|
|
|
|
- List<AdRankItem> result = ScorerUtils.getScorerPipeline(ScorerUtils.PAI_SCORE_CONF_20250804).scoring(sceneFeatureMap, userFeatureMap, adRankItems);
|
|
|
|
|
- if (CollectionUtils.isEmpty(result)) {
|
|
|
|
|
- log.error("scoring result is empty");
|
|
|
|
|
- }
|
|
|
|
|
- long time5 = System.currentTimeMillis();
|
|
|
|
|
- int viewLimit = NumberUtils.toInt(paramsMap.getOrDefault("viewLimit", "3000"));
|
|
|
|
|
- // calibrate score for negative sampling or cold start
|
|
|
|
|
- for (AdRankItem item : result) {
|
|
|
|
|
- double scanScore = item.getScoreMap().getOrDefault("scanScore", 0.0);
|
|
|
|
|
- double addWechatScore = item.getScoreMap().getOrDefault("addWechatScore", 0.0);
|
|
|
|
|
- double conversionScore = item.getScoreMap().getOrDefault("conversionScore", 0.0);
|
|
|
|
|
- double calibratedScanScore = scanScore / (scanScore + (1 - scanScore) / negSampleRate);
|
|
|
|
|
- double calibratedConversionScore = conversionScore / (conversionScore + (1 - conversionScore) / negSampleRate);
|
|
|
|
|
- item.getScoreMap().put("calibratedScanScore", calibratedScanScore);
|
|
|
|
|
- item.getScoreMap().put("calibratedConversionScore", calibratedConversionScore);
|
|
|
|
|
- double calibratedScore = 0.0;
|
|
|
|
|
- if (item.getLandingPageType() == 3 && Objects.equals(item.getTargetingConversion(), "10019")) {
|
|
|
|
|
- calibratedScore = calibratedScanScore;
|
|
|
|
|
- } else if (item.getLandingPageType() == 3 && Objects.equals(item.getTargetingConversion(), "10004")) {
|
|
|
|
|
- calibratedScore = calibratedScanScore * addWechatScore;
|
|
|
|
|
- } else {
|
|
|
|
|
- calibratedScore = calibratedConversionScore;
|
|
|
|
|
|
|
+ long time3 = System.currentTimeMillis();
|
|
|
|
|
+ // 分桶
|
|
|
|
|
+ userFeatureMap = this.featureBucket(userFeatureMap);
|
|
|
|
|
+ CountDownLatch cdl4 = new CountDownLatch(adRankItems.size());
|
|
|
|
|
+ for (AdRankItem adRankItem : adRankItems) {
|
|
|
|
|
+ ThreadPoolFactory.feature().submit(() -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ Map<String, String> featureMap = adRankItem.getFeatureMap();
|
|
|
|
|
+ adRankItem.setFeatureMap(this.featureBucket(featureMap));
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ cdl4.countDown();
|
|
|
}
|
|
}
|
|
|
- item.getScoreMap().put("modelCtcvrScore", calibratedScore);
|
|
|
|
|
- item.getScoreMap().put("ctcvrScore", calibratedScore);
|
|
|
|
|
- item.setLrScore(calibratedScore);
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ cdl4.await(100, TimeUnit.MILLISECONDS);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("handleE1AndE2Feature and handleD3AndB1Feature wait timeout", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ long time4 = System.currentTimeMillis();
|
|
|
|
|
+ // 打分排序
|
|
|
|
|
+ // getScorerPipeline
|
|
|
|
|
+
|
|
|
|
|
+ if (CollectionUtils.isEmpty(adRankItems)) {
|
|
|
|
|
+ log.error("adRankItems is empty");
|
|
|
|
|
+ }
|
|
|
|
|
+ List<AdRankItem> result = ScorerUtils.getScorerPipeline(ScorerUtils.PAI_SCORE_CONF_20250804).scoring(sceneFeatureMap, userFeatureMap, adRankItems);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(result)) {
|
|
|
|
|
+ log.error("scoring result is empty");
|
|
|
|
|
+ }
|
|
|
|
|
+ long time5 = System.currentTimeMillis();
|
|
|
|
|
+ int viewLimit = NumberUtils.toInt(paramsMap.getOrDefault("viewLimit", "3000"));
|
|
|
|
|
+ // calibrate score for negative sampling or cold start
|
|
|
|
|
+ for (AdRankItem item : result) {
|
|
|
|
|
+ double scanScore = item.getScoreMap().getOrDefault("scanScore", 0.0);
|
|
|
|
|
+ double addWechatScore = item.getScoreMap().getOrDefault("addWechatScore", 0.0);
|
|
|
|
|
+ double conversionScore = item.getScoreMap().getOrDefault("conversionScore", 0.0);
|
|
|
|
|
+ double calibratedScanScore = scanScore / (scanScore + (1 - scanScore) / negSampleRate);
|
|
|
|
|
+ double calibratedConversionScore = conversionScore / (conversionScore + (1 - conversionScore) / negSampleRate);
|
|
|
|
|
+ item.getScoreMap().put("calibratedScanScore", calibratedScanScore);
|
|
|
|
|
+ item.getScoreMap().put("calibratedConversionScore", calibratedConversionScore);
|
|
|
|
|
+ double calibratedScore = 0.0;
|
|
|
|
|
+ if (Objects.equals(item.getLandingPageType(), 3) && Objects.equals(item.getTargetingConversion(), "10019")) {
|
|
|
|
|
+ calibratedScore = calibratedScanScore;
|
|
|
|
|
+ } else if (Objects.equals(item.getLandingPageType(), 3) && Objects.equals(item.getTargetingConversion(), "10004")) {
|
|
|
|
|
+ calibratedScore = calibratedScanScore * addWechatScore;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ calibratedScore = calibratedConversionScore;
|
|
|
}
|
|
}
|
|
|
|
|
+ item.getScoreMap().put("modelCtcvrScore", calibratedScore);
|
|
|
|
|
+ item.getScoreMap().put("ctcvrScore", calibratedScore);
|
|
|
|
|
+ item.setLrScore(calibratedScore);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// String calibModelName = paramsMap.getOrDefault("calibModelName", "dnnV3");
|
|
// String calibModelName = paramsMap.getOrDefault("calibModelName", "dnnV3");
|
|
|
// calculateCtcvrScore(result, request, scoreParam, calibModelName, reqFeature);
|
|
// calculateCtcvrScore(result, request, scoreParam, calibModelName, reqFeature);
|
|
@@ -363,8 +362,8 @@ public class RankStrategyBy852 extends RankStrategyBasic {
|
|
|
// log.error("calculateCtcvrScore result is empty");
|
|
// log.error("calculateCtcvrScore result is empty");
|
|
|
// }
|
|
// }
|
|
|
// // loop
|
|
// // loop
|
|
|
- double cpmCoefficient = weightParam.getOrDefault("cpmCoefficient", 0.9);
|
|
|
|
|
- boolean isGuaranteeType = false;
|
|
|
|
|
|
|
+ double cpmCoefficient = weightParam.getOrDefault("cpmCoefficient", 0.9);
|
|
|
|
|
+ boolean isGuaranteeType = false;
|
|
|
// // 查询人群分层信息
|
|
// // 查询人群分层信息
|
|
|
// String peopleLayer = Optional.of(reqFeature)
|
|
// String peopleLayer = Optional.of(reqFeature)
|
|
|
// .map(f -> f.get("layer"))
|
|
// .map(f -> f.get("layer"))
|
|
@@ -383,17 +382,17 @@ public class RankStrategyBy852 extends RankStrategyBasic {
|
|
|
//
|
|
//
|
|
|
// // 计算rerank权重 打压客户
|
|
// // 计算rerank权重 打压客户
|
|
|
// calRerankWeight(scoreParam, userLayer, result);
|
|
// calRerankWeight(scoreParam, userLayer, result);
|
|
|
- for (AdRankItem item : result) {
|
|
|
|
|
- double bid = item.getCpa();
|
|
|
|
|
- if (scoreParam.getExpCodeSet().contains(correctCpaExp1) || scoreParam.getExpCodeSet().contains(correctCpaExp2)) {
|
|
|
|
|
- Double correctionFactor = (Double) item.getExt().get("correctionFactor");
|
|
|
|
|
- item.getScoreMap().put("correctionFactor", correctionFactor);
|
|
|
|
|
- bid = bid * correctionFactor;
|
|
|
|
|
- }
|
|
|
|
|
- item.getScoreMap().put("ecpm", item.getLrScore() * bid * 1000);
|
|
|
|
|
- if (isGuaranteedFlow && item.getExt().get("isGuaranteed") != null && (boolean) item.getExt().get("isGuaranteed")) {
|
|
|
|
|
- isGuaranteeType = true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ for (AdRankItem item : result) {
|
|
|
|
|
+ double bid = item.getCpa();
|
|
|
|
|
+ if (scoreParam.getExpCodeSet().contains(correctCpaExp1) || scoreParam.getExpCodeSet().contains(correctCpaExp2)) {
|
|
|
|
|
+ Double correctionFactor = (Double) item.getExt().get("correctionFactor");
|
|
|
|
|
+ item.getScoreMap().put("correctionFactor", correctionFactor);
|
|
|
|
|
+ bid = bid * correctionFactor;
|
|
|
|
|
+ }
|
|
|
|
|
+ item.getScoreMap().put("ecpm", item.getLrScore() * bid * 1000);
|
|
|
|
|
+ if (isGuaranteedFlow && item.getExt().get("isGuaranteed") != null && (boolean) item.getExt().get("isGuaranteed")) {
|
|
|
|
|
+ isGuaranteeType = true;
|
|
|
|
|
+ }
|
|
|
//
|
|
//
|
|
|
// // h5 降权
|
|
// // h5 降权
|
|
|
// double h5Weight = 1;
|
|
// double h5Weight = 1;
|
|
@@ -419,64 +418,60 @@ public class RankStrategyBy852 extends RankStrategyBasic {
|
|
|
// 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 = item.getLrScore() * bid;
|
|
|
|
|
|
|
+ double score = item.getLrScore() * bid;
|
|
|
// item.getScoreMap().put("guaranteeScoreCoefficient", guaranteeScoreCoefficient);
|
|
// 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("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("scoreCoefficient", scoreCoefficient);
|
|
|
// item.getScoreMap().put("h5", h5Weight);
|
|
// item.getScoreMap().put("h5", h5Weight);
|
|
|
- item.getFeatureMap().putAll(userFeatureMap);
|
|
|
|
|
- item.getFeatureMap().putAll(sceneFeatureMap);
|
|
|
|
|
|
|
+ item.getFeatureMap().putAll(userFeatureMap);
|
|
|
|
|
+ item.getFeatureMap().putAll(sceneFeatureMap);
|
|
|
|
|
|
|
|
- // 没有转化回传的广告主,使用后台配置的CPM
|
|
|
|
|
- if (noApiAdVerIds.contains(item.getAdVerId())) {
|
|
|
|
|
- score = item.getCpm() * cpmCoefficient / 1000;
|
|
|
|
|
- }
|
|
|
|
|
- item.setScore(score);
|
|
|
|
|
|
|
+ // 没有转化回传的广告主,使用后台配置的CPM
|
|
|
|
|
+ if (noApiAdVerIds.contains(item.getAdVerId())) {
|
|
|
|
|
+ score = item.getCpm() * cpmCoefficient / 1000;
|
|
|
}
|
|
}
|
|
|
|
|
+ item.setScore(score);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
- result.sort(ComparatorUtil.equalsRandomComparator());
|
|
|
|
|
|
|
+ result.sort(ComparatorUtil.equalsRandomComparator());
|
|
|
|
|
|
|
|
- String logModelName = paramsMap.getOrDefault("logModelName", "dnnV3");
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(result)) {
|
|
|
|
|
- AdRankItem top1Item = result.get(0);
|
|
|
|
|
- List<String> participateCompetitionType = new ArrayList<>();
|
|
|
|
|
- participateCompetitionType.add("engine");
|
|
|
|
|
- top1Item.getExt().put("isGuaranteeType", isGuaranteeType);
|
|
|
|
|
- if (isGuaranteeType) {
|
|
|
|
|
- participateCompetitionType.add("guarantee");
|
|
|
|
|
- }
|
|
|
|
|
- top1Item.getExt().put("participateCompetitionType", StringUtils.join(participateCompetitionType, ","));
|
|
|
|
|
- Double modelCtcvrScore = top1Item.getScoreMap().get("modelCtcvrScore");
|
|
|
|
|
- Double ctcvrScore = top1Item.getScoreMap().get("ctcvrScore");
|
|
|
|
|
- if (scoreParam.getExpCodeSet().contains(checkoutEcpmExp)) {
|
|
|
|
|
- top1Item.getExt().put("ecpm", ctcvrScore * top1Item.getCpa() * 1000);
|
|
|
|
|
- String filterEcpmValue = paramsMap.getOrDefault("filterEcpm", filterEcpm);
|
|
|
|
|
- top1Item.getExt().put("filterEcpm", filterEcpmValue);
|
|
|
|
|
- if (noApiAdVerIds.contains(top1Item.getAdVerId())) {
|
|
|
|
|
- top1Item.getExt().put("ecpm", top1Item.getCpm());
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- top1Item.getExt().put("ecpm", modelCtcvrScore * top1Item.getCpa() * 1000);
|
|
|
|
|
|
|
+ String logModelName = paramsMap.getOrDefault("logModelName", "dnnV3");
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(result)) {
|
|
|
|
|
+ AdRankItem top1Item = result.get(0);
|
|
|
|
|
+ List<String> participateCompetitionType = new ArrayList<>();
|
|
|
|
|
+ participateCompetitionType.add("engine");
|
|
|
|
|
+ top1Item.getExt().put("isGuaranteeType", isGuaranteeType);
|
|
|
|
|
+ if (isGuaranteeType) {
|
|
|
|
|
+ participateCompetitionType.add("guarantee");
|
|
|
|
|
+ }
|
|
|
|
|
+ top1Item.getExt().put("participateCompetitionType", StringUtils.join(participateCompetitionType, ","));
|
|
|
|
|
+ Double modelCtcvrScore = top1Item.getScoreMap().get("modelCtcvrScore");
|
|
|
|
|
+ Double ctcvrScore = top1Item.getScoreMap().get("ctcvrScore");
|
|
|
|
|
+ if (scoreParam.getExpCodeSet().contains(checkoutEcpmExp)) {
|
|
|
|
|
+ top1Item.getExt().put("ecpm", ctcvrScore * top1Item.getCpa() * 1000);
|
|
|
|
|
+ String filterEcpmValue = paramsMap.getOrDefault("filterEcpm", filterEcpm);
|
|
|
|
|
+ top1Item.getExt().put("filterEcpm", filterEcpmValue);
|
|
|
|
|
+ if (noApiAdVerIds.contains(top1Item.getAdVerId())) {
|
|
|
|
|
+ top1Item.getExt().put("ecpm", top1Item.getCpm());
|
|
|
}
|
|
}
|
|
|
- putMetaFeature(top1Item, feature, reqFeature, sceneFeatureMap, request);
|
|
|
|
|
- top1Item.getExt().put("model", logModelName);
|
|
|
|
|
- String coefficientRate = paramsMap.getOrDefault("coefficientRate", "1");
|
|
|
|
|
- top1Item.getExt().put("coefficientRate", coefficientRate);
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ top1Item.getExt().put("ecpm", modelCtcvrScore * top1Item.getCpa() * 1000);
|
|
|
}
|
|
}
|
|
|
- long time6 = System.currentTimeMillis();
|
|
|
|
|
- log.info("cost={}, getFeature={}, handleFeature={}, similar={}, bucketFeature={}, getScorerPipeline={}, " +
|
|
|
|
|
- "other={}, adIdSize={}, adRankItemsSize={}",
|
|
|
|
|
- time6 - start, time1 - start, time2 - time1, time3 - time2, time4 - time3,
|
|
|
|
|
- time5 - time4, time6 - time5, request.getAdIdList().size(), adRankItems.size());
|
|
|
|
|
- return result;
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error(e.getMessage(), e);
|
|
|
|
|
|
|
+ putMetaFeature(top1Item, feature, reqFeature, sceneFeatureMap, request);
|
|
|
|
|
+ top1Item.getExt().put("model", logModelName);
|
|
|
|
|
+ String coefficientRate = paramsMap.getOrDefault("coefficientRate", "1");
|
|
|
|
|
+ top1Item.getExt().put("coefficientRate", coefficientRate);
|
|
|
}
|
|
}
|
|
|
- return null;
|
|
|
|
|
|
|
+ long time6 = System.currentTimeMillis();
|
|
|
|
|
+ log.info("cost={}, getFeature={}, handleFeature={}, similar={}, bucketFeature={}, getScorerPipeline={}, " +
|
|
|
|
|
+ "other={}, adIdSize={}, adRankItemsSize={}",
|
|
|
|
|
+ time6 - start, time1 - start, time2 - time1, time3 - time2, time4 - time3,
|
|
|
|
|
+ time5 - time4, time6 - time5, request.getAdIdList().size(), adRankItems.size());
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|