Guest User

commons-math BOBYQA trsbox infinite loop

a guest
Oct 20th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.72 KB | None | 0 0
  1. package org.apache.commons.math3.optim.nonlinear.scalar.noderiv;
  2.  
  3. import org.apache.commons.math3.linear.Array2DRowRealMatrix;
  4. import org.apache.commons.math3.linear.ArrayRealVector;
  5. import org.junit.Test;
  6.  
  7. public class BOBYQAOptimizerTest {
  8.     @Test(timeout = 10000)
  9.     public void testInfiniteLoop() throws Exception {
  10.         BOBYQAOptimizer optim = new BOBYQAOptimizer(13);
  11.  
  12.         /*
  13.          * The visibility of these fields needs to be set to "package".
  14.          */
  15.  
  16.         optim.currentBest = new ArrayRealVector(new double[] {
  17.                 0.08873732733679275, 0.0727730484082505, 5.0,
  18.                 0.4739772780102623, 0.3254098307735338, 0.011690891124956138 });
  19.  
  20.         optim.trustRegionCenterOffset = new ArrayRealVector(
  21.                 new double[] { 0.08873732733679275, -0.8154052319625713, 0.0,
  22.                         0.04315377185976695, 0.00763116579283767,
  23.                         0.006690891124956133 });
  24.  
  25.         optim.lowerDifference = new ArrayRealVector(new double[] { 0.0,
  26.                 -0.8881782803708218, -4.999999999999999, -0.42582350615049547,
  27.                 -0.3177786649806961, 0.0 });
  28.  
  29.         optim.gradientAtTrustRegionCenter = new ArrayRealVector(new double[] {
  30.                 1.8796268088008995E126, 3.529308428257907E122,
  31.                 4.339520711070304E125, 5.608812786974868E126,
  32.                 -4.886897857097816E125, 3.487006131445964E125 });
  33.  
  34.         optim.trialStepPoint = new ArrayRealVector(new double[] {
  35.                 0.018534274689260638, -3.0286453569394745E-5,
  36.                 9.307922453577254E-5, 0.08393819985263673,
  37.                 -0.0047990613305209035, 0.006690891124956133 });
  38.  
  39.         optim.upperDifference = new ArrayRealVector(new double[] { 5.0,
  40.                 4.111821719629179, 0.0, 4.569176493849504, 0.6722213350193036,
  41.                 0.995 });
  42.  
  43.         optim.modelSecondDerivativesValues = new ArrayRealVector(new double[] {
  44.                 8.347666014168881E22, 3.083084801163501E24,
  45.                 6.897175318585434E28, -0.44515251255638855,
  46.                 -14.882236374143211, 1.1725054479105397, 3.7517428938402095E22,
  47.                 5.715239375136025E26, -2.615998357726303, 4.737565374055262E24,
  48.                 7.715920246182096E22, 1.9694186667973142E27,
  49.                 -0.3462401331093542, 1.6317726106153778E25,
  50.                 5.623617765741468E25, 0.36431300388940296,
  51.                 -5.086426080473383E12, -0.8209127432417354,
  52.                 4.913708497322823E12, -1.3907154846378276E12,
  53.                 8.46293921765543E10 });
  54.  
  55.         optim.modelSecondDerivativesParameters = new ArrayRealVector(
  56.                 new double[] { -8.280972179979475E107, 6.483491305977545E121,
  57.                         -3.591105321248276E122, -7.150793784954832E122,
  58.                         8.716344713872511E122, 7.393516096544781E120,
  59.                         -8.727921483213026E121, 2.2946726277373087E123,
  60.                         -3.4278084109205284E107, 6.018665812878733E119,
  61.                         -5.46624278297487E119, 4.4618180068639655E108,
  62.                         6.859493898945998E121 });
  63.  
  64.         double[][] matrix = {
  65.                 { 0.08873732733679275, -0.8154052319625713, 0.0,
  66.                         0.04315377185976695, 0.00763116579283767,
  67.                         0.006690891124956133 },
  68.                 { 0.0, -0.09914138449641066, 0.0, 5.403478276122921E-5,
  69.                         1.224284426168555E-4, 0.0 },
  70.                 { 0.0, 0.006616520523110381, 0.0, 5.805252696630824E-5,
  71.                         9.736209365813516E-5, 0.0 },
  72.                 { 0.0, -0.04798067054496377, 0.0, 6.902083900586665E-5,
  73.                         1.8453954146836646E-4, 0.0 },
  74.                 { 0.0, -0.8153670291635121, -0.0012633603831365423,
  75.                         -0.41116414296856707, 0.17181681223620485, 0.0 },
  76.                 { 1.930200144389376E-5, 0.006551199859120928, 0.0,
  77.                         4.055203974058454E-5, 1.2802485498026033E-4, 0.0 },
  78.                 { 0.0, 0.0061801450873448195, 0.0, 1.8504424483918167E-5,
  79.                         7.930155796052627E-5, 0.0 },
  80.                 { 0.0, -2.4394116078706174E-5, 0.0, 5.143706659899293E-5,
  81.                         1.4902504955366063E-4, 0.0 },
  82.                 { 4.167302901016568E-7, 0.006563172498281823,
  83.                         -4.4057982349691814E-5, 6.366744098999058E-5,
  84.                         1.0225459633527619E-4, 3.0413608576169715E-5 },
  85.                 { 0.0, -0.003217994941491575, 0.0, 8.627259287170399E-7,
  86.                         -1.5191639112058534E-6, 0.0 },
  87.                 { 0.07020305264753211, -0.8153749455090019,
  88.                         -9.307922453577254E-5, -0.04078442799286978,
  89.                         0.012430227123358574, 0.0 },
  90.                 { 0.0, 0.006571035139421758, 0.0, 4.922113885024038E-5,
  91.                         1.4154133501121982E-4, 1.7131917154176267E-5 },
  92.                 { 0.0, -0.2014627189010238, 0.0, 1.2867809856229346E-4,
  93.                         2.953203272088548E-4, 0.0 }, };
  94.  
  95.         optim.interpolationPoints = new Array2DRowRealMatrix(matrix);
  96.  
  97.         /*
  98.          * method parameters
  99.          */
  100.  
  101.         ArrayRealVector gnew = new ArrayRealVector(new double[] { 0, 0, 0, 0,
  102.                 0, 0 });
  103.         ArrayRealVector xbdi = new ArrayRealVector(new double[] { 0, 0, 0, 0,
  104.                 0, 0 });
  105.         ArrayRealVector s = new ArrayRealVector(
  106.                 new double[] { 0, 0, 0, 0, 0, 0 });
  107.         ArrayRealVector hs = new ArrayRealVector(new double[] { 0, 0, 0, 0, 0,
  108.                 0 });
  109.         ArrayRealVector hred = new ArrayRealVector(new double[] { 0, 0, 0, 0,
  110.                 0, 0 });
  111.  
  112.         /*
  113.          * The visibility of this method needs to be changed to "package"
  114.          */
  115.  
  116.         optim.trsbox(0.2046430153957766, gnew, xbdi, s, hs, hred);
  117.     }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment