|
@@ -34,7 +34,7 @@ public class VideoAdThompsonScorerV2 {
|
|
|
public List<AdRankItem> thompsonScorerByExp663(ScoreParam param, List<AdPlatformCreativeDTO> adIdList){
|
|
|
List<AdRankItem> result=new LinkedList<>();
|
|
|
String jsonStr;
|
|
|
- CreativeStatistic statistic;
|
|
|
+ CreativeStatistic statistic = null;
|
|
|
List<String> redisKey=new LinkedList<>();
|
|
|
adIdList.forEach(creativeDTO -> {
|
|
|
redisKey.add(redisCreativeStatisticsPrefix+creativeDTO.getCreativeId());
|
|
@@ -59,6 +59,8 @@ public class VideoAdThompsonScorerV2 {
|
|
|
/ (exp663Param.getOrDefault("beta",10000d)+Long.parseLong(statistic.getExp())) ;
|
|
|
}
|
|
|
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);
|
|
|
+ item.setExt(ext);
|
|
|
item.setScore(score);
|
|
|
}catch (Exception e){
|
|
|
log.error("svc=thompsonScorerByExp663 {}",gson.toJson(e.getStackTrace()));
|
|
@@ -72,7 +74,7 @@ public class VideoAdThompsonScorerV2 {
|
|
|
public List<AdRankItem> thompsonScorerByExp664(ScoreParam param,List<AdPlatformCreativeDTO> adIdList){
|
|
|
List<AdRankItem> result=new LinkedList<>();
|
|
|
String jsonStr;
|
|
|
- CreativeStatistic statistic;
|
|
|
+ CreativeStatistic statistic=null;
|
|
|
List<String> redisKey=new LinkedList<>();
|
|
|
adIdList.forEach(creativeDTO -> {
|
|
|
redisKey.add(redisVideoCreativeStatisticsPrefix+param.getVideoId()+"_"+creativeDTO.getCreativeId());
|
|
@@ -99,6 +101,9 @@ public class VideoAdThompsonScorerV2 {
|
|
|
}
|
|
|
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);
|
|
|
+ item.setExt(ext);
|
|
|
}catch (Exception e){
|
|
|
log.error("svc=thompsonScorerByExp664 {}",gson.toJson(e.getStackTrace()));
|
|
|
}
|
|
@@ -112,7 +117,7 @@ public class VideoAdThompsonScorerV2 {
|
|
|
public List<AdRankItem> thompsonScorerByExp665(ScoreParam param,List<AdPlatformCreativeDTO> adIdList){
|
|
|
List<AdRankItem> result=new LinkedList<>();
|
|
|
String jsonStr;
|
|
|
- CreativeStatistic statistic;
|
|
|
+ CreativeStatistic statistic = null;
|
|
|
List<String> redisKey=new LinkedList<>();
|
|
|
adIdList.forEach(creativeDTO -> {
|
|
|
redisKey.add(redisCreativeStatisticsPrefix+creativeDTO.getCreativeId());
|
|
@@ -138,6 +143,8 @@ public class VideoAdThompsonScorerV2 {
|
|
|
score=score*dto.getCpa()*dto.getBid1()*dto.getBid2();
|
|
|
item.setScore(score);
|
|
|
|
|
|
+ Map<String, Object> ext = this.extMap(statistic, "665", dto.getCpa(), null, exp663Param.getOrDefault("alpha", 1d), exp663Param.getOrDefault("beta", 10000d), null);
|
|
|
+ item.setExt(ext);
|
|
|
}catch (Exception e){
|
|
|
log.error("svc=thompsonScorerByExp665 {}",gson.toJson(e.getStackTrace()));
|
|
|
}
|
|
@@ -151,7 +158,7 @@ public class VideoAdThompsonScorerV2 {
|
|
|
public List<AdRankItem> thompsonScorerByExp666(ScoreParam param,List<AdPlatformCreativeDTO> adIdList){
|
|
|
List<AdRankItem> result=new LinkedList<>();
|
|
|
String jsonStr;
|
|
|
- CreativeStatistic statistic;
|
|
|
+ CreativeStatistic statistic = null;
|
|
|
|
|
|
List<String> redisKey=new LinkedList<>();
|
|
|
adIdList.forEach(creativeDTO -> {
|
|
@@ -184,7 +191,7 @@ public class VideoAdThompsonScorerV2 {
|
|
|
}else {
|
|
|
statistic =gson.fromJson(jsonStr,CreativeStatistic.class);
|
|
|
if(Double.parseDouble(statistic.getExp())>exp666Param.getOrDefault("viewThreshold",5000d)){
|
|
|
- score = betaSampler(1d+Long.parseLong(statistic.getOrder()) ,
|
|
|
+ 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);
|
|
@@ -197,6 +204,10 @@ public class VideoAdThompsonScorerV2 {
|
|
|
score=score*dto.getCpa()*dto.getBid1()*dto.getBid2();
|
|
|
item.setScore(score);
|
|
|
|
|
|
+ Map<String, Object> ext = this.extMap(statistic, "665", dto.getCpa(), exp666Param.getOrDefault("viewThreshold",5000d), exp663Param.getOrDefault("alpha", 1d),
|
|
|
+ exp663Param.getOrDefault("beta", 10000d), exp666Param.getOrDefault("beta_k",9d));
|
|
|
+ item.setExt(ext);
|
|
|
+
|
|
|
}catch (Exception e){
|
|
|
log.error("svc=thompsonScorerByExp666 {}",gson.toJson(e.getStackTrace()));
|
|
|
}
|
|
@@ -206,6 +217,25 @@ public class VideoAdThompsonScorerV2 {
|
|
|
Collections.sort(result);
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ map.put("alpha", alpha);
|
|
|
+ map.put("beta", beta);
|
|
|
+ map.put("beta_k", beta_k);
|
|
|
+ map.put("cpa", cpa);
|
|
|
+ if (Objects.nonNull(statistic)) {
|
|
|
+ map.put("click", statistic.click);
|
|
|
+ map.put("order", statistic.getOrder());
|
|
|
+ map.put("exp", statistic.getExp());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
class CreativeStatistic{
|
|
|
public CreativeStatistic() {
|
|
|
}
|