Showing
1 changed file
with
19 additions
and
9 deletions
@@ -384,9 +384,10 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ | @@ -384,9 +384,10 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ | ||
384 | int startSpecial = Integer.valueOf(specialStrategy[0]);//起始点(0,startSpecial) | 384 | int startSpecial = Integer.valueOf(specialStrategy[0]);//起始点(0,startSpecial) |
385 | int endSpecial = Integer.valueOf(specialStrategy[1]);//终结(timeConfig,endSpecial) | 385 | int endSpecial = Integer.valueOf(specialStrategy[1]);//终结(timeConfig,endSpecial) |
386 | //两个坐标点 --线性函数 y=kx + b | 386 | //两个坐标点 --线性函数 y=kx + b |
387 | - double k = ((end - start)*1d) / (timeConfig * 1d); | 387 | +// double k = ((end - start)*1d) / (timeConfig * 1d); |
388 | + double k = timeConfig; | ||
388 | double b = start; | 389 | double b = start; |
389 | - double kSpecial = ((endSpecial - startSpecial)*1d) / (timeConfig * 1d); | 390 | + double kSpecial = timeConfig; |
390 | double bSpecial = startSpecial; | 391 | double bSpecial = startSpecial; |
391 | 392 | ||
392 | //3)基础数据--原有的点赞(正常的点赞--排除; 取消的点赞--不要发站内信) | 393 | //3)基础数据--原有的点赞(正常的点赞--排除; 取消的点赞--不要发站内信) |
@@ -428,9 +429,9 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ | @@ -428,9 +429,9 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ | ||
428 | } | 429 | } |
429 | Set<Integer> randomUidList; | 430 | Set<Integer> randomUidList; |
430 | if(authorType == GrassUserTypeEnum.COMMON.getValue() && specialAuthors.contains(authorUid)){//有货的用户,并且是重点用户,采用的线性函数有所不同 | 431 | if(authorType == GrassUserTypeEnum.COMMON.getValue() && specialAuthors.contains(authorUid)){//有货的用户,并且是重点用户,采用的线性函数有所不同 |
431 | - randomUidList = getPraiseUids(tempList, kSpecial, bSpecial, time); | 432 | + randomUidList = getPraiseUids(tempList, kSpecial, bSpecial, time, end); |
432 | }else{ | 433 | }else{ |
433 | - randomUidList = getPraiseUids(tempList, k, b, time); | 434 | + randomUidList = getPraiseUids(tempList, k, b, time, end); |
434 | } | 435 | } |
435 | if(CollectionUtils.isEmpty(randomUidList)){ | 436 | if(CollectionUtils.isEmpty(randomUidList)){ |
436 | article.setPraiseCount(0);//新增加的点赞数是0 | 437 | article.setPraiseCount(0);//新增加的点赞数是0 |
@@ -482,20 +483,25 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ | @@ -482,20 +483,25 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ | ||
482 | 483 | ||
483 | //随着时间的推移,增加的点赞数 逐步减少--》y= kx + b | 484 | //随着时间的推移,增加的点赞数 逐步减少--》y= kx + b |
484 | //x 是距离当前的时间(分钟为单位,比小时更精确) | 485 | //x 是距离当前的时间(分钟为单位,比小时更精确) |
485 | - private Set<Integer> getPraiseUids(List<Integer> virtualList,double k,double b, double x ) { | 486 | + private Set<Integer> getPraiseUids(List<Integer> virtualList,double timeConfig,double start, double x , int end ) { |
486 | if(virtualList.isEmpty()){//没有可选的马甲粉丝 | 487 | if(virtualList.isEmpty()){//没有可选的马甲粉丝 |
487 | return new HashSet<>(); | 488 | return new HashSet<>(); |
488 | } | 489 | } |
489 | //数量--随着时间的推移,线性的 | 490 | //数量--随着时间的推移,线性的 |
490 | - double numDouble = k * x + b + new Random().nextInt(5); | ||
491 | - int num = new Double(numDouble).intValue();//需要增加的点 | 491 | +// double numDouble = k * x + b + new Random().nextInt(5); |
492 | + //使用对数函数模型 | ||
493 | + double numDouble= new Random().nextInt((int)start-end) + start ; | ||
494 | + double m = log(x/timeConfig,1/timeConfig) * numDouble ; | ||
495 | + double num = Math.ceil(m) > end ? Math.ceil(m) : end; | ||
496 | + | ||
497 | + int addnum = new Double(num).intValue();//需要增加的点 | ||
492 | int totalVitual = virtualList.size(); | 498 | int totalVitual = virtualList.size(); |
493 | Set<Integer> set = new HashSet<>(); | 499 | Set<Integer> set = new HashSet<>(); |
494 | - if(totalVitual <= num){ | 500 | + if(totalVitual <= addnum){ |
495 | set = virtualList.stream().collect(Collectors.toSet()); | 501 | set = virtualList.stream().collect(Collectors.toSet()); |
496 | return set; | 502 | return set; |
497 | } | 503 | } |
498 | - for(int i = 0 ; i < num; i++){ | 504 | + for(int i = 0 ; i < addnum; i++){ |
499 | int index = getRandom(0, virtualList.size() - 1); | 505 | int index = getRandom(0, virtualList.size() - 1); |
500 | Integer uid = virtualList.get(index);//随机得到的粉丝uid | 506 | Integer uid = virtualList.get(index);//随机得到的粉丝uid |
501 | virtualList.remove(uid); | 507 | virtualList.remove(uid); |
@@ -504,6 +510,10 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ | @@ -504,6 +510,10 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ | ||
504 | return set; | 510 | return set; |
505 | } | 511 | } |
506 | 512 | ||
513 | + private double log(double value, double base) { | ||
514 | + return Math.log(value) / Math.log(base); | ||
515 | + } | ||
516 | + | ||
507 | private void sendAddPariseMessage(List<GrassArticlePraise> pariseDetail) { | 517 | private void sendAddPariseMessage(List<GrassArticlePraise> pariseDetail) { |
508 | if(CollectionUtils.isEmpty(pariseDetail)){ | 518 | if(CollectionUtils.isEmpty(pariseDetail)){ |
509 | return; | 519 | return; |
-
Please register or login to post a comment