| 
					
				 | 
			
			
				@@ -37,8 +37,8 @@ public class VideoAdThompsonScorerV2 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private Map<String, Double> exp665Param = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private Map<String, Double> exp666Param = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private Map<String, Double> exp669Param = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private Map<String, Double> exp670Param = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private Map<String, String> exp672Param = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private Map<String, Object> exp670Param = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private Map<String, Object> exp672Param = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     Random random = new Random(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     Gson gson = new Gson(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -128,7 +128,6 @@ public class VideoAdThompsonScorerV2 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ext.put("pairOrSingle", "single"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ext.put("cidStatistic", JSON.toJSONString(cidStatistics)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ext.put("cpa", cpa); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ext.put("abCode", 663); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 log.error("svc=663exp, error: ", e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -364,7 +363,6 @@ public class VideoAdThompsonScorerV2 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ext.put("cidStatistic", JSON.toJSONString(cidStatistics)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ext.put("vidCidStatistic", JSON.toJSONString(vidCidStatistics)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ext.put("cpa", cpa); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ext.put("abCode", 666); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 log.error("svc=666exp, error: ", e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -397,30 +395,85 @@ public class VideoAdThompsonScorerV2 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (AdRankItem adRankItem : result) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             adRankItem.setVideoId(param.getVideoId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             adRankItem.setScore_type(699); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (MapUtils.isNotEmpty(adRankItem.getExt())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                adRankItem.getExt().put("abCode", 699); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public List<AdRankItem> thompsonScorerByExp670(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<Long, CreativeStatistic> creativeStatisticsMap = this.batchFindCreativeRedisCache(redisCidActionKeyV1, adIdList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<Long, CreativeStatistic> videoCreativeStatisticsMap = this.batchFindCreativeRedisCache(redisCidVidActionKeyV1 + param.getVideoId() + "_", adIdList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Long, CreativeStatistic> cidMap = this.batchFindCreativeRedisCache(redisCidActionKeyV1, adIdList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Long, CreativeStatistic> vidCidMap = this.batchFindCreativeRedisCache(redisCidVidActionKeyV1 + param.getVideoId() + "_", adIdList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        double w1 = Double.parseDouble(exp670Param.getOrDefault("w1", "1").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        double w2 = Double.parseDouble(exp670Param.getOrDefault("w2", "1").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        double alpha = Double.parseDouble(exp670Param.getOrDefault("alpha", "0").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        double cidBeta = Double.parseDouble(exp670Param.getOrDefault("cidBeta", "0").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        double vidCidBeta = Double.parseDouble(exp670Param.getOrDefault("vidCidBeta", "0").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<AdRankItem> result = new ArrayList<>(adIdList.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.calcScore(result, adIdList, 0.0, 0.0, 0.0, creativeStatisticsMap, videoCreativeStatisticsMap, exp670Param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        result.sort(equalsRandomComparator()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for (AdRankItem adRankItem : result) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            adRankItem.setVideoId(param.getVideoId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            adRankItem.setScore_type(670); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (MapUtils.isNotEmpty(adRankItem.getExt())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                adRankItem.getExt().put("abCode", 670); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (AdPlatformCreativeDTO dto : adIdList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 日志上报扩展参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, Object> ext = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            double score = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            double cpa = 0.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                CreativeStatistic cidStatistic = cidMap.getOrDefault(dto.getCreativeId(), new CreativeStatistic()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                CreativeStatistic vidCidStatistic = vidCidMap.getOrDefault(dto.getCreativeId(), new CreativeStatistic()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                cpa = cidStatistic.parseCpaToDouble(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double cidExp = cidStatistic.parseExpToDouble(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double vidCidExp = vidCidStatistic.parseExpToDouble(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // double cidScore = this.betaSampler(cidStatistic.parseOrderToDouble() + alpha, cidStatistic.parseExpToDouble() + cidBeta); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // double vidCidScore = this.betaSampler(vidCidStatistic.parseOrderToDouble() + alpha, vidCidStatistic.parseExpToDouble() + vidCidBeta); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double cidScore = this.orderDivideExp(cidStatistic); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double vidCidScore = this.orderDivideExp(vidCidStatistic); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (w1 != 0 || w2 != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    score = ((w1 * vidCidScore * vidCidExp + w2 * cidScore * cidExp) / (w1 * vidCidExp + w2 * cidExp)) * cpa; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("w1", w1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("w2", w2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("cidScore", cidScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("vidCidScore", vidCidScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("cidA", alpha); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("vidCidA", alpha); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("cidB", cidBeta); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("vidCidB", vidCidBeta); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("cidExp", cidExp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("vidCidExp", vidCidExp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("bid1", dto.getBid1()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("bid2", dto.getBid2()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("cidStatistic", JSON.toJSONString(cidStatistic)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("vidCidStatistic", JSON.toJSONString(vidCidStatistic)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ext.put("cpa", cpa); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.error("svc=670exp, error: ", e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AdRankItem item = new AdRankItem(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.setCpa(cpa); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.setAdId(dto.getCreativeId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.setWeight(dto.getWeight()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.setScore(score); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.setExt(ext); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.setBid1(dto.getBid1()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.setBid2(dto.getBid2()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.setCreativeCode(dto.getCreativeCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.setScore_type(670); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.setVideoId(param.getVideoId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            result.add(item); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result.sort(equalsRandomComparator()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -502,6 +555,15 @@ public class VideoAdThompsonScorerV2 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return resultMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private double orderDivideExp(CreativeStatistic statistic) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        double order = statistic.parseOrderToDouble(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        double exp = statistic.parseExpToDouble(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (exp != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return order / exp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return 0.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private double calcThompsonScore(Map<String, Double> expParam, CreativeStatistic creativeStatistic, Double defaultAlpha, Double defaultBeta) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Double alpha = expParam.getOrDefault("alpha", defaultAlpha); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Double beta = expParam.getOrDefault("beta", defaultBeta); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -538,7 +600,6 @@ public class VideoAdThompsonScorerV2 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private Map<String, Object> extMap(CreativeStatistic statistic, String abCode, Double cpa, Double viewThreshold, Double alpha, Double beta, Double beta_k) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Map<String, Object> map = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        map.put("abCode", abCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (Objects.nonNull(viewThreshold)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             map.put("viewThreshold", viewThreshold); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -555,9 +616,9 @@ public class VideoAdThompsonScorerV2 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public List<AdRankItem> thompsonScorerByExp672(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String cidRedisKey = exp672Param.getOrDefault("cidActionRedisKey", redisCreativeStatisticsPrefix); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String vidCidRedisKey = exp672Param.getOrDefault("vidCidActionRedisKey", redisVideoCreativeStatisticsPrefix); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        double viewThreshold = Double.parseDouble(exp672Param.getOrDefault("viewThreshold", "7000")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String cidRedisKey = exp672Param.getOrDefault("cidActionRedisKey", redisCreativeStatisticsPrefix).toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String vidCidRedisKey = exp672Param.getOrDefault("vidCidActionRedisKey", redisVideoCreativeStatisticsPrefix).toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        double viewThreshold = Double.parseDouble(exp672Param.getOrDefault("viewThreshold", "7000").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // RedisKey前缀判断 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (!StringUtils.equals(redisCidActionKeyV1, cidRedisKey) && !StringUtils.equals(redisCreativeStatisticsPrefix, cidRedisKey)) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -603,7 +664,6 @@ public class VideoAdThompsonScorerV2 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ext.put("cidStatistic", JSON.toJSONString(cidStatistic)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ext.put("vidCidStatistic", JSON.toJSONString(vidCidStatistic)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ext.put("cpa", cpa); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ext.put("abCode", 672); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 log.error("svc=672exp, error: ", e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 |