devernay / cminpack

A C/C++ rewrite of the MINPACK software (originally in FORTRAN) for solving nonlinear equations and nonlinear least squares problems
http://devernay.free.fr/hacks/cminpack/
145 stars 63 forks source link

Iteration numbers in cminpack #67

Closed LittleDogXi closed 2 months ago

LittleDogXi commented 3 months ago

The parameter "nfev" is the number of fcn calls. But how can I know the iteration numbers using hybrd function?

luau-project commented 3 months ago

According to the user guide for minpack, which can be found at

when you supply the param nprint a positive integer, it enables controlled printing of iterates.

LittleDogXi commented 3 months ago

I set param nprint a postive integer like +1, but I cannot see any printing of iterates in the console. Is the information printed somewhere else?

luau-project commented 3 months ago

I never experimented this nprint param myself, but judging by the docs linked above, I guess you would be called nprint times in the callback or something in that direction.

LittleDogXi commented 3 months ago

I will try it soon later.

LittleDogXi commented 3 months ago

After a few tries, I have figured it out. Set nprint a positive integer, like 1, and add if(*flag==0){std::cout<<"$";} in the fcn function, you could print serval $ characters, which has the same number of iteration times.

luau-project commented 3 months ago

I'm glad that you solved the puzzle.