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

📄 basicparamholder.java

📁 pso源程序
💻 JAVA
字号:
/** * Description: Holds the parameters. * * @ Author        Create/Modi     Note * Xiaofeng Xie    Apr 28, 2006 * Xiaofeng Xie    Apr 28, 2006    MAOS-TSP Beta 1.1.002 * */package maosKernel.infoIO.setting;import Global.define.*;import Global.methods.*;import Global.system.io.*;import Global.system.*;import Global.basic.nodes.*;public class BasicParamHolder {  public ProjectIOPath prjIOPath = new ProjectIOPath();  private ProblemSettings problemSettings = new ProblemSettings();  private SwarmSettings swarmSettings;  public BasicParamHolder() {    prjIOPath.initUtilities();    setSwarmSettings(new SwarmSettings());  }  public void setSwarmSettings(SwarmSettings swarmSettings) {    this.swarmSettings = swarmSettings;    swarmSettings.initUtilities();  }  public ProblemSettings getProblemSettings() {    return this.problemSettings;  }  public SwarmSettings getSwarmSettings() {    return swarmSettings;  }  public void loadDefaultFiles(String problemType) throws Exception {    loadDefaultFile(prjIOPath, problemType, SystemSettingPath.DefaultPrjIOFile);    loadDefaultFile(swarmSettings, problemType, SystemSettingPath.DefaultSwarmFile);  }  private void loadDefaultFile(UtilSetNode utilSetNode, String problemType, String fileName) throws Exception {    String basicSettingFile = SystemSettingPath.RootSettingPath+BasicTag.FILE_SEP_TAG+fileName;    readDefaultSettingFile(utilSetNode, basicSettingFile);    String specSettingFile = SystemSettingPath.getSpecSettingPath(problemType)+BasicTag.FILE_SEP_TAG+fileName;    readDefaultSettingFile(utilSetNode, specSettingFile);    utilSetNode.shortcutInit();  }  private void readDefaultSettingFile(UtilSetNode utilSetNode, String fileName) {    try {      String content = GlobalFile.getStringFromFile(fileName);      String[] lines = GlobalString.getMeaningfulLines(content);      parserInputs(utilSetNode, lines, false);    }    catch (Exception e) {      System.out.println("*INFO: "+e.getMessage());    }  }  public String getResultFileDir(String problemType) {    String str = problemType/*+ prjIOPath.ResLABEL*/ + "_"+swarmSettings.getBasicResultDir()+"_"+GlobalFile.extractFileName(System.getProperty("user.dir"));    return GlobalFile.getFileLocation(prjIOPath.ResHOME, str);  }  public String getResultFileName() {    return problemSettings.getSummary()+"_"+OSRelativedMethods.getFirstHostName()+"_"+System.currentTimeMillis()+".log";  }  public void parseSwarmSettings(String[] args) throws Exception {    parserInputs(swarmSettings, args, true);    swarmSettings.shortcutInit();  }  /**   * Support the commoand line inputs, format at follows: Name=value   */  private void parserInputs(UtilSetNode utilSetNode, String[] args, boolean isPrint) {    if(args.length>0) {      for(int i=0; i<args.length; i++) {        if (isPrint) System.out.println("Reading: "+args[i]);        String[] vals = GlobalString.tokenize(args[i], BasicTag.EQUAL_TAG);        if(vals.length == 2) {          try {            if (!utilSetNode.setValue(vals[0], vals[1])) {              if(isPrint) System.out.println("*WARN: No such parameter: "+vals[0]);            }          } catch (Exception e) {            if(isPrint)System.out.println(" *WARN: "+e.getMessage()+", use default value");          }        } else {          if(isPrint) System.out.println(" *WARN: not a valid parameter");        }      }    }  }}

⌨️ 快捷键说明

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