示例#1
0
 /**
  * Modify the current search temperature (defaults to 1.0). Higher temperatures increase the
  * likelihood of a bad (i.e. high MML cost) model being accepted.
  */
 public void setTemperature(double temperature) {
   if (fixedTemperature) {
     throw new RuntimeException("Temperature value unchangable");
   }
   this.temperature = temperature;
   caseInfo.temperature = temperature;
   updateMutationOperators(arcProb, temperature);
 }
示例#2
0
 /**
  * Modify the current arc probability. This effects structureCost and the TOM mutation operators
  * (skeletalChange, temporalChange, doubleSkeletalChange, parentSwapChange)
  */
 public void setArcProb(double arcProb) {
   if (fixedArcProb) {
     throw new RuntimeException("ArcProb value unchangable");
   }
   this.arcProb = arcProb;
   caseInfo.arcProb = arcProb;
   updateMutationOperators(arcProb, temperature);
 }
示例#3
0
  /** Create new Mutation operators */
  protected void updateMutationOperators(double arcProb, double temperature) {
    skeletalChange = new SkeletalChange(rand, arcProb, caseInfo, temperature);
    temporalChange = new TemporalChange(rand, arcProb, caseInfo, temperature);
    doubleSkeletalChange = new DoubleSkeletalChange(rand, arcProb, caseInfo, temperature);
    parentSwapChange = new ParentSwapChange(rand, arcProb, caseInfo, temperature);
    // tomCoster = new TOMCoster.UniformTOMCoster( arcProb, caseInfo );
    tomCoster.setArcProb(arcProb);

    caseInfo.tomCoster = tomCoster;
  }
示例#4
0
 /** Setter for TOMCoster. */
 public void setTOMCoster(TOMCoster tc) {
   this.tomCoster = tc;
   caseInfo.tomCoster = tomCoster;
 }
示例#5
0
  /**
   * Set an option by name to a given value. Some options are search specific. <br>
   * Return false if option name is unknown
   *
   * <p>General options include: <br>
   * <b>arcProb</b> -- Fix the probability of arc existance at a value <br>
   * <b>temperature</b> -- Fix temperature at a set value <br>
   * <b>currentTOM</b> -- Set initial TOM to a given value <br>
   * <b>clean</b> -- Should model cleaning be used? <br>
   * <b>searchFactor</b>-- Multiplier to search/sample time. Default is 1.0. <br>
   *
   * <p>Metropolis only options <br>
   * <b>joinDAGs</b> -- Join DAGs to form SECs. (default == true)<br>
   * <b>joinSECs</b> -- Join SECs to form MMLECs. (defalut == true) <br>
   * <b>allowMergeToModelWithMoreArcs</b> -- When joining SECs to MMLECs, allow the representative
   * SEC to have more arcs than SEC it is being joined too. (default == false) <br>
   * <b>sortTOMsBy</b> -- "weight"|"mml", What metric should we use to rank TOMs within a SEC?
   * Default == "weight" <br>
   * <b>regression</b> -- Sets options to the values used in oldCamml. Also makes an attempt to
   * ensure random number generators line up, etc. Only useful for regressiont testing. <br>
   * <b>TOMPrior</b> -- Use expert ellicited prior over network. String passed as option reflects
   * the prior specified. For details see {@link ExpertElicitedTOMCoster} <b>maxNumSECs</b> --
   * Maximum number of SECs retained post metropolis sampling. <b>minTotalPosterior</b> -- Minimal
   * posterior retained post metropolis sampling. If more than 'maxSECs' SECs are required, this
   * condition is ignored. <b>useNetica</b> -- Return BNetNetica instead of BNetStochastic models.
   */
  public boolean setOption(final String option, Value v) {
    if (option.equals("arcProb")) {
      setArcProb(((Value.Scalar) v).getContinuous());
      fixedArcProb = true;
      System.out.println("Setting arcProb = " + v);
    } else if (option.equals("temperature")) {
      setTemperature(((Value.Scalar) v).getContinuous());
      fixedTemperature = true;
      System.out.println("Setting temperature = " + v);
    } else if (option.equals("currentTOM")) {
      setTOMStructure(tom, (Value.Vector) v);
    } else if (option.equals("clean")) {
      boolean clean = (((Value.Discrete) v).getDiscrete() == 0);
      if (clean == false) {
        caseInfo.tomCleaner = TOMCleaner.NoCleanTOMCleaner.tomCleaner;
      }
      System.out.println("Setting arc cleaning: " + clean);
    } else if (option.equals("joinDAGs")) {
      caseInfo.joinDAGs = (((Value.Discrete) v).getDiscrete() == 0);
      System.out.println("Joining DAGs to form SECs: " + caseInfo.joinDAGs);
    } else if (option.equals("joinSECs")) {
      caseInfo.joinSECs = (((Value.Discrete) v).getDiscrete() == 0);
      System.out.println("Joining SECs by KL distance: " + caseInfo.joinSECs);
    } else if (option.equals("allowMergeToModelWithMoreArcs")) {
      caseInfo.allowMergeToModelWithMoreArcs = (((Value.Discrete) v).getDiscrete() == 0);
      System.out.println(
          "Allow merge to model with more arcs: " + caseInfo.allowMergeToModelWithMoreArcs);
    } else if (option.equals("sortTOMSBy")) {
      String s = ((Value.Str) v).getString();
      if (s.equals("weight")) {
        caseInfo.tomComparator = SEC.tomWeightComparator;
      } else if (s.equals("MML")) {
        caseInfo.tomComparator = SEC.tomMMLComparator;
      } else {
        s = "Unknown option.  Ignoring";
      }

      System.out.println("Sorting TOMs by : " + s);
    } else if (option.equals("regression")) {
      caseInfo.regression = (((Value.Discrete) v).getDiscrete() == 0);
      System.out.println("Setting regression: " + caseInfo.regression);
    } else if (option.equals("TOMCoster")) {
      setTOMCoster((TOMCoster) ((Value.Obj) v).getObj());
      System.out.println("Setting TOMCoster: " + tomCoster);
    } else if (option.equals("TOMPrior")) {
      String x = ((Value.Str) v).getString();
      setTOMCoster(new ExpertElicitedTOMCoster(arcProb, new StringReader(x), tom.data));
      System.out.println("Setting TOMCoster: " + tomCoster);
    } else if (option.equals("searchFactor")) {
      double d = ((Value.Scalar) v).getContinuous();
      caseInfo.searchFactor = d;
    } else if (option.equals("maxNumSECs")) {
      int x = ((Value.Scalar) v).getDiscrete();
      caseInfo.maxNumSECs = x;
    } else if (option.equals("minTotalPosterior")) {
      double d = ((Value.Scalar) v).getContinuous();
      caseInfo.minTotalPosterior = d;
    } else if (option.equals("useNetica")) {
      caseInfo.useNetica = (((Value.Discrete) v).getDiscrete() == 0);
      if (caseInfo.useNetica) {
        caseInfo.bNet = new BNetNetica(caseInfo.bNet.getDataType());
      } else {
        caseInfo.bNet = new BNetStochastic(caseInfo.bNet.getDataType());
      }
      System.out.println("Using netica lib for inference: " + caseInfo.useNetica);
    } else if (option.equals("printArcWeights")) {
      caseInfo.printArcWeights = (((Value.Discrete) v).getDiscrete() != 0);
      caseInfo.updateArcWeights = caseInfo.printArcWeights;
      System.out.println("Printing Arc Weights: " + caseInfo.useNetica);
    } else if (option.equals("cklJoinType")) {
      caseInfo.cklJoinType = ((Value.Discrete) v).getDiscrete();
      if (caseInfo.cklJoinType != 0 && caseInfo.cklJoinType != 3) {
        throw new RuntimeException("Unknown join type. Should be 0 or 3");
      }
      System.out.println("Setting Model join type to CKL" + caseInfo.cklJoinType);
      // caseInfo.joinDAGs = false;
      // System.out.println( "Joining DAGs to form SECs: " + caseInfo.joinDAGs );

    } else { // return false if an invalid option is passed.
      return false;
    }
    return true;
  }