|
@@ -99,7 +99,7 @@ public class PidLambdaV2Container {
|
|
|
Double yesterdayConv=0d;
|
|
|
Double yesterdayCpa=0d;
|
|
|
Double yesterdayRealCost=0d;
|
|
|
- Double latestRealCPA=0d;
|
|
|
+
|
|
|
while ((line = bufferedReader.readLine()) != null){
|
|
|
try {
|
|
|
String[] cols=line.split(",");
|
|
@@ -123,19 +123,9 @@ public class PidLambdaV2Container {
|
|
|
lambdaNew=(yesterdayConv*yesterdayCpa)/yesterdayRealCost;
|
|
|
}
|
|
|
}
|
|
|
- if(conversion!=0){
|
|
|
- latestRealCPA=realCost/conversion;
|
|
|
- if(cacheItem.latestRealCpa==0d){
|
|
|
- cacheItem.latestRealCpa=cpa;
|
|
|
- }
|
|
|
- if(Math.abs(latestRealCPA-cpa)-Math.abs(cacheItem.latestRealCpa-cpa)>0){
|
|
|
- cacheItem.pow=2d;
|
|
|
- }else {
|
|
|
- cacheItem.pow=1.2;
|
|
|
- }
|
|
|
- lambdaNew=Math.pow(lambdaNew,cacheItem.pow);
|
|
|
- cacheItem.latestRealCpa=latestRealCPA;
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+ lambdaNew=cacheItem.calculate( conversion, realCost, cpa,lambdaNew) ;
|
|
|
|
|
|
|
|
|
if(lambdaNew>maxLambda){
|
|
@@ -214,6 +204,24 @@ public class PidLambdaV2Container {
|
|
|
this.creativeId=creativeId;
|
|
|
}
|
|
|
|
|
|
+ public double calculate(double conversion, double realCost, double cpa,double lambdaNew ) {
|
|
|
+ if(conversion!=0){
|
|
|
+ double latestRealCPA=realCost/conversion;
|
|
|
+
|
|
|
+ if(this.latestRealCpa==0d){
|
|
|
+ this.latestRealCpa=cpa;
|
|
|
+ }
|
|
|
+ if(Math.abs(latestRealCPA-cpa)-Math.abs(this.latestRealCpa-cpa)>0){
|
|
|
+ this.pow=2d;
|
|
|
+ }else {
|
|
|
+ this.pow=1.2;
|
|
|
+ }
|
|
|
+ this.latestRealCpa=latestRealCPA;
|
|
|
+ return Math.pow(lambdaNew,this.pow);
|
|
|
+ }
|
|
|
+ return lambdaNew;
|
|
|
+ }
|
|
|
+
|
|
|
public Long creativeId;
|
|
|
|
|
|
public double lambda=1d;
|