Changeset 4323


Ignore:
Timestamp:
08/22/08 08:07:52 (12 years ago)
Author:
nor
Message:

Continued improvements to slim plotter curve fitting.

Location:
trunk/loci/slim
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/slim/BurnInRenderer.java

    r4302 r4323  
    105105          currentCurves[currentY][currentX].estimate(); 
    106106          //currentCurves[currentY][currentX].iterate(); 
     107          // This only really matters for the last subsampleLevel 
     108          if(subsampleLevel == 0) { 
     109            double newRCSE = currentCurves[currentY][currentX].getReducedChiSquaredError(); 
     110            rcsecache[currentY][currentX] = newRCSE; 
     111          } 
    107112          double[][] curve = currentCurves[currentY][currentX].getCurve(); 
    108113          double[] exponentials = new double[numExponentials]; 
     
    144149    } 
    145150    // initial pass - iterations 
     151    maxIterations = 1; // TEMP? 
    146152    while(alive && !improving) { 
    147153      if(!estimated) { 
     
    209215      totalIterations++; 
    210216      rcsecache[currentY][currentX] = currentCurves[currentY][currentX].getReducedChiSquaredError(); 
     217      if(rcsecache[currentY][currentX] < worstRCSE) { 
     218        double[][] curve = currentCurves[currentY][currentX].getCurve(); 
     219        double[] exponentials = new double[numExponentials]; 
     220        for(int i = 0; i < numExponentials; i++) { 
     221          exponentials[i] = curve[i][1]; 
     222        } 
     223        Arrays.sort(exponentials); 
     224        for(int c = 0; c < numExponentials; c++) { 
     225          image[numExponentials-c-1][currentY * maxDim + currentX] = exponentials[c]; 
     226          //image[numExponentials-c-1][currentY * maxDim + currentX] = 1; 
     227        } 
     228      } 
    211229      //System.out.println("x: " + currentX + "  y: " + currentY + "   RCSE: " + currentCurves[currentY][currentX].getReducedChiSquaredError()); 
    212230    } 
  • trunk/loci/slim/GACurveFitter.java

    r4302 r4323  
    4848 
    4949  private static final boolean DEBUG = false; 
    50   private static final int STALL_GENERATIONS = 5; 
     50  private static final int STALL_GENERATIONS = 3; 
    5151  private static final double STALLED_FACTOR = 2.0d; 
    5252  private static final double MUTATION_CHANCE = .25d; 
     
    5555  private static final double INITIAL_MUTATION_FACTOR = .5; 
    5656  // Must be 0 < x < 1 
    57   private static final double MUTATION_FACTOR_REDUCTION = .9; 
     57  private static final double MUTATION_FACTOR_REDUCTION = .99; 
    5858 
    5959  // -- Constructor -- 
     
    184184      } 
    185185    } 
    186     for(int q = 0; q < curveEstimate.length; q++) { 
    187       if(DEBUG) System.out.println("c" + q + ": " + curveEstimate[q][2]); 
    188     } 
     186    /* 
     187    System.out.println("RCSE: " + currentRCSE); 
     188    for(int j = 0; j < components; j++) { 
     189      System.out.println("a: " + curveEstimate[j][0] + " b: " + curveEstimate[j][1] + " c: " + curveEstimate[j][2]); 
     190    } 
     191    */ 
    189192  } 
    190193 
     
    228231      System.out.println("i: " + i + "  data: " + curveData[i]); 
    229232    } 
    230     try { Thread.sleep(1000); } catch(Exception e) {} 
    231233    */ 
     234    //try { Thread.sleep(1000); } catch(Exception e) {} 
    232235    if (components >= 1) { 
    233236      // TODO: Estimate c, factor it in below. 
     
    462465  /** 
    463466   * Returns the current curve estimate. 
    464    * Return size is expected to be [numExponentials][3] 
     467   * Return size is expected to be [components][3] 
    465468   * For each exponential of the form ae^-bt+c, 
    466469   * [][0] is a, [1] is b, [2] is c. 
    467470   **/ 
    468471  public double[][] getCurve() { 
    469     return curveEstimate; 
     472    if(components == 1) return curveEstimate; 
     473    // Otherwise, it's 2 exponential, and we want it in ascending order 
     474    if(components == 2) { 
     475      if(curveEstimate[0][1] > curveEstimate[1][1]) { 
     476        double[][] toreturn = new double[components][3]; 
     477        toreturn[0] = curveEstimate[1]; 
     478        toreturn[1] = curveEstimate[0]; 
     479        return toreturn; 
     480      } else { 
     481        return curveEstimate; 
     482      } 
     483    } 
     484    return null; 
     485     
    470486  } 
    471487 
  • trunk/loci/slim/SlimPlotter.java

    r4243 r4323  
    10181018          fitter.setData(curveData); 
    10191019          fitter.estimate(); 
    1020           for (int i=0; i<100; i++) fitter.iterate(); 
     1020          for (int i=0; i<250; i++) fitter.iterate(); 
    10211021          double[][] results = fitter.getCurve(); 
    10221022          log("\t\tchi2=" + fitter.getReducedChiSquaredError()); 
Note: See TracChangeset for help on using the changeset viewer.