1 package net.sf.openrocket.optimization;
3 import static org.junit.Assert.*;
7 import net.sf.openrocket.optimization.general.Point;
8 import net.sf.openrocket.optimization.general.multidim.SearchPattern;
10 import org.junit.Test;
12 public class TestSearchPattern {
15 public void testRegularSimplex() {
16 for (int dim = 1; dim < 20; dim++) {
17 List<Point> points = SearchPattern.regularSimplex(dim);
18 assertEquals(dim, points.size());
20 for (int i = 0; i < dim; i++) {
22 for (int j = i + 1; j < dim; j++) {
23 double[] x = points.get(i).asArray();
24 double[] y = points.get(j).asArray();
26 for (int k = 0; k < dim; k++) {
29 assertEquals(0.5, dot, 0.000000001);
32 // Test positive coordinates
33 for (int j = 0; j < dim; j++) {
34 assertTrue(points.get(i).get(j) >= 0);
38 assertEquals(1.0, points.get(i).length(), 0.000000001);