admb-project / admb

AD Model Builder
http://admb-project.org
Other
64 stars 19 forks source link

const int initial_params::max_num_initial_params = 4000; on line 16 of nh99/model.cpp #157

Closed yukio-takeuchi closed 3 years ago

yukio-takeuchi commented 3 years ago

It seems that max_num_initial_params = 4000 in the line 16 of nh99/model.cpp limit the number of parameters which can be estimated by ADMB. Is there any command line options to increase it to allow larger number of parameters? Otherwise I would like to propose to increase this constant e.g 8000 or 10000, considering the increased ram size of modern PC.

johnoel commented 3 years ago

That's a good idea to set the maximum parameters using the command line. Let me try to code it up.

johnoel commented 3 years ago

Hi @yukio-takeuchi, when you get a chance, please test issue157 branch. Check that you can run with more than 4000 initial parameters.

yukio-takeuchi commented 3 years ago

Hi, I installed admb from branch issue157 macOS Intel big sur. Then I compiled a StockSynthesis 3.24z executable from tpl file I personally received from Rick Methot several years ago. The SS executable successfully finished with input files that have about 6000 parameters including both active and non-active ones. This input files were converted from WCPO skipjack MFCL basecase model run. I compiled admb with the default option to use std::vector. I would also like to test the alternative option to allow command line argument (-mpi). Can you tell me needed specific changes in makefile to do so?

johnoel commented 3 years ago

Thanks @yukio-takeuchi for testing the first approach. To use the second method, you will need to rebuild the branch.

Follow the procedure below:

Note: please update branch.

First clean,

% make clean

Then define macro USE_PTR_INIT_PARAMS in build,

CXXFLAGS=-DUSE_PTR_INIT_PARAMS make -j 4 

Usage:

./ss -mip 6000
yukio-takeuchi commented 3 years ago

It seems that the executable produced by the 2nd option has some problems

First of all I run SS executable without -mip

❯ ~/bin/SS3test2 -nox -nohess -mdl 100000000 -cbs 1000000000 -gbs 5000000000
 reading from STARTER.SS
 reading from data file
Data read sucessful 999

 reading forecast file
 reading from control  file
If you see 999, we got to the end of the control file successfully! 999
Warning : Command line option -mip has invalid argument, the default value will be used instead.

Estimating...please wait...

Then with -mip 8000 It stop after the calculation of objective function value on 1st ieration

ready for catchlike
 did recruitdev obj_fun 5790.63
 OK with obj_func 250936
1 1 -log(L): 250936  Spbio: 2.23179e+07 3.29476e+09

Initial statistics: 189 variables; iteration 0; function evaluation 0; phase 1
Function value   2.5093611e+05; maximum gradient component mag  -1.3789e+05
SS3test2(85858,0x10eafbe00) malloc: Incorrect checksum for freed object 0x7fbce3894810: probably modified after being freed.
Corrupt value: 0x7fbbcccc0bd8
SS3test2(85858,0x10eafbe00) malloc: *** set a breakpoint in malloc_error_break to debug
zsh: abort      ~/bin/SS3test2 -nox -nohess -mdl 100000000 -cbs 1000000000 -gbs 5000000000

Could you have any advise to me?

Cole-Monnahan-NOAA commented 3 years ago

I wonder if the option -mno already does something similar? According to the help file

 -mno N          set the maximum number of independent variables to N

https://github.com/admb-project/admb/blob/5ac089984c3309b10e42f14b7ea2f674f414e028/src/linad99/gradstrc.cpp#L461

johnoel commented 3 years ago

@Cole-Monnahan-NOAA, that's a good idea to use the same option to allocate both structures.

johnoel commented 3 years ago

Okay @yukio-takeuchi, it is ready for testing. Please update the branch and rebuild, then test. Using the -mip option will allocate memory for initial parameters. If the -mip option is not used or the total exceeds allocated, the memory will be dynamically allocated. I will look into using the existing -mno instead of adding another option -mip suggested by @Cole-Monnahan-NOAA.