|  | @@ -25,104 +25,158 @@ public class VideoAdThompsonScorerV2 {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private AlgorithmRedisHelper redisHelper;
 | 
	
		
			
				|  |  |      // redis:cid_action:{$cid}
 | 
	
		
			
				|  |  | -    private String redisCreativeStatisticsPrefix="redis:cid_action:";
 | 
	
		
			
				|  |  | -    //redis:vid_cid_action:{$vid}_{$cid}
 | 
	
		
			
				|  |  | -    private String redisVideoCreativeStatisticsPrefix="redis:vid_cid_action:";
 | 
	
		
			
				|  |  | +    private String redisCreativeStatisticsPrefix = "redis:cid_action:";
 | 
	
		
			
				|  |  | +    // redis:vid_cid_action:{$vid}_{$cid}
 | 
	
		
			
				|  |  | +    private String redisVideoCreativeStatisticsPrefix = "redis:vid_cid_action:";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private String rediCidActionKeyV1 = "redis:cid_action_v1:";
 | 
	
		
			
				|  |  |      private String rediCidVidActionKeyV1 = "redis:vid_cid_action_v1:";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private Map<String,Double> exp663Param=new HashMap<>();
 | 
	
		
			
				|  |  | -    private Map<String,Double> exp664Param=new HashMap<>();
 | 
	
		
			
				|  |  | -    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<>();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    Random random=new Random();
 | 
	
		
			
				|  |  | -    Gson gson=new Gson();
 | 
	
		
			
				|  |  | -    public List<AdRankItem> thompsonScorerByExp663(ScoreParam param, List<AdPlatformCreativeDTO> adIdList){
 | 
	
		
			
				|  |  | -        List<AdRankItem> result=new LinkedList<>();
 | 
	
		
			
				|  |  | -        String jsonStr;
 | 
	
		
			
				|  |  | -        CreativeStatistic statistic = null;
 | 
	
		
			
				|  |  | -        List<String> redisKey=new LinkedList<>();
 | 
	
		
			
				|  |  | -        adIdList.forEach(creativeDTO -> {
 | 
	
		
			
				|  |  | -            redisKey.add(redisCreativeStatisticsPrefix+creativeDTO.getCreativeId());
 | 
	
		
			
				|  |  | -        });
 | 
	
		
			
				|  |  | -        List<String> values=redisHelper.getValues(redisKey);
 | 
	
		
			
				|  |  | -        double score=0d;
 | 
	
		
			
				|  |  | -        int i=0;
 | 
	
		
			
				|  |  | -        for(AdPlatformCreativeDTO dto:adIdList){
 | 
	
		
			
				|  |  | -            AdRankItem item=new AdRankItem();
 | 
	
		
			
				|  |  | -            item.setVideoId(param.getVideoId());
 | 
	
		
			
				|  |  | -            item.setCpa(dto.getCpa());
 | 
	
		
			
				|  |  | -            item.setAdId(dto.getCreativeId());
 | 
	
		
			
				|  |  | -            try {
 | 
	
		
			
				|  |  | -                jsonStr=values.get(i);
 | 
	
		
			
				|  |  | -                if(jsonStr==null){
 | 
	
		
			
				|  |  | -                    score = exp663Param.getOrDefault("randomMin",0.000001)
 | 
	
		
			
				|  |  | -                            + (random.nextDouble() *
 | 
	
		
			
				|  |  | -                            (exp663Param.getOrDefault("randomMax",0.00001 ) - exp663Param.getOrDefault("randomMin",0.000001 )));
 | 
	
		
			
				|  |  | -                }else {
 | 
	
		
			
				|  |  | -                    statistic =gson.fromJson(jsonStr,CreativeStatistic.class);
 | 
	
		
			
				|  |  | -                    score = (exp663Param.getOrDefault("alpha",1d)+Long.parseLong(statistic.getOrder()))
 | 
	
		
			
				|  |  | -                            / (exp663Param.getOrDefault("beta",10000d)+Long.parseLong(statistic.getExp())) ;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                double s1 = score;
 | 
	
		
			
				|  |  | -                score=score*dto.getCpa()*dto.getBid1()*dto.getBid2();
 | 
	
		
			
				|  |  | +    private Map<String, Double> exp663Param = new HashMap<>();
 | 
	
		
			
				|  |  | +    private Map<String, Double> exp664Param = new HashMap<>();
 | 
	
		
			
				|  |  | +    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<>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    Random random = new Random();
 | 
	
		
			
				|  |  | +    Gson gson = new Gson();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // public List<AdRankItem> thompsonScorerByExp663(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
 | 
	
		
			
				|  |  | +    //     List<AdRankItem> result = new LinkedList<>();
 | 
	
		
			
				|  |  | +    //     String jsonStr;
 | 
	
		
			
				|  |  | +    //     CreativeStatistic statistic = null;
 | 
	
		
			
				|  |  | +    //     List<String> redisKey = new LinkedList<>();
 | 
	
		
			
				|  |  | +    //     adIdList.forEach(creativeDTO -> {
 | 
	
		
			
				|  |  | +    //         redisKey.add(redisCreativeStatisticsPrefix + creativeDTO.getCreativeId());
 | 
	
		
			
				|  |  | +    //     });
 | 
	
		
			
				|  |  | +    //     List<String> values = redisHelper.getValues(redisKey);
 | 
	
		
			
				|  |  | +    //     double score = 0d;
 | 
	
		
			
				|  |  | +    //     int i = 0;
 | 
	
		
			
				|  |  | +    //     for (AdPlatformCreativeDTO dto : adIdList) {
 | 
	
		
			
				|  |  | +    //         AdRankItem item = new AdRankItem();
 | 
	
		
			
				|  |  | +    //         item.setVideoId(param.getVideoId());
 | 
	
		
			
				|  |  | +    //         item.setCpa(dto.getCpa());
 | 
	
		
			
				|  |  | +    //         item.setAdId(dto.getCreativeId());
 | 
	
		
			
				|  |  | +    //         try {
 | 
	
		
			
				|  |  | +    //             jsonStr = values.get(i);
 | 
	
		
			
				|  |  | +    //             if (jsonStr == null) {
 | 
	
		
			
				|  |  | +    //                 score = exp663Param.getOrDefault("randomMin", 0.000001)
 | 
	
		
			
				|  |  | +    //                         + (random.nextDouble() *
 | 
	
		
			
				|  |  | +    //                         (exp663Param.getOrDefault("randomMax", 0.00001) - exp663Param.getOrDefault("randomMin", 0.000001)));
 | 
	
		
			
				|  |  | +    //             } else {
 | 
	
		
			
				|  |  | +    //                 statistic = gson.fromJson(jsonStr, CreativeStatistic.class);
 | 
	
		
			
				|  |  | +    //                 score = (exp663Param.getOrDefault("alpha", 1d) + Long.parseLong(statistic.getOrder()))
 | 
	
		
			
				|  |  | +    //                         / (exp663Param.getOrDefault("beta", 10000d) + Long.parseLong(statistic.getExp()));
 | 
	
		
			
				|  |  | +    //             }
 | 
	
		
			
				|  |  | +    //             double s1 = score;
 | 
	
		
			
				|  |  | +    //             score = score * dto.getCpa() * dto.getBid1() * dto.getBid2();
 | 
	
		
			
				|  |  | +    //
 | 
	
		
			
				|  |  | +    //             Map<String, Object> ext = this.extMap(statistic, "663", dto.getCpa(), null,
 | 
	
		
			
				|  |  | +    //                     exp663Param.getOrDefault("alpha", 1d), exp663Param.getOrDefault("beta", 10000d), null);
 | 
	
		
			
				|  |  | +    //             ext.put("s1", s1);
 | 
	
		
			
				|  |  | +    //             item.setExt(ext);
 | 
	
		
			
				|  |  | +    //             item.setScore(score);
 | 
	
		
			
				|  |  | +    //             item.setScore_type(663);
 | 
	
		
			
				|  |  | +    //         } catch (Exception e) {
 | 
	
		
			
				|  |  | +    //             log.error("svc=thompsonScorerByExp663 {}", gson.toJson(e.getStackTrace()));
 | 
	
		
			
				|  |  | +    //         }
 | 
	
		
			
				|  |  | +    //         result.add(item);
 | 
	
		
			
				|  |  | +    //         i++;
 | 
	
		
			
				|  |  | +    //     }
 | 
	
		
			
				|  |  | +    //     Collections.sort(result);
 | 
	
		
			
				|  |  | +    //     return result;
 | 
	
		
			
				|  |  | +    // }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public List<AdRankItem> thompsonScorerByExp663(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
 | 
	
		
			
				|  |  | +        List<AdRankItem> result = new LinkedList<>();
 | 
	
		
			
				|  |  | +        Map<Long, CreativeStatistic> creativeStatisticsMap = this.batchFindCreativeRedisCache(redisCreativeStatisticsPrefix, adIdList);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        double alpha = exp663Param.getOrDefault("alpha", 0d);
 | 
	
		
			
				|  |  | +        double beta = exp663Param.getOrDefault("beta", 0d);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                Map<String, Object> ext = this.extMap(statistic, "663", dto.getCpa(), null, exp663Param.getOrDefault("alpha", 1d), exp663Param.getOrDefault("beta", 10000d), null);
 | 
	
		
			
				|  |  | -                ext.put("s1", s1);
 | 
	
		
			
				|  |  | -                item.setExt(ext);
 | 
	
		
			
				|  |  | -                item.setScore(score);
 | 
	
		
			
				|  |  | -                item.setScore_type(663);
 | 
	
		
			
				|  |  | -            }catch (Exception e){
 | 
	
		
			
				|  |  | -                log.error("svc=thompsonScorerByExp663 {}",gson.toJson(e.getStackTrace()));
 | 
	
		
			
				|  |  | +        for (AdPlatformCreativeDTO dto : adIdList) {
 | 
	
		
			
				|  |  | +            CreativeStatistic cidStatistics = creativeStatisticsMap.getOrDefault(dto.getCreativeId(), new CreativeStatistic());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            double order;
 | 
	
		
			
				|  |  | +            double exp;
 | 
	
		
			
				|  |  | +            order = cidStatistics.parseOrderToDouble();
 | 
	
		
			
				|  |  | +            exp = cidStatistics.parseExpToDouble();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            double s1 = 0.0;
 | 
	
		
			
				|  |  | +            double a = order + alpha;
 | 
	
		
			
				|  |  | +            double b = exp + beta;
 | 
	
		
			
				|  |  | +            if (a != 0 && b != 0) {
 | 
	
		
			
				|  |  | +                s1 = a / b;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            double score = s1 * dto.getCpa() * dto.getBid1() * dto.getBid2();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            // 日志上报扩展参数
 | 
	
		
			
				|  |  | +            Map<String, Object> ext = new HashMap<>();
 | 
	
		
			
				|  |  | +            ext.put("a", alpha);
 | 
	
		
			
				|  |  | +            ext.put("b", beta);
 | 
	
		
			
				|  |  | +            ext.put("order", order);
 | 
	
		
			
				|  |  | +            ext.put("exp", exp);
 | 
	
		
			
				|  |  | +            ext.put("s1", s1);
 | 
	
		
			
				|  |  | +            ext.put("pairOrSingle", "single");
 | 
	
		
			
				|  |  | +            ext.put("cidStatistic", JSON.toJSONString(cidStatistics));
 | 
	
		
			
				|  |  | +            ext.put("cpa", dto.getCpa());
 | 
	
		
			
				|  |  | +            ext.put("abCode", 663);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            AdRankItem item = new AdRankItem();
 | 
	
		
			
				|  |  | +            item.setCpa(dto.getCpa());
 | 
	
		
			
				|  |  | +            item.setAdId(dto.getCreativeId());
 | 
	
		
			
				|  |  | +            item.setScore(score);
 | 
	
		
			
				|  |  | +            item.setExt(ext);
 | 
	
		
			
				|  |  | +            item.setVideoId(param.getVideoId());
 | 
	
		
			
				|  |  | +            item.setScore_type(663);
 | 
	
		
			
				|  |  |              result.add(item);
 | 
	
		
			
				|  |  | -            i++;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        Collections.sort(result);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        result.sort(equalsRandomComparator());
 | 
	
		
			
				|  |  |          return result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    public List<AdRankItem> thompsonScorerByExp664(ScoreParam param,List<AdPlatformCreativeDTO> adIdList){
 | 
	
		
			
				|  |  | -        List<AdRankItem> result=new LinkedList<>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public List<AdRankItem> thompsonScorerByExp664(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
 | 
	
		
			
				|  |  | +        List<AdRankItem> result = new LinkedList<>();
 | 
	
		
			
				|  |  |          String jsonStr;
 | 
	
		
			
				|  |  | -        CreativeStatistic statistic=null;
 | 
	
		
			
				|  |  | -        List<String> redisKey=new LinkedList<>();
 | 
	
		
			
				|  |  | +        CreativeStatistic statistic = null;
 | 
	
		
			
				|  |  | +        List<String> redisKey = new LinkedList<>();
 | 
	
		
			
				|  |  |          adIdList.forEach(creativeDTO -> {
 | 
	
		
			
				|  |  | -            redisKey.add(redisVideoCreativeStatisticsPrefix+param.getVideoId()+"_"+creativeDTO.getCreativeId());
 | 
	
		
			
				|  |  | +            redisKey.add(redisVideoCreativeStatisticsPrefix + param.getVideoId() + "_" + creativeDTO.getCreativeId());
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | -        List<String> values=redisHelper.getValues(redisKey);
 | 
	
		
			
				|  |  | -        int i=0;
 | 
	
		
			
				|  |  | -        double score=0d;
 | 
	
		
			
				|  |  | -        for(AdPlatformCreativeDTO dto:adIdList){
 | 
	
		
			
				|  |  | -            AdRankItem item=new AdRankItem();
 | 
	
		
			
				|  |  | +        List<String> values = redisHelper.getValues(redisKey);
 | 
	
		
			
				|  |  | +        int i = 0;
 | 
	
		
			
				|  |  | +        double score = 0d;
 | 
	
		
			
				|  |  | +        for (AdPlatformCreativeDTO dto : adIdList) {
 | 
	
		
			
				|  |  | +            AdRankItem item = new AdRankItem();
 | 
	
		
			
				|  |  |              item.setVideoId(param.getVideoId());
 | 
	
		
			
				|  |  |              item.setCpa(dto.getCpa());
 | 
	
		
			
				|  |  |              item.setAdId(dto.getCreativeId());
 | 
	
		
			
				|  |  |              try {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                jsonStr=values.get(i);
 | 
	
		
			
				|  |  | -                if(jsonStr==null){
 | 
	
		
			
				|  |  | -                    score = exp664Param.getOrDefault("randomMin",0.000001)
 | 
	
		
			
				|  |  | +                jsonStr = values.get(i);
 | 
	
		
			
				|  |  | +                if (jsonStr == null) {
 | 
	
		
			
				|  |  | +                    score = exp664Param.getOrDefault("randomMin", 0.000001)
 | 
	
		
			
				|  |  |                              + (random.nextDouble() *
 | 
	
		
			
				|  |  | -                            (exp664Param.getOrDefault("randomMax",0.00001 ) - exp664Param.getOrDefault("randomMin",0.000001 )));
 | 
	
		
			
				|  |  | -                }else {
 | 
	
		
			
				|  |  | -                    statistic =gson.fromJson(jsonStr,CreativeStatistic.class);
 | 
	
		
			
				|  |  | -                    score = (exp664Param.getOrDefault("alpha",1d)+Long.parseLong(statistic.getOrder()))
 | 
	
		
			
				|  |  | -                            / (exp664Param.getOrDefault("beta",10000d)+Long.parseLong(statistic.getExp())) ;
 | 
	
		
			
				|  |  | +                            (exp664Param.getOrDefault("randomMax", 0.00001) - exp664Param.getOrDefault("randomMin", 0.000001)));
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    statistic = gson.fromJson(jsonStr, CreativeStatistic.class);
 | 
	
		
			
				|  |  | +                    score = (exp664Param.getOrDefault("alpha", 1d) + Long.parseLong(statistic.getOrder()))
 | 
	
		
			
				|  |  | +                            / (exp664Param.getOrDefault("beta", 10000d) + Long.parseLong(statistic.getExp()));
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  double s1 = score;
 | 
	
		
			
				|  |  | -                score=score*dto.getCpa()*dto.getBid1()*dto.getBid2();
 | 
	
		
			
				|  |  | +                score = score * dto.getCpa() * dto.getBid1() * dto.getBid2();
 | 
	
		
			
				|  |  |                  item.setScore(score);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                Map<String, Object> ext = this.extMap(statistic, "664", dto.getCpa(), null, exp663Param.getOrDefault("alpha", 1d), exp663Param.getOrDefault("beta", 10000d), null);
 | 
	
		
			
				|  |  | +                Map<String, Object> ext = this.extMap(statistic, "664", dto.getCpa(), null,
 | 
	
		
			
				|  |  | +                        exp664Param.getOrDefault("alpha", 1d), exp664Param.getOrDefault("beta", 10000d), null);
 | 
	
		
			
				|  |  |                  ext.put("s1", s1);
 | 
	
		
			
				|  |  |                  item.setExt(ext);
 | 
	
		
			
				|  |  |                  item.setScore_type(664);
 | 
	
		
			
				|  |  | -            }catch (Exception e){
 | 
	
		
			
				|  |  | -                log.error("svc=thompsonScorerByExp664 {}",gson.toJson(e.getStackTrace()));
 | 
	
		
			
				|  |  | +            } catch (Exception e) {
 | 
	
		
			
				|  |  | +                log.error("svc=thompsonScorerByExp664 {}", gson.toJson(e.getStackTrace()));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              result.add(item);
 | 
	
		
			
				|  |  |              i++;
 | 
	
	
		
			
				|  | @@ -131,42 +185,44 @@ public class VideoAdThompsonScorerV2 {
 | 
	
		
			
				|  |  |          Collections.sort(result);
 | 
	
		
			
				|  |  |          return result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    public List<AdRankItem> thompsonScorerByExp665(ScoreParam param,List<AdPlatformCreativeDTO> adIdList){
 | 
	
		
			
				|  |  | -        List<AdRankItem> result=new LinkedList<>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public List<AdRankItem> thompsonScorerByExp665(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
 | 
	
		
			
				|  |  | +        List<AdRankItem> result = new LinkedList<>();
 | 
	
		
			
				|  |  |          String jsonStr;
 | 
	
		
			
				|  |  |          CreativeStatistic statistic = null;
 | 
	
		
			
				|  |  | -        List<String> redisKey=new LinkedList<>();
 | 
	
		
			
				|  |  | +        List<String> redisKey = new LinkedList<>();
 | 
	
		
			
				|  |  |          adIdList.forEach(creativeDTO -> {
 | 
	
		
			
				|  |  | -            redisKey.add(redisCreativeStatisticsPrefix+creativeDTO.getCreativeId());
 | 
	
		
			
				|  |  | +            redisKey.add(redisCreativeStatisticsPrefix + creativeDTO.getCreativeId());
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | -        //view/sum(view)
 | 
	
		
			
				|  |  | -        List<String> values=redisHelper.getValues(redisKey);
 | 
	
		
			
				|  |  | -        int i=0;
 | 
	
		
			
				|  |  | -        double score=0d;
 | 
	
		
			
				|  |  | -        for(AdPlatformCreativeDTO dto:adIdList){
 | 
	
		
			
				|  |  | -            AdRankItem item=new AdRankItem();
 | 
	
		
			
				|  |  | +        // view/sum(view)
 | 
	
		
			
				|  |  | +        List<String> values = redisHelper.getValues(redisKey);
 | 
	
		
			
				|  |  | +        int i = 0;
 | 
	
		
			
				|  |  | +        double score = 0d;
 | 
	
		
			
				|  |  | +        for (AdPlatformCreativeDTO dto : adIdList) {
 | 
	
		
			
				|  |  | +            AdRankItem item = new AdRankItem();
 | 
	
		
			
				|  |  |              item.setVideoId(param.getVideoId());
 | 
	
		
			
				|  |  |              item.setCpa(dto.getCpa());
 | 
	
		
			
				|  |  |              item.setAdId(dto.getCreativeId());
 | 
	
		
			
				|  |  |              try {
 | 
	
		
			
				|  |  | -                jsonStr=values.get(i);
 | 
	
		
			
				|  |  | -                if(jsonStr==null){
 | 
	
		
			
				|  |  | -                    score = betaSampler(exp665Param.getOrDefault("alpha",1d),exp665Param.getOrDefault("beta",100000d));
 | 
	
		
			
				|  |  | -                }else {
 | 
	
		
			
				|  |  | -                    statistic =gson.fromJson(jsonStr,CreativeStatistic.class);
 | 
	
		
			
				|  |  | -                    score = betaSampler(exp665Param.getOrDefault("alpha",1d)+Long.parseLong(statistic.getOrder()) ,
 | 
	
		
			
				|  |  | -                            (exp665Param.getOrDefault("beta",100000d)+Long.parseLong(statistic.getExp())))/ (1+exp665Param.getOrDefault("beta_k",9d));
 | 
	
		
			
				|  |  | +                jsonStr = values.get(i);
 | 
	
		
			
				|  |  | +                if (jsonStr == null) {
 | 
	
		
			
				|  |  | +                    score = betaSampler(exp665Param.getOrDefault("alpha", 1d), exp665Param.getOrDefault("beta", 100000d));
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    statistic = gson.fromJson(jsonStr, CreativeStatistic.class);
 | 
	
		
			
				|  |  | +                    score = betaSampler(exp665Param.getOrDefault("alpha", 1d) + Long.parseLong(statistic.getOrder()),
 | 
	
		
			
				|  |  | +                            (exp665Param.getOrDefault("beta", 100000d) + Long.parseLong(statistic.getExp()))) / (1 + exp665Param.getOrDefault("beta_k", 9d));
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  double s1 = score;
 | 
	
		
			
				|  |  | -                score=score*dto.getCpa()*dto.getBid1()*dto.getBid2();
 | 
	
		
			
				|  |  | +                score = score * dto.getCpa() * dto.getBid1() * dto.getBid2();
 | 
	
		
			
				|  |  |                  item.setScore(score);
 | 
	
		
			
				|  |  |                  item.setScore_type(665);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                Map<String, Object> ext = this.extMap(statistic, "665", dto.getCpa(), null, exp663Param.getOrDefault("alpha", 1d), exp663Param.getOrDefault("beta", 10000d), null);
 | 
	
		
			
				|  |  | +                Map<String, Object> ext = this.extMap(statistic, "665", dto.getCpa(), null,
 | 
	
		
			
				|  |  | +                        exp665Param.getOrDefault("alpha", 1d), exp665Param.getOrDefault("beta", 10000d), null);
 | 
	
		
			
				|  |  |                  ext.put("s1", s1);
 | 
	
		
			
				|  |  |                  item.setExt(ext);
 | 
	
		
			
				|  |  | -            }catch (Exception e){
 | 
	
		
			
				|  |  | -                log.error("svc=thompsonScorerByExp665 {}",gson.toJson(e.getStackTrace()));
 | 
	
		
			
				|  |  | +            } catch (Exception e) {
 | 
	
		
			
				|  |  | +                log.error("svc=thompsonScorerByExp665 {}", gson.toJson(e.getStackTrace()));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              result.add(item);
 | 
	
		
			
				|  |  |              i++;
 | 
	
	
		
			
				|  | @@ -175,73 +231,135 @@ public class VideoAdThompsonScorerV2 {
 | 
	
		
			
				|  |  |          Collections.sort(result);
 | 
	
		
			
				|  |  |          return result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    public List<AdRankItem> thompsonScorerByExp666(ScoreParam param,List<AdPlatformCreativeDTO> adIdList){
 | 
	
		
			
				|  |  | -        List<AdRankItem> result=new LinkedList<>();
 | 
	
		
			
				|  |  | -        String jsonStr;
 | 
	
		
			
				|  |  | -        CreativeStatistic statistic = null;
 | 
	
		
			
				|  |  | +    // public List<AdRankItem> thompsonScorerByExp666(ScoreParam param,List<AdPlatformCreativeDTO> adIdList){
 | 
	
		
			
				|  |  | +    //     List<AdRankItem> result=new LinkedList<>();
 | 
	
		
			
				|  |  | +    //     String jsonStr;
 | 
	
		
			
				|  |  | +    //     CreativeStatistic statistic = null;
 | 
	
		
			
				|  |  | +    //
 | 
	
		
			
				|  |  | +    //     List<String> redisKey=new LinkedList<>();
 | 
	
		
			
				|  |  | +    //     adIdList.forEach(creativeDTO -> {
 | 
	
		
			
				|  |  | +    //         redisKey.add(redisCreativeStatisticsPrefix+creativeDTO.getCreativeId());
 | 
	
		
			
				|  |  | +    //     });
 | 
	
		
			
				|  |  | +    //     List<String> values=redisHelper.getValues(redisKey);
 | 
	
		
			
				|  |  | +    //     List<String> combineKeys=new LinkedList<>();
 | 
	
		
			
				|  |  | +    //     adIdList.forEach(creativeDTO -> {
 | 
	
		
			
				|  |  | +    //         combineKeys.add(redisVideoCreativeStatisticsPrefix+param.getVideoId()+"_"+creativeDTO.getCreativeId());
 | 
	
		
			
				|  |  | +    //     });
 | 
	
		
			
				|  |  | +    //     List<String> combineValues=redisHelper.getValues(combineKeys);
 | 
	
		
			
				|  |  | +    //     int i=0;
 | 
	
		
			
				|  |  | +    //     double score=0d;
 | 
	
		
			
				|  |  | +    //     for(AdPlatformCreativeDTO dto:adIdList){
 | 
	
		
			
				|  |  | +    //         String statisticType = "vid+cid";
 | 
	
		
			
				|  |  | +    //         AdRankItem item=new AdRankItem();
 | 
	
		
			
				|  |  | +    //         item.setVideoId(param.getVideoId());
 | 
	
		
			
				|  |  | +    //         item.setCpa(dto.getCpa());
 | 
	
		
			
				|  |  | +    //         item.setAdId(dto.getCreativeId());
 | 
	
		
			
				|  |  | +    //         try {
 | 
	
		
			
				|  |  | +    //             jsonStr=combineValues.get(i);
 | 
	
		
			
				|  |  | +    //             if(jsonStr==null){
 | 
	
		
			
				|  |  | +    //                 jsonStr=values.get(i);
 | 
	
		
			
				|  |  | +    //                 if(jsonStr==null){
 | 
	
		
			
				|  |  | +    //                     statisticType = "";
 | 
	
		
			
				|  |  | +    //                     score = betaSampler(exp666Param.getOrDefault("alpha",1d),exp666Param.getOrDefault("beta",100000d));
 | 
	
		
			
				|  |  | +    //                 }else {
 | 
	
		
			
				|  |  | +    //                     statisticType = "cid";
 | 
	
		
			
				|  |  | +    //                     statistic =gson.fromJson(jsonStr,CreativeStatistic.class);
 | 
	
		
			
				|  |  | +    //                     score = betaSampler(exp666Param.getOrDefault("alpha",1d)+Long.parseLong(statistic.getOrder()) ,
 | 
	
		
			
				|  |  | +    //                             (exp666Param.getOrDefault("beta",100000d)+Long.parseLong(statistic.getExp()))/(1+exp666Param.getOrDefault("beta_k",9d))) ;
 | 
	
		
			
				|  |  | +    //                 }
 | 
	
		
			
				|  |  | +    //             }else {
 | 
	
		
			
				|  |  | +    //                 statistic =gson.fromJson(jsonStr,CreativeStatistic.class);
 | 
	
		
			
				|  |  | +    //                 if(Double.parseDouble(statistic.getExp())>exp666Param.getOrDefault("viewThreshold",5000d)){
 | 
	
		
			
				|  |  | +    //                     score = betaSampler(exp666Param.getOrDefault("alpha",1d)+Long.parseLong(statistic.getOrder()) ,
 | 
	
		
			
				|  |  | +    //                             (exp666Param.getOrDefault("beta",100000d)+Long.parseLong(statistic.getExp()))/(1+exp666Param.getOrDefault("beta_k",9d))) ;
 | 
	
		
			
				|  |  | +    //                 } else if( values.get(i)!=null) {
 | 
	
		
			
				|  |  | +    //                     statistic =gson.fromJson(values.get(i),CreativeStatistic.class);
 | 
	
		
			
				|  |  | +    //                     score = betaSampler(exp666Param.getOrDefault("alpha",1d)+Long.parseLong(statistic.getOrder()) ,
 | 
	
		
			
				|  |  | +    //                             (exp666Param.getOrDefault("beta",100000d)+Long.parseLong(statistic.getExp()))/(1+exp666Param.getOrDefault("beta_k",9d))) ;
 | 
	
		
			
				|  |  | +    //                 }else {
 | 
	
		
			
				|  |  | +    //                     score = betaSampler(exp666Param.getOrDefault("alpha",1d),exp666Param.getOrDefault("beta",100000d));
 | 
	
		
			
				|  |  | +    //                 }
 | 
	
		
			
				|  |  | +    //             }
 | 
	
		
			
				|  |  | +    //             double s1 = score;
 | 
	
		
			
				|  |  | +    //             score=score*dto.getCpa()*dto.getBid1()*dto.getBid2();
 | 
	
		
			
				|  |  | +    //             item.setScore(score);
 | 
	
		
			
				|  |  | +    //             item.setScore_type(666);
 | 
	
		
			
				|  |  | +    //
 | 
	
		
			
				|  |  | +    //             Map<String, Object> ext = this.extMap(statistic, "666", dto.getCpa(), exp666Param.getOrDefault("viewThreshold",5000d), exp663Param.getOrDefault("alpha", 1d),
 | 
	
		
			
				|  |  | +    //                     exp663Param.getOrDefault("beta", 10000d), exp666Param.getOrDefault("beta_k",9d));
 | 
	
		
			
				|  |  | +    //             ext.put("s1", s1);
 | 
	
		
			
				|  |  | +    //             ext.put("group_field", statisticType);
 | 
	
		
			
				|  |  | +    //             item.setExt(ext);
 | 
	
		
			
				|  |  | +    //
 | 
	
		
			
				|  |  | +    //         }catch (Exception e){
 | 
	
		
			
				|  |  | +    //             log.error("svc=thompsonScorerByExp666 {}",gson.toJson(e.getStackTrace()));
 | 
	
		
			
				|  |  | +    //         }
 | 
	
		
			
				|  |  | +    //         result.add(item);
 | 
	
		
			
				|  |  | +    //         i++;
 | 
	
		
			
				|  |  | +    //     }
 | 
	
		
			
				|  |  | +    //     Collections.sort(result);
 | 
	
		
			
				|  |  | +    //     return result;
 | 
	
		
			
				|  |  | +    // }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public List<AdRankItem> thompsonScorerByExp666(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
 | 
	
		
			
				|  |  | +        List<AdRankItem> result = new LinkedList<>();
 | 
	
		
			
				|  |  | +        Map<Long, CreativeStatistic> creativeStatisticsMap = this.batchFindCreativeRedisCache(redisCreativeStatisticsPrefix, adIdList);
 | 
	
		
			
				|  |  | +        Map<Long, CreativeStatistic> videoCreativeStatisticsMap = this.batchFindCreativeRedisCache(redisVideoCreativeStatisticsPrefix + param.getVideoId() + "_", adIdList);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        double alpha = exp666Param.getOrDefault("alpha", 0d);
 | 
	
		
			
				|  |  | +        double beta = exp666Param.getOrDefault("beta", 0d);
 | 
	
		
			
				|  |  | +        double betaK = exp666Param.getOrDefault("beta_k", 0d) + 1;
 | 
	
		
			
				|  |  | +        double viewThreshold = exp666Param.getOrDefault("viewThreshold", 7000d);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        List<String> redisKey=new LinkedList<>();
 | 
	
		
			
				|  |  | -        adIdList.forEach(creativeDTO -> {
 | 
	
		
			
				|  |  | -            redisKey.add(redisCreativeStatisticsPrefix+creativeDTO.getCreativeId());
 | 
	
		
			
				|  |  | -        });
 | 
	
		
			
				|  |  | -        List<String> values=redisHelper.getValues(redisKey);
 | 
	
		
			
				|  |  | -        List<String> combineKeys=new LinkedList<>();
 | 
	
		
			
				|  |  | -        adIdList.forEach(creativeDTO -> {
 | 
	
		
			
				|  |  | -            combineKeys.add(redisVideoCreativeStatisticsPrefix+param.getVideoId()+"_"+creativeDTO.getCreativeId());
 | 
	
		
			
				|  |  | -        });
 | 
	
		
			
				|  |  | -        List<String> combineValues=redisHelper.getValues(combineKeys);
 | 
	
		
			
				|  |  | -        int i=0;
 | 
	
		
			
				|  |  | -        double score=0d;
 | 
	
		
			
				|  |  | -        for(AdPlatformCreativeDTO dto:adIdList){
 | 
	
		
			
				|  |  | -            String statisticType = "vid+cid";
 | 
	
		
			
				|  |  | -            AdRankItem item=new AdRankItem();
 | 
	
		
			
				|  |  | -            item.setVideoId(param.getVideoId());
 | 
	
		
			
				|  |  | +        for (AdPlatformCreativeDTO dto : adIdList) {
 | 
	
		
			
				|  |  | +            Long cid = dto.getCreativeId();
 | 
	
		
			
				|  |  | +            String pairOrSingle;
 | 
	
		
			
				|  |  | +            double order;
 | 
	
		
			
				|  |  | +            double exp;
 | 
	
		
			
				|  |  | +            CreativeStatistic vidCidStatistics = videoCreativeStatisticsMap.getOrDefault(cid, new CreativeStatistic());
 | 
	
		
			
				|  |  | +            CreativeStatistic cidStatistics = creativeStatisticsMap.getOrDefault(cid, new CreativeStatistic());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (vidCidStatistics.parseExpToDouble() >= viewThreshold) {
 | 
	
		
			
				|  |  | +                pairOrSingle = "pair";
 | 
	
		
			
				|  |  | +                order = vidCidStatistics.parseOrderToDouble();
 | 
	
		
			
				|  |  | +                exp = vidCidStatistics.parseExpToDouble();
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                pairOrSingle = "single";
 | 
	
		
			
				|  |  | +                order = cidStatistics.parseOrderToDouble();
 | 
	
		
			
				|  |  | +                exp = cidStatistics.parseExpToDouble();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            double s1 = this.betaSampler((alpha + order), ((beta + exp) / betaK));
 | 
	
		
			
				|  |  | +            double score = s1 * dto.getCpa() * dto.getBid1() * dto.getBid2();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            // 日志上报扩展参数
 | 
	
		
			
				|  |  | +            Map<String, Object> ext = new HashMap<>();
 | 
	
		
			
				|  |  | +            ext.put("a", alpha);
 | 
	
		
			
				|  |  | +            ext.put("b", beta);
 | 
	
		
			
				|  |  | +            ext.put("bk", betaK);
 | 
	
		
			
				|  |  | +            ext.put("order", order);
 | 
	
		
			
				|  |  | +            ext.put("exp", exp);
 | 
	
		
			
				|  |  | +            ext.put("s1", s1);
 | 
	
		
			
				|  |  | +            ext.put("viewThreshold", viewThreshold);
 | 
	
		
			
				|  |  | +            ext.put("pairOrSingle", pairOrSingle);
 | 
	
		
			
				|  |  | +            ext.put("cidStatistic", JSON.toJSONString(cidStatistics));
 | 
	
		
			
				|  |  | +            ext.put("vidCidStatistic", JSON.toJSONString(vidCidStatistics));
 | 
	
		
			
				|  |  | +            ext.put("cpa", dto.getCpa());
 | 
	
		
			
				|  |  | +            ext.put("abCode", 666);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            AdRankItem item = new AdRankItem();
 | 
	
		
			
				|  |  |              item.setCpa(dto.getCpa());
 | 
	
		
			
				|  |  |              item.setAdId(dto.getCreativeId());
 | 
	
		
			
				|  |  | -            try {
 | 
	
		
			
				|  |  | -                jsonStr=combineValues.get(i);
 | 
	
		
			
				|  |  | -                if(jsonStr==null){
 | 
	
		
			
				|  |  | -                    jsonStr=values.get(i);
 | 
	
		
			
				|  |  | -                    if(jsonStr==null){
 | 
	
		
			
				|  |  | -                        statisticType = "";
 | 
	
		
			
				|  |  | -                        score = betaSampler(exp666Param.getOrDefault("alpha",1d),exp666Param.getOrDefault("beta",100000d));
 | 
	
		
			
				|  |  | -                    }else {
 | 
	
		
			
				|  |  | -                        statisticType = "cid";
 | 
	
		
			
				|  |  | -                        statistic =gson.fromJson(jsonStr,CreativeStatistic.class);
 | 
	
		
			
				|  |  | -                        score = betaSampler(exp666Param.getOrDefault("alpha",1d)+Long.parseLong(statistic.getOrder()) ,
 | 
	
		
			
				|  |  | -                                (exp666Param.getOrDefault("beta",100000d)+Long.parseLong(statistic.getExp()))/(1+exp666Param.getOrDefault("beta_k",9d))) ;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }else {
 | 
	
		
			
				|  |  | -                    statistic =gson.fromJson(jsonStr,CreativeStatistic.class);
 | 
	
		
			
				|  |  | -                    if(Double.parseDouble(statistic.getExp())>exp666Param.getOrDefault("viewThreshold",5000d)){
 | 
	
		
			
				|  |  | -                        score = betaSampler(exp666Param.getOrDefault("alpha",1d)+Long.parseLong(statistic.getOrder()) ,
 | 
	
		
			
				|  |  | -                                (exp666Param.getOrDefault("beta",100000d)+Long.parseLong(statistic.getExp()))/(1+exp666Param.getOrDefault("beta_k",9d))) ;
 | 
	
		
			
				|  |  | -                    } else if( values.get(i)!=null) {
 | 
	
		
			
				|  |  | -                        statistic =gson.fromJson(values.get(i),CreativeStatistic.class);
 | 
	
		
			
				|  |  | -                        score = betaSampler(exp666Param.getOrDefault("alpha",1d)+Long.parseLong(statistic.getOrder()) ,
 | 
	
		
			
				|  |  | -                                (exp666Param.getOrDefault("beta",100000d)+Long.parseLong(statistic.getExp()))/(1+exp666Param.getOrDefault("beta_k",9d))) ;
 | 
	
		
			
				|  |  | -                    }else {
 | 
	
		
			
				|  |  | -                        score = betaSampler(exp666Param.getOrDefault("alpha",1d),exp666Param.getOrDefault("beta",100000d));
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                double s1 = score;
 | 
	
		
			
				|  |  | -                score=score*dto.getCpa()*dto.getBid1()*dto.getBid2();
 | 
	
		
			
				|  |  | -                item.setScore(score);
 | 
	
		
			
				|  |  | -                item.setScore_type(666);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                Map<String, Object> ext = this.extMap(statistic, "666", dto.getCpa(), exp666Param.getOrDefault("viewThreshold",5000d), exp663Param.getOrDefault("alpha", 1d),
 | 
	
		
			
				|  |  | -                        exp663Param.getOrDefault("beta", 10000d), exp666Param.getOrDefault("beta_k",9d));
 | 
	
		
			
				|  |  | -                ext.put("s1", s1);
 | 
	
		
			
				|  |  | -                ext.put("group_field", statisticType);
 | 
	
		
			
				|  |  | -                item.setExt(ext);
 | 
	
		
			
				|  |  | +            item.setScore(score);
 | 
	
		
			
				|  |  | +            item.setExt(ext);
 | 
	
		
			
				|  |  | +            item.setVideoId(param.getVideoId());
 | 
	
		
			
				|  |  | +            item.setScore_type(666);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            }catch (Exception e){
 | 
	
		
			
				|  |  | -                log.error("svc=thompsonScorerByExp666 {}",gson.toJson(e.getStackTrace()));
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  |              result.add(item);
 | 
	
		
			
				|  |  | -            i++;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        Collections.sort(result);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        result.sort(equalsRandomComparator());
 | 
	
		
			
				|  |  |          return result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -252,7 +370,7 @@ public class VideoAdThompsonScorerV2 {
 | 
	
		
			
				|  |  |          Double videoCreativeExpSum = this.sumCreativeStatisticExp(videoCreativeStatisticsMap.values());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<AdRankItem> result = new ArrayList<>(adIdList.size());
 | 
	
		
			
				|  |  | -        this.calcScore(result, adIdList,1d, creativeExpSum, videoCreativeExpSum, creativeStatisticsMap, videoCreativeStatisticsMap, exp669Param);
 | 
	
		
			
				|  |  | +        this.calcScore(result, adIdList, 1d, creativeExpSum, videoCreativeExpSum, creativeStatisticsMap, videoCreativeStatisticsMap, exp669Param);
 | 
	
		
			
				|  |  |          result.sort(equalsRandomComparator());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          for (AdRankItem adRankItem : result) {
 | 
	
	
		
			
				|  | @@ -277,7 +395,7 @@ public class VideoAdThompsonScorerV2 {
 | 
	
		
			
				|  |  |          for (AdRankItem adRankItem : result) {
 | 
	
		
			
				|  |  |              adRankItem.setVideoId(param.getVideoId());
 | 
	
		
			
				|  |  |              adRankItem.setScore_type(670);
 | 
	
		
			
				|  |  | -            if (MapUtils.isNotEmpty(adRankItem.getExt())){
 | 
	
		
			
				|  |  | +            if (MapUtils.isNotEmpty(adRankItem.getExt())) {
 | 
	
		
			
				|  |  |                  adRankItem.getExt().put("abCode", 670);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -285,7 +403,7 @@ public class VideoAdThompsonScorerV2 {
 | 
	
		
			
				|  |  |          return result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private void calcScore(List<AdRankItem> result, List<AdPlatformCreativeDTO> adIdList,Double alpha, Double cidBeta, Double vidCidBeta, Map<Long, CreativeStatistic> cidMap, Map<Long, CreativeStatistic> vidCidMap, Map<String, Double> expParam) {
 | 
	
		
			
				|  |  | +    private void calcScore(List<AdRankItem> result, List<AdPlatformCreativeDTO> adIdList, Double alpha, Double cidBeta, Double vidCidBeta, Map<Long, CreativeStatistic> cidMap, Map<Long, CreativeStatistic> vidCidMap, Map<String, Double> expParam) {
 | 
	
		
			
				|  |  |          for (AdPlatformCreativeDTO dto : adIdList) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              CreativeStatistic cidStatistic = cidMap.getOrDefault(dto.getCreativeId(), new CreativeStatistic());
 | 
	
	
		
			
				|  | @@ -351,9 +469,6 @@ public class VideoAdThompsonScorerV2 {
 | 
	
		
			
				|  |  |          double order = creativeStatistic.parseOrderToDouble() + alpha;
 | 
	
		
			
				|  |  |          double exp = creativeStatistic.parseExpToDouble() + beta;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if (order == 0 || exp == 0) {
 | 
	
		
			
				|  |  | -            return 0.0;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  |          log.info("calcThompsonScore.order: {}, exp: {}", order, exp);
 | 
	
		
			
				|  |  |          return this.betaSampler(order, exp);
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -399,7 +514,7 @@ public class VideoAdThompsonScorerV2 {
 | 
	
		
			
				|  |  |          return map;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    class CreativeStatistic{
 | 
	
		
			
				|  |  | +    class CreativeStatistic {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          private String exp;
 | 
	
		
			
				|  |  |          private String click;
 | 
	
	
		
			
				|  | @@ -420,7 +535,7 @@ public class VideoAdThompsonScorerV2 {
 | 
	
		
			
				|  |  |              return exp;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        public Double parseExpToDouble() {
 | 
	
		
			
				|  |  | +        public double parseExpToDouble() {
 | 
	
		
			
				|  |  |              if (StringUtils.isBlank(exp)) {
 | 
	
		
			
				|  |  |                  return 0.0;
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -438,8 +553,8 @@ public class VideoAdThompsonScorerV2 {
 | 
	
		
			
				|  |  |              return click;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        public Double parseClickToDouble(){
 | 
	
		
			
				|  |  | -            if (StringUtils.isBlank(click)){
 | 
	
		
			
				|  |  | +        public double parseClickToDouble() {
 | 
	
		
			
				|  |  | +            if (StringUtils.isBlank(click)) {
 | 
	
		
			
				|  |  |                  return 0.0;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              return Double.parseDouble(click);
 | 
	
	
		
			
				|  | @@ -456,8 +571,8 @@ public class VideoAdThompsonScorerV2 {
 | 
	
		
			
				|  |  |              return order;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        public Double parseOrderToDouble(){
 | 
	
		
			
				|  |  | -            if (StringUtils.isBlank(order)){
 | 
	
		
			
				|  |  | +        public double parseOrderToDouble() {
 | 
	
		
			
				|  |  | +            if (StringUtils.isBlank(order)) {
 | 
	
		
			
				|  |  |                  return 0.0;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              return Double.parseDouble(order);
 | 
	
	
		
			
				|  | @@ -474,40 +589,49 @@ public class VideoAdThompsonScorerV2 {
 | 
	
		
			
				|  |  |              return cpa;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        public Double parseCpaToDouble() {
 | 
	
		
			
				|  |  | +        public double parseCpaToDouble() {
 | 
	
		
			
				|  |  |              if (StringUtils.isBlank(cpa)) {
 | 
	
		
			
				|  |  |                  return 0.0;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              return Double.parseDouble(cpa);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      double betaSampler(double alpha, double beta) {
 | 
	
		
			
				|  |  | +        if (alpha == 0 || beta == 0) {
 | 
	
		
			
				|  |  | +            return 0.0d;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          BetaDistribution betaSample = new BetaDistribution(alpha, beta);
 | 
	
		
			
				|  |  |          return betaSample.sample();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Value("${ad.engine.new.thompson.exp.V2.663:{\"randomMin\":0.000001,\"randomMax\":0.00001,\"alpha\":1,\"beta\":10000}}")
 | 
	
		
			
				|  |  | -    public void setExp663Param(String str){
 | 
	
		
			
				|  |  | -        this.exp663Param=gson.fromJson(str,Map.class);
 | 
	
		
			
				|  |  | +    public void setExp663Param(String str) {
 | 
	
		
			
				|  |  | +        this.exp663Param = gson.fromJson(str, Map.class);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Value("${ad.engine.new.thompson.exp.V2.664:{}}")
 | 
	
		
			
				|  |  | -    public void setExp664Param(String str){
 | 
	
		
			
				|  |  | -        this.exp663Param=gson.fromJson(str,Map.class);
 | 
	
		
			
				|  |  | +    public void setExp664Param(String str) {
 | 
	
		
			
				|  |  | +        this.exp664Param = gson.fromJson(str, Map.class);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Value("${ad.engine.new.thompson.exp.V2.665:{}}")
 | 
	
		
			
				|  |  | -    public void setExp665Param(String str){
 | 
	
		
			
				|  |  | -        this.exp663Param=gson.fromJson(str,Map.class);
 | 
	
		
			
				|  |  | +    public void setExp665Param(String str) {
 | 
	
		
			
				|  |  | +        this.exp665Param = gson.fromJson(str, Map.class);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Value("${ad.engine.new.thompson.exp.V2.666:{}}")
 | 
	
		
			
				|  |  | -    public void setExp666Param(String str){
 | 
	
		
			
				|  |  | -        this.exp663Param=gson.fromJson(str,Map.class);
 | 
	
		
			
				|  |  | +    public void setExp666Param(String str) {
 | 
	
		
			
				|  |  | +        this.exp666Param = gson.fromJson(str, Map.class);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Value("${ad.engine.new.thompson.exp.V2.669:{}}")
 | 
	
		
			
				|  |  | -    public void setExp669Param(String str){
 | 
	
		
			
				|  |  | -        this.exp669Param=gson.fromJson(str,Map.class);
 | 
	
		
			
				|  |  | +    public void setExp669Param(String str) {
 | 
	
		
			
				|  |  | +        this.exp669Param = gson.fromJson(str, Map.class);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Value("${ad.engine.new.thompson.exp.V2.670:{}}")
 | 
	
		
			
				|  |  | -    public void setExp670Param(String str){
 | 
	
		
			
				|  |  | -        this.exp670Param=gson.fromJson(str,Map.class);
 | 
	
		
			
				|  |  | +    public void setExp670Param(String str) {
 | 
	
		
			
				|  |  | +        this.exp670Param = gson.fromJson(str, Map.class);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |