CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   public domain f77 separable nonlinear least squares solver wanted (http://www.cfd-online.com/Forums/main/1748-public-domain-f77-separable-nonlinear-least-squares-solver-wanted.html)

 Sergei Chernyshenko January 26, 2000 06:00

public domain f77 separable nonlinear least squares solver wanted

Hi,

I need a public domain f77 subroutine for solving the following problem:

minimize f_1**2+...+f_m**2

where f_i(x_1,...,x_n,y_1,...,y_m) are linear in x_k and nonlinear in y_l.

n=32, m=8 or 16 or 34, f_i are simple, so, may be, pure nonlinear optimizer will do.

I tried lmdif1 from MINPACK but when n>8 it gives incorrect results. Any suggestions?

Sergei

 Zhong Lei January 26, 2000 21:50

Re: public domain f77 separable nonlinear least squares solver wanted

Try to use the book, Numerical Recipies in Fortran77 2nd ed. Are you talking about optimization?

Zhong

 Sergei Chernyshenko January 27, 2000 06:01

Re: public domain f77 separable nonlinear least squares solver wanted

Hi, Zhong,

Thank you.

Subroutines in Numerical Ricipes are not in public domain, you have to pay for them, 50\$ per one cheepest-kind license per subroutine.

Well, my problem is a specific case of data fitting. But this is quite close to optimization, of course.

Rgds, Sergei.

 Joerg Weidenfeller January 27, 2000 12:01

Re: public domain f77 separable nonlinear least squares solver wanted

Hi Sergei!

Try the following ftp-server.

ftp://elib.zib.de/netlib/slatec

The file toc.gz contains all f77 subroutines (public domain). For minimizing RMS of a multidimensional polynom I used the subroutine called "SNLS1.F" resp. "DNLS1.F" for double precission. Both are modifications of the Levenberg-Marquardt algorithm. Mostly the source codes are explained well!

Joerg

 Sergei Chernyshenko January 27, 2000 12:24

Re: public domain f77 separable nonlinear least squares solver wanted

Hi, Joerg,

Thank you.

I tried them, or, more exactly, SNLS1E.f, which is a driver for SNLS1.f. I also tried LMDIF1.f which is an earlier version. Note that I do not want to calculate the derivatives. Well, both perform badly, the older version just giving erroneous results while the newer one gives spurious error messages and stops, or just gives erroneuos results, too. And this is with comparatively simple functions with good Jacobean. I do not think I use them incorrectly since for other functions they work all right. Just their criteria for stopping iterations are far from perfect.

So, I wrote my own code, after all. Not state of the art, but it works in the specific case I have, allthough I would like to have something better.

Thanks again, Sergei

 Joerg Weidenfeller January 28, 2000 08:44

Re: public domain f77 separable nonlinear least squares solver wanted

Hi Sergei!

That seems really strange to me. I used SNLS1.f for fitting a 4 dimensional polynom (each dimension has a order from 4 to 7) with approx 700 quadrupels. And I got really good results. I run the subroutine with IOPT=1 (means do not calculate jacobian matrix, because I don't need this). The criteria for stopping the iterations were 1E-5 for single precission. Perhaps the suggested criteria (R1MACH(4)-sqrt of machine precission) is a possibility for your problem?

Good luck

Joerg

 Sergei Chernyshenko January 28, 2000 12:19

Re: public domain f77 separable nonlinear least squares solver wanted

Hi, Joerg,

Well, I made one more attempt. I downloaded slatec from the site you indicated, and run the checks supplied there. And it does not pass the checks! This can something to do with machine constants. I'll try to find a program which will determine all those constants for my specific computer.

Thanks,

Sergei

 Adrin Gharakhani January 28, 2000 14:32

Re: public domain f77 separable nonlinear least squares solver wanted

If you have a F90 compiler on your machine you can print out these values using F90 functions. That's how I found & used my machine numbers with netlib functions.

 Sergei Chernyshenko January 28, 2000 14:37

Re: public domain f77 separable nonlinear least squares solver wanted

Thanks, I did not know that f90 had such functions. I'll investigate.

Rgds, Sergei

 Adrin Gharakhani January 28, 2000 14:54

Re: public domain f77 separable nonlinear least squares solver wanted

Look for the explanation for the following functions:

bit_size() digits() epsilon() exponent() fraction() huge() maxexponent() minexponent() precision() radix() range() rrspacing() spacing() tiny()

You will not need all of these, but they are nice functions to know