commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pavol Loffay (JIRA)" <j...@apache.org>
Subject [jira] [Created] (MATH-1321) SimplexOptimizer returns wrong values
Date Tue, 09 Feb 2016 11:37:18 GMT
Pavol Loffay created MATH-1321:
----------------------------------

             Summary: SimplexOptimizer returns wrong values
                 Key: MATH-1321
                 URL: https://issues.apache.org/jira/browse/MATH-1321
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 3.6
         Environment: Fedora 23,
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
            Reporter: Pavol Loffay


Hello I'm trying to minimize MSE of double exponential smoothing and get optimal parameters
alpha and beta. 
https://www.otexts.org/fpp/7/2

During the minimization the output shows values of alpha and beta which differs from alpha,
and beta returned from SimplexOptimizer.optimize().

{code:title=output|borderStyle=solid}
...
Nelder MSE = 0.007226473669598979, alpha=0.896283, beta=0.228161
Nelder MSE = 0.0069843320509952005, alpha=0.913694, beta=0.190210 # returned minimum
Nelder MSE = 0.008577342645261695, alpha=0.931617, beta=0.131448
Nelder MSE = 0.00743296945818598, alpha=0.918018, beta=0.166808
Nelder MSE = 0.007818891499431175, alpha=0.936768, beta=0.136053
Nelder MSE = 0.007293932014855209, alpha=0.927010, beta=0.155973
Nelder MSE = 0.007319455298330941, alpha=0.923120, beta=0.178180
Nelder MSE = 0.007110221641945739, alpha=0.921873, beta=0.175281
Nelder MSE = 0.007271067724068611, alpha=0.907713, beta=0.212689
Nelder MSE = 0.007084561548618076, alpha=0.912928, beta=0.197226
Nelder MSE = 0.007072487763137581, alpha=0.903911, beta=0.213540

Nelder -> key = [2.3595947265625, -1.44864501953125], fce minimum= 0.00698433205099520050
{code}

{code:title=Test.java|borderStyle=solid}

@Test
    public void testOptimization() throws IOException {

        int maxEval = 1000;
        int maxIter = 1000;

        // Nelder-Mead Simplex
        SimplexOptimizer nelderSimplexOptimizer = new SimplexOptimizer(0.0001, 0.0001);
        PointValuePair nelderResult = nelderSimplexOptimizer.optimize(
                GoalType.MINIMIZE, new MaxIter(maxIter), new MaxEval(maxEval),
                new InitialGuess(new double[]{0.4, 0.1}), new ObjectiveFunction(optimizationFn("Nelder")),
                new NelderMeadSimplex(2));

 System.out.format("\nNelder (%d eval) -> key = %s, fce minimum= %.20f", nelderSimplexOptimizer.getEvaluations(),
                Arrays.toString(nelderResult.getKey()), nelderResult.getValue());
}

private MultivariateFunction optimizationFn(String algorithm) {

        final List<DataPoint> testData = metricData.subList(0, 50);
        // func for minimization
        MultivariateFunction multivariateFunction = point -> {

            double alpha = point[0];
            double beta = point[1];

            DoubleExponentialSmoothing doubleExponentialSmoothing = new DoubleExponentialSmoothing(alpha,
beta);
            AccuracyStatistics accuracyStatistics = doubleExponentialSmoothing.init(testData);

            System.out.format("%s MSE = %s, alpha=%f, beta=%f\n", algorithm, accuracyStatistics.getMse(),
alpha, beta);
            return accuracyStatistics.getMse();
        };
        MultivariateFunctionMappingAdapter multivariateFunctionMappingAdapter =
                new MultivariateFunctionMappingAdapter(multivariateFunction,
                        new double[]{0.0, 0.0}, new double[]{1, 1});

        return multivariateFunctionMappingAdapter;
    }
{code}







--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message