Class NMSimplex

java.lang.Object
gov.nih.mipav.model.algorithms.NMSimplex

public abstract class NMSimplex extends Object
Example public class Objfunc implements Objfun { public double evalObjfun(double x[]){ return (100*(x[1]-x[0]*x[0])*(x[1]-x[0]*x[0])+(1.0-x[0])*(1.0-x[0])); } } public class Constraint implements Constraints { double round2(double num, int precision) { double rnum; int tnum; rnum = num*Math.pow(10,precision); tnum = (int)(rnum invalid input: '<' 0 ? rnum-0.5 : rnum + 0.5); rnum = tnum/Math.pow(10,precision); return rnum; } public void getConstrainedValues(double x[], int n) { // round to 2 decimal places int i; for (i=0; iinvalid input: '<'n; i++) { x[i] = round2(x[i],2); } } } public class Testfun { public static void main(String[] args) throws IOException { double start[] = {-1.2,1.0}; int dim = 2; double eps = 1.0e-4; double scale = 1.0; boolean display = true; int i; NMSimplex simplex = new NMSimplex(start,dim,eps,scale,display); for (i=0; iinvalid input: '<'dim; i++) { System.out.format("%f\n",start[i]); } } } My run of Rosenbrock example gives: Starting at double x0[] = new double[]{0.0,0.0}; The minimum was found at 1.000000e+00 1.000000e+00 101 Function Evaluations 50 Iterations through program This agrees with Nike Hutt's answer: Initial Values 0.00, 0.00, value 1.00 0.97, 0.26, value 46.36 0.26, 0.97, value 81.98 102 Function Evaluations 50 Iterations through program The minimum was found at 1.00, 1.00, value 0.00
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final double
     
    (package private) static final double
     
    private boolean
     
    private double
     
    (package private) static final double
     
    (package private) static final int
     
    private int
     
    private double
     
    private double[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    NMSimplex(double[] start, int n, double EPSILON, double scale, boolean display)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    abstract double
    evalObjfun(double[] x)
     
    abstract void
    getConstrainedValues(double[] x, int n)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • NMSimplex

      public NMSimplex(double[] start, int n, double EPSILON, double scale, boolean display)
  • Method Details

    • driver

      public void driver()
    • getConstrainedValues

      public abstract void getConstrainedValues(double[] x, int n)
    • evalObjfun

      public abstract double evalObjfun(double[] x)