()
| 95 | } |
| 96 | |
| 97 | public void testNormOpt() { |
| 98 | // norm penalty should put max at 0 (and max value should be 0) |
| 99 | final int dim = 3; |
| 100 | final VectorFn f = new NormPenalty(dim,1.0e-2); |
| 101 | final double[] x = new double[dim]; |
| 102 | x[1] = 0.1; |
| 103 | x[2] = -0.1; |
| 104 | final Newton opt = new Newton(); |
| 105 | final VEval r = opt.maximize(f,x,10); |
| 106 | assertNotNull(r); |
| 107 | assertNotNull(r.x); |
| 108 | assertEquals(dim,r.x.length); |
| 109 | for(int i=0;i<dim;++i) { |
| 110 | assertTrue(Math.abs(r.x[i])<1.0e-3); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | } |