[ 
https://issues.apache.org/jira/browse/MATH-867?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13466297#comment-13466297
 ] 

Nikolaus Hansen commented on MATH-867:
--------------------------------------

{quote}
Revision 1391840 contains modified "encode" and "decode" functions. Both unit 
tests now pass (for "testConstrainedRosen" I had to move the initial guess 
closer to the solution).
{quote}
if the test does not pass with initial point at 0.1, something is wrong (and it 
doesn't look like a good idea to change the test to make the code pass). 

I found at least one problem:

{code}
        private double[] repair(final double[] x) {
            double[] repaired = new double[x.length];
            for (int i = 0; i < x.length; i++) {
                if (x[i] < 0) {
                    repaired[i] = 0;
                } else if (x[i] > 1.0) {
                    repaired[i] = 1.0;
                } else {
                    repaired[i] = x[i];
                }
            }
            return repaired;
        }

{code}
must read 
{code}
        private double[] repair(final double[] x) {
            double[] repaired = new double[x.length];
            if (boundaries == null) {
                for (int i = 0; i < x.length; i++) {
                    repaired[i] = x[i];
                }
            } else {

                final double[] bLoEnc = encode(boundaries[0]);
                final double[] bHiEnc = encode(boundaries[1]);

                for (int i = 0; i < x.length; i++) {
                    if (x[i] < bLoEnc[i]) {
                        repaired[i] = bLoEnc[i];
                    } else if (x[i] > bHiEnc[i]) {
                        repaired[i] = bHiEnc[i];
                    }
                }
            }
            return repaired;
    }


{code}
I am not sure whether or not this is the reason why the test fails. 
                
> CMAESOptimizer with bounds fits finely near lower bound and coarsely near 
> upper bound. 
> ---------------------------------------------------------------------------------------
>
>                 Key: MATH-867
>                 URL: https://issues.apache.org/jira/browse/MATH-867
>             Project: Commons Math
>          Issue Type: Bug
>            Reporter: Frank Hess
>         Attachments: MATH867_patch, Math867Test.java
>
>
> When fitting with bounds, the CMAESOptimizer fits finely near the lower bound 
> and coarsely near the upper bound.  This is because it internally maps the 
> fitted parameter range into the interval [0,1].  The unit of least precision 
> (ulp) between floating point numbers is much smaller near zero than near one. 
>  Thus, fits have much better resolution near the lower bound (which is mapped 
> to zero) than the upper bound (which is mapped to one).  I will attach a 
> example program to demonstrate.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to