⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 solutionoutputhandler.java

📁 用于求解TSP(Traveling salesman problem
💻 JAVA
字号:
/**
 * Description: provide the capability for handling historical best state
 *
 * @ Author        Create/Modi     Note
 * Xiaofeng Xie    Jul 19, 2006
 */

package maosKernel.infoIO;

import java.io.*;
import Global.system.io.*;
import Global.define.*;

public class SolutionOutputHandler {
  private RandomAccessFile onlineResultFile = null;

  public SolutionOutputHandler(String tempResultDir, String resultFileName) throws Exception {
    new File(tempResultDir).mkdirs();
    String outfileName = GlobalFile.getFileLocation(tempResultDir, resultFileName);
    onlineResultFile = new RandomAccessFile(outfileName, "rw");
    System.out.println("@Output file: "+outfileName);
  }

  public void writeBytes(String message) throws Exception {
    onlineResultFile.writeBytes(message);
  }

  public void writeHead() throws Exception {
    onlineResultFile.writeBytes(this.getResultHeadString());
  }

  public void writeInitInfo(IBestCycleInfoEngine bestCycleInfoEngine) throws Exception {
    onlineResultFile.writeBytes(bestCycleInfoEngine.getBestState().writeEncodeInfo()+BasicTag.NULL_SEPERATE_TAG + bestCycleInfoEngine.getBestTime()+BasicTag.NULL_SEPERATE_TAG);
  }

  public void writeLastInfo(IBestCycleInfoEngine bestCycleInfoEngine) throws Exception {
    onlineResultFile.writeBytes(bestCycleInfoEngine.getBestState().writeEncodeInfo()+BasicTag.NULL_SEPERATE_TAG + bestCycleInfoEngine.getBestNCycle()+BasicTag.NULL_SEPERATE_TAG+bestCycleInfoEngine.getBestTime()+BasicTag.RETURN_TAG);
  }

  private String getResultHeadString() {
    return "#"
      + "Eval0" + BasicTag.NULL_SEPERATE_TAG
      + "Time0" + BasicTag.NULL_SEPERATE_TAG
      + "EvalT" + BasicTag.NULL_SEPERATE_TAG
      + "Num_T" + BasicTag.NULL_SEPERATE_TAG
      + "TimeT" + BasicTag.NULL_SEPERATE_TAG
      + BasicTag.RETURN_TAG;
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -