关于物流的5种模型10种算法的实现
下面是关于预测的一个适配器:
package com.logis.game.adapter.foretell;
public class ForetellAdapter {
private IForeTell foretell;
private List<DataRow> data;
public double doWork(String willTime) {
for (DataRow dRow : data) {
if (isBlank(dRow.getValue(0)) || isBlank(dRow.getValue(1)))
data.remove(dRow);
}
foretell.setNum(data.size());
for (DataRow dRow : data) {
int time = getInt(dRow.getValue(0));
double d = getDouble(dRow.getValue(1));
foretell.setData(time, d);
}
if (!isBlank(willTime)) {
foretell.setWillTime(getInt(willTime));
return foretell.getForetellData();
}
return 0.0;
}
public String getExplainStr() {
return foretell.getExplainStr();
}
public boolean isBlank(String str) {
return str == null || "".equals(str);
}
public int getInt(String str) {
int result = 0;
try {
result = Integer.parseInt(str);
if (result < 0) {
result = 0; MyLogger.debug("把" + str + "修正为" + result);
}
} catch (Exception e) {
MyLogger.debug("转换为正数失败:" + str);
}
return result;
}
public double getDouble(String str) {
double result = 0.0;
try {
result = Double.parseDouble(str);
if (result < 0) {
result = 0;
MyLogger.debug("把" + str + "修正为" + result);
}
} catch (Exception e) {
MyLogger.debug("转换为正数失败:" + str);
}
return result;
}
public IForeTell getForetell() {
return foretell;
}
public void setForetell(IForeTell foretell) {
this.foretell = foretell;
}
public List<DataRow> getData() {
return data;
}
public void setData(List<DataRow> data) {
this.data = data;
}
}
欢迎大家讨论指正。
上一页 [1] [2] [3]

【责编:Ken】