📄 cycleinfohandler.java
字号:
/**
* Description: provide the capability for handling historical best state
*
* @ Author Create/Modi Note
* Xiaofeng Xie Jul 19, 2006
*/
package maosKernel.infoIO;
import maosKernel.represent.*;
public class CycleInfoHandler implements IBestCycleInfoEngine {
private int T_CON = Integer.MAX_VALUE;
private int t_con = 0;
private int bestNCycle = 0;
private int currentNCycle = 0;
private double bestTime = 0;
private double currentTime = 0;
private EncodedState bestState;
/**********************************************/
private AbsLandscape virtualLandscape;
public CycleInfoHandler(AbsLandscape virtualLandscape) {
bestState = new EncodedState(virtualLandscape);
this.virtualLandscape = virtualLandscape;
}
public void setCycleLimit(int T_CON) {
this.T_CON = T_CON;
}
public void initCycle(EncodedState bestState, double currentTime) {
this.bestState.importEncodeState(bestState);
this.bestNCycle = 0;
this.currentNCycle = 0;
this.bestTime = currentTime;
this.currentTime = currentTime;
t_con = 0;
}
public boolean checkCycle(EncodedState state, int currentNCycle, double currentTime) {
this.currentNCycle = currentNCycle;
this.currentTime = currentTime;
if (!virtualLandscape.evaluate(bestState, state)) {
t_con = 0;
bestState.importEncodeState(state);
bestNCycle = currentNCycle;
bestTime = currentTime;
return true;
} else {
t_con++;
return false;
}
}
public boolean isAchievedCycleLimit() {
return t_con == T_CON;
}
public EncodedState getBestState() {
return bestState;
}
public String getEncodeInfo() {
return bestState.writeEncodeInfo();
}
public double getBestTime() {
return bestTime;
}
public int getBestNCycle() {
return bestNCycle;
}
public String getCycleInfo() {
return currentNCycle + " \t" + getEncodeInfo() + " \t\t" + currentTime;
}
public String getBestCycleInfo() {
return "cost=" + getEncodeInfo() + " at cycle=" + bestNCycle +" & calcTime=" + bestTime +"(s)";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -