commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: [math] BOBYQAOptimizer hang
Date Thu, 19 Dec 2013 13:53:14 GMT

Thank you for answering. PowellOptimizer did not work very well for our 
particular function, and other optimizers in scalar.noderiv are not easily 
understandable. BOBYQAOptimizer usually works well. Do you have 
suggestions that we might work around this particular case so it does not 
hang? We minimize LS with grid (x,y) having 9 points.


class LS implements MultivariateFunction {
        private BS bs = new BS();
        private double[] x;
        private double[] y;
        private double const1;
        private int optionType;

        public LS(double[] x, double[] y, int optionType, double const1) {
                this.x = x;
                this.y = y;
                this.optionType = optionType;
                this.const1 = const1;

        public double value(double point[]) {
                int len = x.length;
                double val = 0;
                for (int i=0; i<len; i++) {
                        double yc = bs.f2(x[i], point[0]*const1, point[1], 
point[2], optionType); 
                        val += Math.pow(yc-y[i], 2);
                return val;

class BS {
        public double blackScholes(double price, double strike, double 
time, double vol, int optionType) {
            double volrootime = Math.pow(time, 0.5) * vol;
            double topline1 = Math.log(price/strike);
            double topline2 = Math.pow(vol, 2)/2* time;
            double topline = topline1 + topline2;
            double d1 = topline / volrootime;
            double d2 = d1 - volrootime;
            double val = 0.0;
            NormalDistribution normal = new NormalDistribution();
            if (optionType==1)
                val = (price * normal.cumulativeProbability(d1) - strike * 
                val = (strike * normal.cumulativeProbability(-d2) - price 
* normal.cumulativeProbability(-d1));
            return val;

        public double f2(double x, double ah, double ai, double aj, int 
ak) {
                return ah*bScore(x, ai, aj, ak);
        public double bScore(double price, double strike, double vol, int 
optionType) {
                return blackScholes(price, strike, 1, vol, optionType);

Gilles <>
12/18/2013 07:22 PM
Re: [math] BOBYQAOptimizer hang


On Wed, 18 Dec 2013 12:58:52 -0500, wrote:
> I ran into a case that BOBYQAOptimizer hang in line 485. trsbox is 
> pretty
> complex method and I'm not familiar with the algorithm. It seems 
> going
> into infinite loop between different states.
>             final double[] dsqCrvmin = trsbox(delta, gnew, xbdi, s,
>                                               hs, hred);
> Here is the test case for it. After reducing the value to <2.24 it 
> hang in
> trsbox method without progress.
> Can someone shed light on what might be happening, and how to deal 
> with
> it? Thanks.

The short story is that BOBYQAOptimzer is not really supported.
The long story is on the bug-tracking system:


To unsubscribe, e-mail:
For additional commands, e-mail:

The contents of this email are the property of PNC. If it was not addressed to you, you have
no legal right to read it. If you think you received it in error, please notify the sender.
Do not forward or copy without permission of the sender. This message may contain an advertisement
of a product or service and thus may constitute a commercial electronic mail message under
US Law. The postal address for PNC is 249 Fifth Avenue, Pittsburgh, PA 15222. If you do not
wish to receive any additional advertising or promotional messages from PNC at this e-mail
address, click here to unsubscribe. 
By unsubscribing to this message, you will be unsubscribed from all advertising or promotional
messages from PNC. Removing your e-mail address from this mailing list will not affect your
subscription to alerts, e-newsletters or account servicing e-mails.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message