Commit 6246cd5f authored by mxx's avatar mxx

,,,

parent 12aa1d92
package cn.com.duiba.nezha.compute.common.model.pacing;
public class BlackInfo {
Long advertId;
Long orientId;
public BlackInfo() {
}
public BlackInfo(Long advertId, Long orientId) {
this.advertId = advertId;
this.orientId = orientId;
}
public Long getAdvertId() {
return advertId;
}
public void setAdvertId(Long advertId) {
this.advertId = advertId;
}
public Long getOrientId() {
return orientId;
}
public void setOrientId(Long orientId) {
this.orientId = orientId;
}
}
package cn.com.duiba.nezha.compute.common.model.pacing;
public class OrientInfo {
Long advertId;
Long orientId;
boolean isManagered; //是否为托管配置
Integer chargeType; //计费方式
Long target; //目标成本
Long fee; //出价
Double cvr;
Double confidence; //置信度
Double bias; //偏差
public OrientInfo() {
}
public OrientInfo(Long advertId, Long orientId, boolean isManagered, Integer chargeType, Long target, Long fee, Double cvr, Double confidence, Double bias) {
this.advertId = advertId;
this.orientId = orientId;
this.isManagered = isManagered;
this.chargeType = chargeType;
this.target = target;
this.fee = fee;
this.cvr = cvr;
this.confidence = confidence;
this.bias = bias;
}
public Long getAdvertId() {
return advertId;
}
public void setAdvertId(Long advertId) {
this.advertId = advertId;
}
public Long getOrientId() {
return orientId;
}
public void setOrientId(Long orientId) {
this.orientId = orientId;
}
public boolean isManagered() {
return isManagered;
}
public void setManagered(boolean managered) {
isManagered = managered;
}
public Integer getChargeType() {
return chargeType;
}
public void setChargeType(Integer chargeType) {
this.chargeType = chargeType;
}
public Long getTarget() {
return target;
}
public void setTarget(Long target) {
this.target = target;
}
public Long getFee() {
return fee;
}
public void setFee(Long fee) {
this.fee = fee;
}
public Double getCvr() {
return cvr;
}
public void setCvr(Double cvr) {
this.cvr = cvr;
}
public Double getConfidence() {
return confidence;
}
public void setConfidence(Double confidence) {
this.confidence = confidence;
}
public Double getBias() {
return bias;
}
public void setBias(Double bias) {
this.bias = bias;
}
}
package cn.com.duiba.nezha.compute.common.model.pacing;
public class OrientResultInfo {
Long advertId;
Long orientId;
public OrientResultInfo() {
}
public OrientResultInfo(Long advertId, Long orientId) {
this.advertId = advertId;
this.orientId = orientId;
}
public Long getAdvertId() {
return advertId;
}
public void setAdvertId(Long advertId) {
this.advertId = advertId;
}
public Long getOrientId() {
return orientId;
}
public void setOrientId(Long orientId) {
this.orientId = orientId;
}
}
package cn.com.duiba.nezha.compute.common.model.pacing;
import java.util.*;
public class SlotRecommender {
public static List<OrientResultInfo> recommend(List<OrientInfo> orientlist, List<BlackInfo> blacklist) {
Set<List<Long>> OrientSet = new HashSet<List<Long>>();
for (OrientInfo orient:orientlist) {
boolean isManagered = orient.isManagered; //是否为托管配置
Integer chargeType = orient.chargeType; //计费方式
Long target = orient.target; //目标成本
Long fee = orient.fee; //出价
Double cvr = orient.cvr;
Double confidence = orient.confidence; //置信度
Double bias = orient.bias;
Random r=new Random();
Double x=r.nextDouble();
Double p_convert_cost=fee/cvr;
List<Long> OrientInfoList=new ArrayList<Long>();
OrientInfoList.add(orient.advertId);
OrientInfoList.add(orient.orientId);
//////////ocpc
if (isManagered && chargeType == 1) {
//剔除有发券的预估偏差较高定向
if (bias < 3 && confidence > 0) {
OrientSet.add(OrientInfoList);
// 无发券,使用行业-广告位或广告维度偏差<2,定向几率0.8 (这里的偏差=0,代表空值)
} else if (bias < 2 && bias != 0 && confidence == 0 && x>0.2) {
OrientSet.add(OrientInfoList);
//无发券,使用行业-广告位或广告维度偏差>2,定向几率0.2
}else if (bias >= 2 && bias != 0 && confidence == 0 && x>0.8) {
OrientSet.add(OrientInfoList);
//无发券,偏差为空,定向几率0.5
}else {
if (x>0.5) {OrientSet.add(OrientInfoList);}
}
}
////////cpc
else if (isManagered && chargeType == 0) {
if (confidence > 0 && p_convert_cost<2*target) {OrientSet.add(OrientInfoList);}
if (confidence == 0 && bias != 0 && p_convert_cost<0.8*target) {OrientSet.add(OrientInfoList);}
if (confidence == 0 && bias == 0 && p_convert_cost<0.7*target) {OrientSet.add(OrientInfoList);}
}
}
Set<List<Long>> BlackSet = new HashSet<List<Long>>();
for (BlackInfo black:blacklist){
List<Long> BlackInfoList=new ArrayList<Long>();
BlackInfoList.add(black.advertId);
BlackInfoList.add(black.orientId);
BlackSet.add(BlackInfoList);
}
//剔除黑名单
OrientSet.removeAll(BlackSet);
List<OrientResultInfo> orientResultList = new ArrayList<OrientResultInfo>();
for(List<Long> resultList:OrientSet){
OrientResultInfo orientResultInfo = new OrientResultInfo(resultList.get(0), resultList.get(1));
orientResultList.add(orientResultInfo);
}
return orientResultList;
}
}
package blackwhitenamelist;
import java.util.*;
public class SlotFeedBack {
public static Map<String,String> slotFeedBack(List<SlotFeedBackInfo> infoList) {
Map<String,String> blackMap=new HashMap<String, String>();
for (int i = 0; i < infoList.size(); i++) {
//System.out.println(infoList.get(i));
SlotFeedBackInfo SlotFeedBackInfo = infoList.get(i);
String slotId = SlotFeedBackInfo.slotId;
String advertId = SlotFeedBackInfo.advertId;
String orientationId = SlotFeedBackInfo.orientationId;
String type = SlotFeedBackInfo.type;
; //type=hour:表示小时数据, day :表示1天粒度的指标数据
Long cost = SlotFeedBackInfo.cost; //托管配置消耗
Long convert = SlotFeedBackInfo.convert; //托管配置转化量
Float targetCostConvert = SlotFeedBackInfo.targetCostConvert; //目标成本
Float CostConvert = (float) cost / convert; //实时成本
String blackKey = "NZ_K77_" + SlotFeedBackInfo.slotId + "_" + SlotFeedBackInfo.advertId + "_" + SlotFeedBackInfo.orientationId + "_" + SlotFeedBackInfo.targetCostConvert;
String value = "True";
//NZ_K77_slotId_advertId_orientationId_targetCostConvert
if (type.equals("day") && convert > 10 && CostConvert > 2 * targetCostConvert) {
blackMap.put(blackKey, value);
} else if (type.equals("day") && convert == 0 && cost > 10000L) {
blackMap.put(blackKey, value);
} else if (type.equals("hour") && convert>5 && CostConvert > 2.5 * targetCostConvert) {
blackMap.put(blackKey, value);
} else if (type.equals("hour") && convert == 0 && cost > 5000L) {
blackMap.put(blackKey, value);
}
}
return blackMap;
}
}
package blackwhitenamelist;
public class SlotFeedBackInfo {
String slotId;
String advertId;
String orientationId;
String type; //type=hour:表示小时数据, day :表示1天粒度的指标数据
Long cost; //托管配置消耗
Long convert; //托管配置转化量
Float targetCostConvert; //每个广告人工配置目标成本
public SlotFeedBackInfo() {
}
public SlotFeedBackInfo(String slotId, String advertId, String orientationId, String type, Long cost, Long convert, Float targetCostConvert) {
this.slotId = slotId;
this.advertId = advertId;
this.orientationId = orientationId;
this.type = type;
this.cost = cost;
this.convert = convert;
this.targetCostConvert = targetCostConvert;
}
public String getSlotId() {
return slotId;
}
public void setSlotId(String slotId) {
this.slotId = slotId;
}
public String getAdvertId() {
return advertId;
}
public void setAdvertId(String advertId) {
this.advertId = advertId;
}
public String getOrientationId() {
return orientationId;
}
public void setOrientationId(String orientationId) {
this.orientationId = orientationId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Long getCost() {
return cost;
}
public void setCost(Long cost) {
this.cost = cost;
}
public Long getConvert() {
return convert;
}
public void setConvert(Long convert) {
this.convert = convert;
}
public Float getTargetCostConvert() {
return targetCostConvert;
}
public void setTargetCostConvert(Float targetCostConvert) {
this.targetCostConvert = targetCostConvert;
}
}
......@@ -4,33 +4,50 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Test {
public static void main(String[] args) {
CostConvertInfo costConvertInfo1= new CostConvertInfo(
"44474", "8675", "7403", "0", "31320",
"hour", "2",0, 1020L, 0L,
37L,69.37984F
// CostConvertInfo costConvertInfo1= new CostConvertInfo(
// "44474", "8675", "7403", "0", "31320",
// "hour", "2",0, 1020L, 0L,
// 37L,69.37984F
// );
//
// CostConvertInfo costConvertInfo2= new CostConvertInfo(
// "11111", "22222", "5255", "27192", "30886",
// "day", "2",1, 2680L, 0L,
// 88888L,1677.3059F
// );
//
//
// List infoList = new ArrayList();
// infoList.add(costConvertInfo1);
// infoList.add(costConvertInfo2);
SlotFeedBackInfo SlotFeedBackInfo1= new SlotFeedBackInfo(
"111","222","333","day",34678L,12L,30F
);
CostConvertInfo costConvertInfo2= new CostConvertInfo(
"11111", "22222", "5255", "27192", "30886",
"day", "2",1, 2680L, 0L,
88888L,1677.3059F
SlotFeedBackInfo SlotFeedBackInfo2= new SlotFeedBackInfo(
"666","888","999","day",34678L,100L,200F
);
SlotFeedBackInfo SlotFeedBackInfo3= new SlotFeedBackInfo(
"11","22","33","hour",99999L,0L,200F
);
List infoList = new ArrayList();
infoList.add(costConvertInfo1);
infoList.add(costConvertInfo2);
// infoList.add(costConvertInfo3);
// infoList.add(costConvertInfo4);
// infoList.add(costConvertInfo5);
List infoList = new ArrayList();
infoList.add(SlotFeedBackInfo1);
infoList.add(SlotFeedBackInfo2);
infoList.add(SlotFeedBackInfo3);
Map<String,String> label=BlackWhiteNameListRule.whiteBlackNameListRule(infoList);
Map<String,String> label=SlotFeedBack.slotFeedBack(infoList);
System.out.println(label);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment