|
@@ -101,8 +101,10 @@ public class VideoAdThompsonScorerV2 {
|
|
// 日志上报扩展参数
|
|
// 日志上报扩展参数
|
|
Map<String, Object> ext = new HashMap<>();
|
|
Map<String, Object> ext = new HashMap<>();
|
|
double score = 0.0;
|
|
double score = 0.0;
|
|
|
|
+ double cpa = 0.0;
|
|
try {
|
|
try {
|
|
CreativeStatistic cidStatistics = creativeStatisticsMap.getOrDefault(dto.getCreativeId(), new CreativeStatistic());
|
|
CreativeStatistic cidStatistics = creativeStatisticsMap.getOrDefault(dto.getCreativeId(), new CreativeStatistic());
|
|
|
|
+ cpa = cidStatistics.parseCpaToDouble();
|
|
|
|
|
|
double order;
|
|
double order;
|
|
double exp;
|
|
double exp;
|
|
@@ -116,31 +118,27 @@ public class VideoAdThompsonScorerV2 {
|
|
s1 = a / b;
|
|
s1 = a / b;
|
|
}
|
|
}
|
|
|
|
|
|
- score = s1 * dto.getCpa() * dto.getBid1() * dto.getBid2();
|
|
|
|
|
|
+ score = s1 * cpa;
|
|
|
|
|
|
ext.put("alpha", alpha);
|
|
ext.put("alpha", alpha);
|
|
ext.put("beta", beta);
|
|
ext.put("beta", beta);
|
|
ext.put("order", order);
|
|
ext.put("order", order);
|
|
ext.put("exp", exp);
|
|
ext.put("exp", exp);
|
|
ext.put("s1", s1);
|
|
ext.put("s1", s1);
|
|
- ext.put("bid1", dto.getBid1());
|
|
|
|
- ext.put("bid2", dto.getBid2());
|
|
|
|
ext.put("pairOrSingle", "single");
|
|
ext.put("pairOrSingle", "single");
|
|
ext.put("cidStatistic", JSON.toJSONString(cidStatistics));
|
|
ext.put("cidStatistic", JSON.toJSONString(cidStatistics));
|
|
- ext.put("cpa", dto.getCpa());
|
|
|
|
|
|
+ ext.put("cpa", cpa);
|
|
ext.put("abCode", 663);
|
|
ext.put("abCode", 663);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("svc=663exp, error: ", e);
|
|
log.error("svc=663exp, error: ", e);
|
|
}
|
|
}
|
|
AdRankItem item = new AdRankItem();
|
|
AdRankItem item = new AdRankItem();
|
|
- item.setCpa(dto.getCpa());
|
|
|
|
|
|
+ item.setCpa(cpa);
|
|
item.setAdId(dto.getCreativeId());
|
|
item.setAdId(dto.getCreativeId());
|
|
item.setScore(score);
|
|
item.setScore(score);
|
|
item.setExt(ext);
|
|
item.setExt(ext);
|
|
item.setVideoId(param.getVideoId());
|
|
item.setVideoId(param.getVideoId());
|
|
item.setScore_type(663);
|
|
item.setScore_type(663);
|
|
- item.setBid1(dto.getBid1());
|
|
|
|
- item.setBid2(dto.getBid2());
|
|
|
|
item.setWeight(dto.getWeight());
|
|
item.setWeight(dto.getWeight());
|
|
item.setCreativeCode(dto.getCreativeCode());
|
|
item.setCreativeCode(dto.getCreativeCode());
|
|
result.add(item);
|
|
result.add(item);
|
|
@@ -337,6 +335,7 @@ public class VideoAdThompsonScorerV2 {
|
|
// 日志上报扩展参数
|
|
// 日志上报扩展参数
|
|
Map<String, Object> ext = new HashMap<>();
|
|
Map<String, Object> ext = new HashMap<>();
|
|
double score = 0.0;
|
|
double score = 0.0;
|
|
|
|
+ double cpa = cidStatistics.parseCpaToDouble();
|
|
try {
|
|
try {
|
|
|
|
|
|
|
|
|
|
@@ -351,7 +350,7 @@ public class VideoAdThompsonScorerV2 {
|
|
}
|
|
}
|
|
|
|
|
|
double s1 = this.betaSampler((alpha + order), ((beta + exp) / betaK));
|
|
double s1 = this.betaSampler((alpha + order), ((beta + exp) / betaK));
|
|
- score = s1 * dto.getCpa() * dto.getBid1() * dto.getBid2();
|
|
|
|
|
|
+ score = s1 * cpa;
|
|
|
|
|
|
|
|
|
|
ext.put("alpha", alpha);
|
|
ext.put("alpha", alpha);
|
|
@@ -360,26 +359,22 @@ public class VideoAdThompsonScorerV2 {
|
|
ext.put("order", order);
|
|
ext.put("order", order);
|
|
ext.put("exp", exp);
|
|
ext.put("exp", exp);
|
|
ext.put("s1", s1);
|
|
ext.put("s1", s1);
|
|
- ext.put("bid1", dto.getBid1());
|
|
|
|
- ext.put("bid2", dto.getBid2());
|
|
|
|
ext.put("viewThreshold", viewThreshold);
|
|
ext.put("viewThreshold", viewThreshold);
|
|
ext.put("pairOrSingle", pairOrSingle);
|
|
ext.put("pairOrSingle", pairOrSingle);
|
|
ext.put("cidStatistic", JSON.toJSONString(cidStatistics));
|
|
ext.put("cidStatistic", JSON.toJSONString(cidStatistics));
|
|
ext.put("vidCidStatistic", JSON.toJSONString(vidCidStatistics));
|
|
ext.put("vidCidStatistic", JSON.toJSONString(vidCidStatistics));
|
|
- ext.put("cpa", dto.getCpa());
|
|
|
|
|
|
+ ext.put("cpa", cpa);
|
|
ext.put("abCode", 666);
|
|
ext.put("abCode", 666);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("svc=666exp, error: ", e);
|
|
log.error("svc=666exp, error: ", e);
|
|
}
|
|
}
|
|
AdRankItem item = new AdRankItem();
|
|
AdRankItem item = new AdRankItem();
|
|
- item.setCpa(dto.getCpa());
|
|
|
|
|
|
+ item.setCpa(cpa);
|
|
item.setAdId(dto.getCreativeId());
|
|
item.setAdId(dto.getCreativeId());
|
|
item.setScore(score);
|
|
item.setScore(score);
|
|
item.setExt(ext);
|
|
item.setExt(ext);
|
|
item.setVideoId(param.getVideoId());
|
|
item.setVideoId(param.getVideoId());
|
|
item.setScore_type(666);
|
|
item.setScore_type(666);
|
|
- item.setBid2(dto.getBid2());
|
|
|
|
- item.setBid1(dto.getBid1());
|
|
|
|
item.setWeight(dto.getWeight());
|
|
item.setWeight(dto.getWeight());
|
|
item.setCreativeCode(dto.getCreativeCode());
|
|
item.setCreativeCode(dto.getCreativeCode());
|
|
result.add(item);
|
|
result.add(item);
|
|
@@ -444,9 +439,11 @@ public class VideoAdThompsonScorerV2 {
|
|
double w1 = expParam.getOrDefault("w1", 1d);
|
|
double w1 = expParam.getOrDefault("w1", 1d);
|
|
double w2 = expParam.getOrDefault("w2", 1d);
|
|
double w2 = expParam.getOrDefault("w2", 1d);
|
|
|
|
|
|
|
|
+ double cpa = cidStatistic.parseCpaToDouble();
|
|
|
|
+
|
|
double score = 0;
|
|
double score = 0;
|
|
if (w1 != 0 || w2 != 0) {
|
|
if (w1 != 0 || w2 != 0) {
|
|
- score = ((w1 * vidCidScore * vidCidExp + w2 * cidScore * cidExp) / (w1 + w2)) * dto.getCpa();
|
|
|
|
|
|
+ score = ((w1 * vidCidScore * vidCidExp + w2 * cidScore * cidExp) / (w1 * vidCidExp + w2 * cidExp)) * cpa;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -466,13 +463,13 @@ public class VideoAdThompsonScorerV2 {
|
|
ext.put("bid2", dto.getBid2());
|
|
ext.put("bid2", dto.getBid2());
|
|
ext.put("cidStatistic", JSON.toJSONString(cidStatistic));
|
|
ext.put("cidStatistic", JSON.toJSONString(cidStatistic));
|
|
ext.put("vidCidStatistic", JSON.toJSONString(vidCidStatistic));
|
|
ext.put("vidCidStatistic", JSON.toJSONString(vidCidStatistic));
|
|
- ext.put("cpa", dto.getCpa());
|
|
|
|
|
|
+ ext.put("cpa", cpa);
|
|
|
|
|
|
log.info("svc=699And670Score, score: {}, param: {}", score, JSON.toJSONString(ext));
|
|
log.info("svc=699And670Score, score: {}, param: {}", score, JSON.toJSONString(ext));
|
|
|
|
|
|
|
|
|
|
AdRankItem item = new AdRankItem();
|
|
AdRankItem item = new AdRankItem();
|
|
- item.setCpa(dto.getCpa());
|
|
|
|
|
|
+ item.setCpa(cpa);
|
|
item.setAdId(dto.getCreativeId());
|
|
item.setAdId(dto.getCreativeId());
|
|
item.setWeight(dto.getWeight());
|
|
item.setWeight(dto.getWeight());
|
|
item.setScore(score);
|
|
item.setScore(score);
|
|
@@ -482,6 +479,7 @@ public class VideoAdThompsonScorerV2 {
|
|
item.setCreativeCode(dto.getCreativeCode());
|
|
item.setCreativeCode(dto.getCreativeCode());
|
|
|
|
|
|
result.add(item);
|
|
result.add(item);
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -557,38 +555,38 @@ public class VideoAdThompsonScorerV2 {
|
|
}
|
|
}
|
|
|
|
|
|
public List<AdRankItem> thompsonScorerByExp672(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
|
|
public List<AdRankItem> thompsonScorerByExp672(ScoreParam param, List<AdPlatformCreativeDTO> adIdList) {
|
|
- String cidRedisKey = exp672Param.getOrDefault("cidActionRedisKey", redisCidActionKeyV1);
|
|
|
|
- String vidCidRedisKey = exp672Param.getOrDefault("vidCidActionRedisKey", redisCidVidActionKeyV1);
|
|
|
|
|
|
+ String cidRedisKey = exp672Param.getOrDefault("cidActionRedisKey", redisCreativeStatisticsPrefix);
|
|
|
|
+ String vidCidRedisKey = exp672Param.getOrDefault("vidCidActionRedisKey", redisVideoCreativeStatisticsPrefix);
|
|
double viewThreshold = Double.parseDouble(exp672Param.getOrDefault("viewThreshold", "7000"));
|
|
double viewThreshold = Double.parseDouble(exp672Param.getOrDefault("viewThreshold", "7000"));
|
|
|
|
|
|
|
|
+ // RedisKey前缀判断
|
|
|
|
+ if (!StringUtils.equals(redisCidActionKeyV1, cidRedisKey) && !StringUtils.equals(redisCreativeStatisticsPrefix, cidRedisKey)) {
|
|
|
|
+ cidRedisKey = redisCreativeStatisticsPrefix;
|
|
|
|
+ }
|
|
|
|
+ if (!StringUtils.equals(redisCidVidActionKeyV1, vidCidRedisKey) && !StringUtils.equals(redisVideoCreativeStatisticsPrefix, vidCidRedisKey)) {
|
|
|
|
+ vidCidRedisKey = redisVideoCreativeStatisticsPrefix;
|
|
|
|
+ }
|
|
|
|
|
|
Map<Long, CreativeStatistic> paramCidRedisCache = this.batchFindCreativeRedisCache(cidRedisKey, adIdList);
|
|
Map<Long, CreativeStatistic> paramCidRedisCache = this.batchFindCreativeRedisCache(cidRedisKey, adIdList);
|
|
Map<Long, CreativeStatistic> paramVidCidRedisCache = this.batchFindCreativeRedisCache(vidCidRedisKey, adIdList);
|
|
Map<Long, CreativeStatistic> paramVidCidRedisCache = this.batchFindCreativeRedisCache(vidCidRedisKey, adIdList);
|
|
|
|
|
|
- // 兜底逻辑
|
|
|
|
- if (MapUtils.isEmpty(paramCidRedisCache) && MapUtils.isEmpty(paramVidCidRedisCache)) {
|
|
|
|
-
|
|
|
|
- Map<Long, CreativeStatistic> defaultCidCache = this.batchFindCreativeRedisCache(redisCidActionKeyV1, adIdList);
|
|
|
|
- Map<Long, CreativeStatistic> defaultVidCidCache = this.batchFindCreativeRedisCache(redisCidVidActionKeyV1, adIdList);
|
|
|
|
-
|
|
|
|
- for (AdPlatformCreativeDTO dto : adIdList) {
|
|
|
|
- Long cid = dto.getCreativeId();
|
|
|
|
- paramCidRedisCache.putIfAbsent(cid, defaultCidCache.getOrDefault(cid, new CreativeStatistic()));
|
|
|
|
- paramVidCidRedisCache.putIfAbsent(cid, defaultVidCidCache.getOrDefault(cid, new CreativeStatistic()));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
List<AdRankItem> result = new ArrayList<>(adIdList.size());
|
|
List<AdRankItem> result = new ArrayList<>(adIdList.size());
|
|
for (AdPlatformCreativeDTO dto : adIdList) {
|
|
for (AdPlatformCreativeDTO dto : adIdList) {
|
|
Map<String, Object> ext = new HashMap<>();
|
|
Map<String, Object> ext = new HashMap<>();
|
|
double score = 0.0;
|
|
double score = 0.0;
|
|
- double cpa = dto.getCpa();
|
|
|
|
|
|
+ double cpa = 0.0;
|
|
Long cid = dto.getCreativeId();
|
|
Long cid = dto.getCreativeId();
|
|
try {
|
|
try {
|
|
String pairOrSingle = "pair";
|
|
String pairOrSingle = "pair";
|
|
CreativeStatistic vidCidStatistic = paramVidCidRedisCache.getOrDefault(cid, new CreativeStatistic());
|
|
CreativeStatistic vidCidStatistic = paramVidCidRedisCache.getOrDefault(cid, new CreativeStatistic());
|
|
CreativeStatistic cidStatistic = paramCidRedisCache.getOrDefault(cid, new CreativeStatistic());
|
|
CreativeStatistic cidStatistic = paramCidRedisCache.getOrDefault(cid, new CreativeStatistic());
|
|
|
|
|
|
|
|
+ if (paramVidCidRedisCache.containsKey(cid)) {
|
|
|
|
+ cpa = vidCidStatistic.parseCpaToDouble();
|
|
|
|
+ } else {
|
|
|
|
+ cpa = cidStatistic.parseCpaToDouble();
|
|
|
|
+ }
|
|
|
|
+
|
|
double order = vidCidStatistic.parseOrderToDouble();
|
|
double order = vidCidStatistic.parseOrderToDouble();
|
|
double exp = vidCidStatistic.parseExpToDouble();
|
|
double exp = vidCidStatistic.parseExpToDouble();
|
|
|
|
|
|
@@ -598,7 +596,7 @@ public class VideoAdThompsonScorerV2 {
|
|
exp = cidStatistic.parseExpToDouble();
|
|
exp = cidStatistic.parseExpToDouble();
|
|
}
|
|
}
|
|
|
|
|
|
- if (exp > 0 && order > 0 && cpa > 0) {
|
|
|
|
|
|
+ if (exp != 0) {
|
|
score = (order / exp) * cpa;
|
|
score = (order / exp) * cpa;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -611,7 +609,7 @@ public class VideoAdThompsonScorerV2 {
|
|
ext.put("cpa", cpa);
|
|
ext.put("cpa", cpa);
|
|
ext.put("abCode", 672);
|
|
ext.put("abCode", 672);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error("svc=666exp, error: ", e);
|
|
|
|
|
|
+ log.error("svc=672exp, error: ", e);
|
|
}
|
|
}
|
|
|
|
|
|
AdRankItem item = new AdRankItem();
|
|
AdRankItem item = new AdRankItem();
|