[Bug]: Automatically work around "no active parameters" error
Imported from redmine, Issue #82472 Opened by @iantaylor-NOAA on 2020-08-31 Status when imported: New
Low priority issue moved from documentation issue #51300
When no parameters are assigned to phase 1, SS crashes with this warning from ADMB:
Estimating...please wait... 0 0 -log(L): 0 between Error -- no active parameters. There must be at least 1
When this occurs while manually changing phases in the control file, it's easy to understand and fix. But it also occurs when users estimate only the SR_LN(R0) parameter in phase 1 and then run a likelihood profile over this parameter. The r4ss function SS_profile() facilitates this by iteratively changing the initial value and setting the phase of the profile parameter to be negative, potentially removing the only parameter in phase 1 from estimation and also making it hard for users to know where the error is coming from since the user is separated from the re-phasing.
Potential solutions could include:
- an automatic fix by subtracting 1 (or other value depending on the minimum phase number) from the phase of all active parameters (with a warning message saying what's being done)
- check for the issue and produce a more informative warning with guidance on how to deal with it
Either of those solutions could be implemented in r4ss or SS, but I think doing it in SS would be more complete and ensure that it worked for everyone whether the problem was caused by an r4ss function or not.
comment from @RickMethot on 2020-09-01: When we use maxphase=0, no parameters are active, so SS turns on estimation of a dummy parameter. You see it as first parameter in ss.par.
I could change such that it always is active in phase 1, rather than only being active when turn_off_phase (actual name for what we call maxphase) =0 right now, the code is this: !!// SS_Label_Info_1.2.1 #Set up a dummy datum for use when max phase = 0 number dummy_datum int dummy_phase !! dummy_datum=1.; !! if(Turn_off_phase<=0) {dummy_phase=0;} else {dummy_phase=-6;}
in prelim: // SS_Label_Info_6.1.2 #Initialize the dummy parameter as needed if(Turn_off_phase<=0) {dummy_parm=0.5;} else {dummy_parm=1.0;}
then in obj_fun obj_fun += square(dummy_datum-dummy_parm);
comment from @iantaylor-NOAA on 2020-09-01: I like the dummy parameter solution which simpler with less confusing for anyone who is paying attention to what's happening in any given phase. Let me know if you'd like help implementing this.