gt:         doTest(new CigTab(), startPoint, insigma, boundaries,
context: /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.commons.math.optimization.direct;
  
  import java.util.Arrays;
  import java.util.Random;
  
  import org.apache.commons.math.Retry;
  import org.apache.commons.math.RetryRunner;
  import org.apache.commons.math.analysis.MultivariateRealFunction;
  import org.apache.commons.math.exception.MultiDimensionMismatchException;
  import org.apache.commons.math.exception.NoDataException;
  import org.apache.commons.math.exception.NotPositiveException;
  import org.apache.commons.math.exception.OutOfRangeException;
  import org.apache.commons.math.optimization.GoalType;
  import org.apache.commons.math.optimization.MultivariateRealOptimizer;
  import org.apache.commons.math.optimization.RealPointValuePair;
  import org.apache.commons.math.random.MersenneTwister;
  import org.junit.Assert;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  
  /**
   * Test for {@link CMAESOptimizer}.
   */
  @RunWith(RetryRunner.class)
  public class CMAESOptimizerTest {
  
      static final int DIM = 13;
      static final int LAMBDA = 4 + (int)(3.*Math.log(DIM));
     
      @Test(expected = OutOfRangeException.class)
      public void testInitOutofbounds() {
          double[] startPoint = point(DIM,3);
          double[] insigma = null;
          double[][] boundaries = boundaries(DIM,-1,2);
          RealPointValuePair expected =
              new RealPointValuePair(point(DIM,1.0),0.0);
          doTest(new Rosen(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13,
                  1e-13, 1e-6, 100000, expected);
      }
      
      @Test(expected = MultiDimensionMismatchException.class)
      public void testBoundariesDimensionMismatch() {
          double[] startPoint = point(DIM,0.5);
          double[] insigma = null;
          double[][] boundaries = boundaries(DIM+1,-1,2);
          RealPointValuePair expected =
              new RealPointValuePair(point(DIM,1.0),0.0);
          doTest(new Rosen(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13,
                  1e-13, 1e-6, 100000, expected);
      }
  
      @Test(expected = NoDataException.class)
      public void testBoundariesNoData() {
          double[] startPoint = point(DIM,0.5);
          double[] insigma = null;
          double[][] boundaries = boundaries(DIM,-1,2);
          boundaries[1] = null;
          RealPointValuePair expected =
              new RealPointValuePair(point(DIM,1.0),0.0);
          doTest(new Rosen(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13,
                  1e-13, 1e-6, 100000, expected);
      }
  
      @Test(expected = NotPositiveException.class)
      public void testInputSigmaNegative() {
          double[] startPoint = point(DIM,0.5);
          double[] insigma = point(DIM,-0.5);
          double[][] boundaries = null;
          RealPointValuePair expected =
              new RealPointValuePair(point(DIM,1.0),0.0);
          doTest(new Rosen(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13,
                  1e-13, 1e-6, 100000, expected);
      }
  
      @Test(expected = OutOfRangeException.class)
      public void testInputSigmaOutOfRange() {
          double[] startPoint = point(DIM,0.5);
          double[] insigma = point(DIM, 1.1);
          double[][] boundaries = boundaries(DIM,-1,2);
          RealPointValuePair expected =
              new RealPointValuePair(point(DIM,1.0),0.0);
          doTest(new Rosen(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13,
                  1e-13, 1e-6, 100000, expected);
      }
  
      @Test(expected = MultiDimensionMismatchException.class)
      public void testInputSigmaDimensionMismatch() {
          double[] startPoint = point(DIM,0.5);
          double[] insigma = point(DIM+1,-0.5);
          double[][] boundaries = null;
          RealPointValuePair expected =
              new RealPointValuePair(point(DIM,1.0),0.0);
          doTest(new Rosen(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13,
                  1e-13, 1e-6, 100000, expected);
      }
      
      @Test
      @Retry(3)
      public void testRosen() {
          double[] startPoint = point(DIM,0.1);
          double[] insigma = point(DIM,0.1);
          double[][] boundaries = null;
          RealPointValuePair expected =
              new RealPointValuePair(point(DIM,1.0),0.0);
          doTest(new Rosen(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13,
                  1e-13, 1e-6, 100000, expected);
          doTest(new Rosen(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, false, 0, 1e-13,
                  1e-13, 1e-6, 100000, expected);
      }
  
      @Test
      @Retry(3)
      public void testMaximize() {}
  //     public void testMaximize() {
  //         double[] startPoint = point(DIM,1.0);
  //         double[] insigma = point(DIM,0.1);
  //         double[][] boundaries = null;
  //         RealPointValuePair expected =
  //             new RealPointValuePair(point(DIM,0.0),1.0);
  //         doTest(new MinusElli(), startPoint, insigma, boundaries,
  //                 GoalType.MAXIMIZE, LAMBDA, true, 0, 1.0-1e-13,
  //                 2e-10, 5e-6, 100000, expected);
  //         doTest(new MinusElli(), startPoint, insigma, boundaries,
  //                 GoalType.MAXIMIZE, LAMBDA, false, 0, 1.0-1e-13,
  //                 2e-10, 5e-6, 100000, expected);
  //         boundaries = boundaries(DIM,-0.3,0.3); 
  //         startPoint = point(DIM,0.1);
  //         doTest(new MinusElli(), startPoint, insigma, boundaries,
  //                 GoalType.MAXIMIZE, LAMBDA, true, 0, 1.0-1e-13,
  //                 2e-10, 5e-6, 100000, expected);
  //     }
  
      @Test
      public void testEllipse() {
          double[] startPoint = point(DIM,1.0);
          double[] insigma = point(DIM,0.1);
          double[][] boundaries = null;
          RealPointValuePair expected =
              new RealPointValuePair(point(DIM,0.0),0.0);
          doTest(new Elli(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13,
                  1e-13, 1e-6, 100000, expected);
          doTest(new Elli(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, false, 0, 1e-13,
                  1e-13, 1e-6, 100000, expected);
      }
  
      @Test
      public void testElliRotated() {
          double[] startPoint = point(DIM,1.0);
          double[] insigma = point(DIM,0.1);
          double[][] boundaries = null;
          RealPointValuePair expected =
              new RealPointValuePair(point(DIM,0.0),0.0);
          doTest(new ElliRotated(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13,
                  1e-13, 1e-6, 100000, expected);
          doTest(new ElliRotated(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, false, 0, 1e-13,
                  1e-13, 1e-6, 100000, expected);
      }
  
      @Test
      public void testCigar() {
          double[] startPoint = point(DIM,1.0);
          double[] insigma = point(DIM,0.1);
          double[][] boundaries = null;
          RealPointValuePair expected =
              new RealPointValuePair(point(DIM,0.0),0.0);
          doTest(new Cigar(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13,
                  1e-13, 1e-6, 200000, expected);
          doTest(new Cigar(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, false, 0, 1e-13,
                  1e-13, 1e-6, 100000, expected);
      }
  
      @Test
      public void testTwoAxes() {
          double[] startPoint = point(DIM,1.0);
          double[] insigma = point(DIM,0.1);
          double[][] boundaries = null;
          RealPointValuePair expected =
              new RealPointValuePair(point(DIM,0.0),0.0);
          doTest(new TwoAxes(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, 2*LAMBDA, true, 0, 1e-13,
                  1e-13, 1e-6, 200000, expected);
          doTest(new TwoAxes(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, 2*LAMBDA, false, 0, 1e-13,
                  1e-8, 1e-3, 200000, expected);
      }
  
      @Test
      public void testCigTab() {
          double[] startPoint = point(DIM,1.0);
          double[] insigma = point(DIM,0.3);
          double[][] boundaries = null;
          RealPointValuePair expected =
              new RealPointValuePair(point(DIM,0.0),0.0);
          doTest(new CigTab(), startPoint, insigma, boundaries,
                  GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13,
                  1e-13, 5e-5, 100000, expected);
  