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

📄 controllerconfiguration.java

📁 Boosting算法软件包
💻 JAVA
字号:
/* * Created on Jan 6, 2004 * * To change the template for this generated file go to * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments */package jboost.controller;import java.io.*;import jboost.examples.ExampleSet;import jboost.monitor.Monitor;/** * The ControllerConfiguration holds all the configurable data used by the  * Controller, Monitor, and anything else that needs to get access to it. * Using this configuration object allows us to reduce the exposure of the * Controller to other classes that may need to share data with it. *  * The data that this class maintains are: * <li> specFileName * <li> trainFileName * <li> testFileName * <li> resultOutputFileName * <li> C output FileName * <li> Java output FileName * <li> matlab output FileName * <li> serialized Output file name * <li> trainSet * <li> testSet *  *  * @author cschavis */public class ControllerConfiguration extends Configuration {  // These are the option keywords used for this Configuration  public static final String SPEC_FILENAME="specFileName";  public static final String TRAIN_FILENAME="trainFileName";  public static final String TEST_FILENAME="testFileName";  public static final String RESULTOUTPUT_FILENAME="resultOutputFileName";  public static final String C_OUTPUT_FILENAME="cCodeOutputFileName";  public static final String JAVA_OUTPUT_FILENAME="javaCodeOutputFileName";  public static final String MATLAB_OUTPUT_FILENAME="matlabCodeOutputFileName";  public static final String SERIALIZED_OUTPUT_FILENAME="serializationOutputFileName";  public static final String SERIALIZED_INPUT="serialTreeInput";  public static final String SAMPLE_TRAINING_DATA="controller.sampling";  public static final String SAMPLE_THRESHOLD_WEIGHT="controller.threshold.weight";  public static final String N_THREADS="nthreads";  public static final String BOOSTER_RUNTIME="boostingRuntime";  public static final String BOOSTER_TYPE="booster_type";  public static final String JBOOST_VERSION="version";  public static final String YABA_C1="c1";  public static final String YABA_C2="c2";  public static final String YABA_THETA="theta";  public static final String YABA_POS_C="pos_r";  public static final String YABA_POS_C1="pos_c1";  public static final String YABA_POS_C2="pos_c2";  public static final String YABA_POS_THETA="pos_theta";  public static final String YABA_NEG_C="neg_r";  public static final String YABA_NEG_C1="neg_c1";  public static final String YABA_NEG_C2="neg_c2";  public static final String YABA_NEG_THETA="neg_theta";  public static final String BROWN_BOOST_POTENTIAL="brownBoostPotential";    public static final String DEFAULT_BOOSTER = "AdaBoost";    // private data elements that are not stored in the Configuration vector  private ExampleSet trainSet;  private ExampleSet testSet;  /**   * Configure the specific entries that we need for the Controller   */  public ControllerConfiguration(String manpage, String[] argv) throws        BadCommandException, IOException {        super(manpage, argv);    String stem= getString("S", "default");    addOption(SPEC_FILENAME, getString("n", stem + ".spec"));    addOption(TRAIN_FILENAME, getString("t", stem + ".train"));    addOption(TEST_FILENAME, getString("T", stem + ".test"));    addOption(RESULTOUTPUT_FILENAME, getString("O", stem + ".output.tree"));    addOption(C_OUTPUT_FILENAME, getString("c", null));    addOption(JAVA_OUTPUT_FILENAME, getString("j", null));    addOption(MATLAB_OUTPUT_FILENAME, getString("m", null));    addOption(SERIALIZED_OUTPUT_FILENAME, getString("serialTreeOutput", null));    addOption(SERIALIZED_INPUT, getString("serialTreeInput", null));    addOption(N_THREADS, getString("p", null));    addOption(BOOSTER_RUNTIME, getString("r", "1.0"));    addOption(BOOSTER_TYPE, "jboost.booster." + getString("b", DEFAULT_BOOSTER));    addOption(JBOOST_VERSION, getString("V", null));    addOption(YABA_C1, getString("c1", null));    addOption(YABA_C2, getString("c2", null));    addOption(YABA_THETA, getString("theta", null));    addOption(YABA_POS_C,"pos_r");    addOption(YABA_POS_C1,"pos_c1");    addOption(YABA_POS_C2,"pos_c2");    addOption(YABA_POS_THETA,"pos_theta");    addOption(YABA_NEG_C,"neg_r");    addOption(YABA_NEG_C1,"neg_c1");    addOption(YABA_NEG_C2,"neg_c2");    addOption(YABA_NEG_THETA,"neg_theta");    addOption(BROWN_BOOST_POTENTIAL, getString("potential", null));  }      /**   * Check the values of all the parameters, e.g. make sure that    * the filenames for the input files exist.   * @return    */  protected boolean checkCommandValues() throws BadCommandException {	  	// check the input files	try {	  if(getPrintVersion()){		  System.out.println("JBoost version " + VERSION);		  System.exit(0);	  }	  String specname = getSpecFileName();	  String testname = getTestFileName();	  String trainname = getTrainFileName();	  Monitor.log("Spec: " + specname + ", Test: " + testname + ", Train: " + trainname);	  if(specname == null || testname == null || trainname == null){		  throw new BadCommandException("ERROR: Have not assigned all (spec,train,test) input file names yet!");	  }	  File specfile = new File(specname);	  File testfile = new File(testname);	  File trainfile = new File(trainname);	  if (! (specfile.exists() && testfile.exists() && trainfile.exists()) ) {		throw new BadCommandException("ERROR: Input file names (spec,train,test) do not exist!");	  }	  	} catch(Exception e) {	  System.err.println("ERROR: Input files do not exist or are unreadable for other reasons!");	  throw new BadCommandException(e.getMessage());	}	  	// Check the results output file parameters	try {	  String fname = getResultOutputFileName();	  if(fname == null){		throw new BadCommandException("ERROR: Have not assigned output file name yet!");	  }	} catch(Exception e) {	  System.err.println("ERROR: File either does not exist or is unreadable for other reasons!");	  throw new BadCommandException(e.getMessage());	}		return true;  }      /**   * @return Returns the resultOutputFileName.   */  public String getResultOutputFileName() {    return getString(RESULTOUTPUT_FILENAME);  }  /**   * @return Returns the specFileName.   */  public String getSpecFileName() {    return getString(SPEC_FILENAME);  }  /**   * @return Returns the testFileName.   */  public String getTestFileName() {    return getString(TEST_FILENAME);  }  /**   * @param the test set   */  public void setTestSet(ExampleSet set) {    testSet= set;  }    /**   * @return Returns the testSet.   */  public ExampleSet getTestSet() {    return testSet;  }  /**   * @return Returns the trainFileName.   */  public String getTrainFileName() {    return getString(TRAIN_FILENAME);  }  /**   * @param the training set   */  public void setTrainSet(ExampleSet set) {    trainSet= set;  }    /**   * @return Returns the trainSet.   */  public ExampleSet getTrainSet() {    return trainSet;  }    /**   * @return Returns the name of the C output file   */  public String getCoutputFileName() {    return getString(C_OUTPUT_FILENAME);    }    /**   * @return Returns the name of the Java output file   */  public String getJavaOutputFileName() {    return getString(JAVA_OUTPUT_FILENAME);  }    /**   * @return Returns the name of the Matlab output file   */  public String getMatlabOutputFileName() {     return getString(MATLAB_OUTPUT_FILENAME);  }    /**   * @return Returns the name of the serialized output file   */  public String getSerializationOutputFileName() {    return getString(SERIALIZED_OUTPUT_FILENAME);  }    /**   * @return Returns the name of the serialized input file   */  public String getSerializationInputFileName() {    return getString(SERIALIZED_INPUT);  }    /**   * @return Returns the specified number of threads   */  public String getNThreads() {    return getString(N_THREADS);  }    /**   * @return the runtime of the boosting algorithm    * (for adaptive versions of BBM)   */  public double getRuntime() {	String runStr = getString(BOOSTER_RUNTIME);	if (runStr == null) {		return 0;	}	return Double.parseDouble(runStr);  }    /**   * @return should we print the version?   */  public boolean getPrintVersion() {	String str = getString(JBOOST_VERSION);	if (str == null) {		return false;	}	return true;  }  /**   * @return should we print potential and exit?   */  public boolean getPrintPotential() {	String str = getString(BROWN_BOOST_POTENTIAL);	if (str == null) {		return false;	}	return true;  }}

⌨️ 快捷键说明

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