Ver código fonte

新增广告阈值pid控制

gufengshou1 1 ano atrás
pai
commit
8d6f9b4a62

+ 15 - 7
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/container/ThresholdModelContainer.java

@@ -30,7 +30,7 @@ public class ThresholdModelContainer {
     private double position;
 
     public static Map<String,ThresholdPredictModel> modelMap=new HashMap<>();
-    public static MergingDigest mergingDigest = new MergingDigest(1000);
+    public static Map<Integer,MergingDigest> mergingDigestMap=new HashMap<>();
 
     private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
     @PostConstruct
@@ -39,7 +39,11 @@ public class ThresholdModelContainer {
         beanMap.forEach((s,model)->{
             modelMap.put(model.getName(), model);
         });
-        mergingDigest.add(0);
+        //只关注重点app
+        mergingDigestMap.put(0, new MergingDigest(10000));
+        mergingDigestMap.put(4, new MergingDigest(10000));
+        mergingDigestMap.put(5, new MergingDigest(10000));
+        mergingDigestMap.put(21, new MergingDigest(10000));
         final Runnable task = new Runnable() {
             public void run() {
                 try {
@@ -60,17 +64,21 @@ public class ThresholdModelContainer {
         return modelMap.get("basic");
     }
 
-    public static void mergingDigestAddScore(Double score){
-        mergingDigest.add(score);
+    public static void mergingDigestAddScore(Integer appType,Double score){
+        mergingDigestMap.getOrDefault(appType,new MergingDigest(1)).add(score);
     }
 
-    public static double getThresholdByTDigest(Double sortPosition){
-        return mergingDigest.quantile(sortPosition);
+    public static double getThresholdByTDigest(Integer appType,Double sortPosition){
+        return  mergingDigestMap.getOrDefault(appType,new MergingDigest(1)).quantile(sortPosition);
     }
 
     public void printDigestThreshold(){
         try {
-            log.info("svc=printDigestThreshold modelName=modelV2 mergingDigestThreshold={}", ThresholdModelContainer.getThresholdByTDigest(position));
+            for(Map.Entry<Integer,MergingDigest> entry:mergingDigestMap.entrySet()){
+                log.info("svc=printDigestThreshold modelName=modelV2 appType={} mergingDigestThreshold={}"
+                        , entry.getKey(),entry.getValue().quantile(position));
+            }
+
         }catch (Exception e){
             e.printStackTrace();
         }

+ 1 - 1
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/model/threshold/ScoreV2ThresholdPredictModel.java

@@ -104,7 +104,7 @@ public class ScoreV2ThresholdPredictModel extends ThresholdPredictModel {
             adPredict = 2;
         }
         if(maxItem != null){
-            ThresholdModelContainer.mergingDigestAddScore(maxItem.getScore());
+            ThresholdModelContainer.mergingDigestAddScore(modelParam.getAppType(),maxItem.getScore());
             //删除多余打印
             maxItem.setItemFeature(null);
             maxItem.setLrSampleString(null);