Initialise the simplex and evaluate it. Returns null on failure.
(double[] initialParams, double[] initialParamVariations, Random random)
| 609 | |
| 610 | /** Initialise the simplex and evaluate it. Returns null on failure. */ |
| 611 | private double[][] makeSimplex(double[] initialParams, double[] initialParamVariations, Random random) { |
| 612 | double[][] simp = new double[numVertices][numParams+1+numExtraArrayElements]; |
| 613 | /* simpTable.put(Thread.currentThread(), simp); */ |
| 614 | |
| 615 | if (initialParams!=null) { |
| 616 | for (int i=0; i<numParams; i++) |
| 617 | if (Double.isNaN(initialParams[i])) |
| 618 | if (IJ.debugMode) IJ.log("Warning: Initial Parameter["+i+"] is NaN"); |
| 619 | System.arraycopy(initialParams, 0, simp[0], 0, Math.min(initialParams.length, numParams)); |
| 620 | } |
| 621 | evaluate(simp[0]); |
| 622 | if (Double.isNaN(value(simp[0]))) { |
| 623 | if (IJ.debugMode) showVertex(simp[0], "Warning: Initial Parameters yield NaN:"); |
| 624 | findValidInitalParams(simp[0], initialParamVariations, random); |
| 625 | } |
| 626 | if (Double.isNaN(value(simp[0]))) { |
| 627 | if (IJ.debugMode) IJ.log("Error: Could not find initial parameters not yielding NaN:"); |
| 628 | return null; |
| 629 | } |
| 630 | if (initializeSimplex(simp, initialParamVariations, random)) |
| 631 | return simp; |
| 632 | else { |
| 633 | if (IJ.debugMode) showSimplex(simp, "Error: Could not make simplex vertices not yielding NaN"); |
| 634 | return null; |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | /** Whether the distance between the best and any other simplex vertex |
| 639 | * is less than the resolution of the parameters */ |
no test coverage detected