|
@@ -43,7 +43,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());
|
|
@@ -67,7 +67,12 @@ public class VideoAdThompsonScorerV2 {
|
|
|
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){
|
|
@@ -82,7 +87,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());
|
|
@@ -107,8 +112,13 @@ public class VideoAdThompsonScorerV2 {
|
|
|
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();
|
|
|
item.setScore(score);
|
|
|
+
|
|
|
+ Map<String, Object> ext = this.extMap(statistic, "664", dto.getCpa(), null, exp663Param.getOrDefault("alpha", 1d), exp663Param.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()));
|
|
@@ -123,7 +133,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());
|
|
@@ -146,9 +156,14 @@ public class VideoAdThompsonScorerV2 {
|
|
|
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();
|
|
|
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);
|
|
|
+ ext.put("s1", s1);
|
|
|
+ item.setExt(ext);
|
|
|
}catch (Exception e){
|
|
|
log.error("svc=thompsonScorerByExp665 {}",gson.toJson(e.getStackTrace()));
|
|
|
}
|
|
@@ -162,7 +177,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 -> {
|
|
@@ -195,7 +210,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);
|
|
@@ -205,9 +220,16 @@ public class VideoAdThompsonScorerV2 {
|
|
|
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);
|
|
|
+ item.setExt(ext);
|
|
|
+
|
|
|
}catch (Exception e){
|
|
|
log.error("svc=thompsonScorerByExp666 {}",gson.toJson(e.getStackTrace()));
|
|
|
}
|
|
@@ -333,6 +355,25 @@ 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);
|
|
|
+ }
|
|
|
+ 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{
|
|
|
|
|
|
private String exp;
|