MINPACK error with PiecewiseConstantParameter class

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

MINPACK error with PiecewiseConstantParameter class

javit
I'm having problems with a piecewise constant parameter optimization. I'm getting

MINPACK: improper input parameters

Still digging the code to find out what the problem is.

Would you share an example of a succesfull optimization with PiecewiseConstantParameter class?

Thank you,
Javit
Reply | Threaded
Open this post in threaded view
|

Re: MINPACK error with PiecewiseConstantParameter class

Bojan Nikolic

javit <[hidden email]> writes:

> MINPACK: improper input parameters

This suggests you are using the Levenberg-Marquardt algorithm. Did you
try using the ConjugateGradient, it might give you a more verbose
error message?

Best,
Bojan

--
Bojan Nikolic          ||          http://www.bnikolic.co.uk

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: MINPACK error with PiecewiseConstantParameter class

javit
Bojan,

Thank you for the reply. I tried the simplex class and it worked. I believe it is the Levenberg-Marquardt causing the trouble. I will try the ConjugateGradient class, too.

Javit

Bojan Nikolic wrote
javit <cavit@virginia.edu> writes:

> MINPACK: improper input parameters

This suggests you are using the Levenberg-Marquardt algorithm. Did you
try using the ConjugateGradient, it might give you a more verbose
error message?

Best,
Bojan

--
Bojan Nikolic          ||          http://www.bnikolic.co.uk

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: MINPACK error with PiecewiseConstantParameter class

Klaus Spanderen-2
In reply to this post by javit
Hi Javit

could you please send (or post) the code that causes the problem. The
Levenberg-Marquardt algorithm should (in theory;-) work for
PiecewiseConstantParameter.

cheers
 Klaus

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: MINPACK error with PiecewiseConstantParameter class

javit
Klaus,

At my first read, I believed that LM algorithm should work too. I got the code running with ConjugateGradient method.

It took me sometime to figure out what is wrong. It turns out that after the optimized parameters are called, I call the model class once more to get the node values. And at that call, since the values are optimal, the root finders return an error complaining that the root is not bracketed. Both optimal f values have the same sign.

Therefore, in Solver1d.hpp, I believe that one should check the accuracy of the starting points (is f(x_1) - f(x_2) close to zero and is f(x_1) close to zero?) before checking the signs of the f(x_1) and f(x_2).

The current checks are:

Is f(x_1) = 0 ?
Is f(x_2) = 0 ?

Rather than this, it should be:
Is Abs( f(x_1) ) < accuracy?
Is Abs( f(x_2) ) < accuracy?
If yes, then return the x as the root before starting to check the signs of f values.

For the LM algorithm, I still don't know why it is not working. I would bet that it is the number of optimization variables causing the error. My code is currently messy. I cannot send it as it is. I will let you know when all is done.

Thank you for your help,

Javit


Klaus Spanderen-2 wrote
Hi Javit

could you please send (or post) the code that causes the problem. The
Levenberg-Marquardt algorithm should (in theory;-) work for
PiecewiseConstantParameter.

cheers
 Klaus

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: MINPACK error with PiecewiseConstantParameter class

Dimathematician
I think I know where the problem might be located: in your cost function

Array values(Array x)

is the dimension of the returned array smaller than the dimension of
x? e.g. you are optimizing with respect to 3 parameters, but returning
a 2 dimensional array.

lmdif checks for

m < n

if this is true, your error code (*info=0) is returned


*    m is a positive integer input variable set to the number
*      of functions.
*
*    n is a positive integer input variable set to the number
*      of variables. n must not exceed m.

I think the objective in the MINPACK algo is to avoid an ill posed problem.

Can you check please? Otherwise we'll find something else :)




2009/9/3 javit <[hidden email]>

Klaus,

At my first read, I believed that LM algorithm should work too. I got the
code running with ConjugateGradient method.

It took me sometime to figure out what is wrong. It turns out that after the
optimized parameters are called, I call the model class once more to get the
node values. And at that call, since the values are optimal, the root
finders return an error complaining that the root is not bracketed. Both
optimal f values have the same sign.

Therefore, in Solver1d.hpp, I believe that one should check the accuracy of
the starting points (is f(x_1) - f(x_2) close to zero and is f(x_1) close to
zero?) before checking the signs of the f(x_1) and f(x_2).

The current checks are:

Is f(x_1) = 0 ?
Is f(x_2) = 0 ?

Rather than this, it should be:
Is Abs( f(x_1) ) < accuracy?
Is Abs( f(x_2) ) < accuracy?
If yes, then return the x as the root before starting to check the signs of
f values.

For the LM algorithm, I still don't know why it is not working. I would bet
that it is the number of optimization variables causing the error. My code
is currently messy. I cannot send it as it is. I will let you know when all
is done.

Thank you for your help,

Javit



Klaus Spanderen-2 wrote:
>
> Hi Javit
>
> could you please send (or post) the code that causes the problem. The
> Levenberg-Marquardt algorithm should (in theory;-) work for
> PiecewiseConstantParameter.
>
> cheers
>  Klaus
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
>


-----
Cavit (Javit) Hafizoglu
mailto:[hidden email] mailto:[hidden email]
--
View this message in context: http://www.nabble.com/MINPACK--error-with-PiecewiseConstantParameter-class-tp25225373p25274841.html
Sent from the quantlib-users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: MINPACK error with PiecewiseConstantParameter class

javit
Dima,

Thank you for your reply. I can't check it right away. It's our heavy season this time of the year. Things got slowed down now. Previously, I checked the LM code. The code exits with info = 0. That's why I was suspicious of the number of optimization variables.

Javit


Dimathematician wrote
I think I know where the problem might be located: in your cost function

Array values(Array x)

is the dimension of the returned array smaller than the dimension of
x? e.g. you are optimizing with respect to 3 parameters, but returning
a 2 dimensional array.

lmdif checks for

m < n

if this is true, your error code (*info=0) is returned


*    m is a positive integer input variable set to the number
*      of functions.
*
*    n is a positive integer input variable set to the number
*      of variables. n must not exceed m.

I think the objective in the MINPACK algo is to avoid an ill posed problem.

Can you check please? Otherwise we'll find something else :)




2009/9/3 javit <cavit@virginia.edu>

>
> Klaus,
>
> At my first read, I believed that LM algorithm should work too. I got the
> code running with ConjugateGradient method.
>
> It took me sometime to figure out what is wrong. It turns out that after
> the
> optimized parameters are called, I call the model class once more to get
> the
> node values. And at that call, since the values are optimal, the root
> finders return an error complaining that the root is not bracketed. Both
> optimal f values have the same sign.
>
> Therefore, in Solver1d.hpp, I believe that one should check the accuracy of
> the starting points (is f(x_1) - f(x_2) close to zero and is f(x_1) close
> to
> zero?) before checking the signs of the f(x_1) and f(x_2).
>
> The current checks are:
>
> Is f(x_1) = 0 ?
> Is f(x_2) = 0 ?
>
> Rather than this, it should be:
> Is Abs( f(x_1) ) < accuracy?
> Is Abs( f(x_2) ) < accuracy?
> If yes, then return the x as the root before starting to check the signs of
> f values.
>
> For the LM algorithm, I still don't know why it is not working. I would bet
> that it is the number of optimization variables causing the error. My code
> is currently messy. I cannot send it as it is. I will let you know when all
> is done.
>
> Thank you for your help,
>
> Javit
>
>
>
> Klaus Spanderen-2 wrote:
> >
> > Hi Javit
> >
> > could you please send (or post) the code that causes the problem. The
> > Levenberg-Marquardt algorithm should (in theory;-) work for
> > PiecewiseConstantParameter.
> >
> > cheers
> >  Klaus
> >
> >
> ------------------------------------------------------------------------------
> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> > 30-Day
> > trial. Simplify your report design, integration and deployment - and
> focus
> > on
> > what you do best, core application coding. Discover what's new with
> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> > _______________________________________________
> > QuantLib-users mailing list
> > QuantLib-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/quantlib-users
> >
> >
>
>
> -----
> Cavit (Javit) Hafizoglu
> mailto:javit.hafizoglu@suntrust.com mailto:javit.hafizoglu@suntrust.com
> --
> View this message in context:
> http://www.nabble.com/MINPACK--error-with-PiecewiseConstantParameter-class-tp25225373p25274841.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> QuantLib-users mailing list
> QuantLib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: MINPACK error with PiecewiseConstantParameter class

Luigi Ballabio
In reply to this post by javit
On Thu, 2009-09-03 at 05:19 -0700, javit wrote:
> It took me sometime to figure out what is wrong. It turns out that after the
> optimized parameters are called, I call the model class once more to get the
> node values.

I'm not sure I follow. Is this in your code or in the library? What
class or function does the calls? It sounds strange that the solver is
called again after the parameters have been optimized...

> Therefore, in Solver1d.hpp, I believe that one should check the accuracy of
> the starting points (is f(x_1) - f(x_2) close to zero and is f(x_1) close to
> zero?) before checking the signs of the f(x_1) and f(x_2).
>
> The current checks are:
>
> Is f(x_1) = 0 ?
> Is f(x_2) = 0 ?
>
> Rather than this, it should be:
> Is Abs( f(x_1) ) < accuracy?
> Is Abs( f(x_2) ) < accuracy?

The problem here is that the interface of Solver1D is not clearly
defined. Depending on the particular solver, the required accuracy might
be on the y axis (i.e., give me an x for which abs(f(x)) < accuracy) or
on the x axis (give me an x for which abs(x-x0) < accuracy, where x0 is
the real root.) The above only works with y accuracy.

Luigi


--

Every solution breeds new problems.
-- unknown



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users