ices-eg / wg_HAWG

Herring Assessment Working Group for the Area South of 62°N
0 stars 7 forks source link

retro(), looi() should take advantage of reduced.cfg #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Run retro on stock assessment trimming off one year at a time. Smart way to do 
this is to use the output parameters from the assessment run as input 
parameters to the retrospective.

Original issue reported on code.google.com by Niels.Hintzen on 3 Nov 2011 at 9:47

GoogleCodeExporter commented 9 years ago
Comment below from Anders

First you run it as is, which is with a 'reduced.cfg' file that may look like:

# This allows to exclude data in ways customized for retrospective runs
# The following specifies one integer for each fleet (catches and surveys)
# if:
#     0: all data for that fleet is used
#    -1: all data for that fleet is excluded
#     n: n is a positive integer the corresponding fleet's data is reduced
#        by n years starting from the most recent year.  
0 0 0

Then you edit that to:

# This allows to exclude data in ways customized for retrospective runs
# The following specifies one integer for each fleet (catches and surveys)
# if:
#     0: all data for that fleet is used
#    -1: all data for that fleet is excluded
#     n: n is a positive integer the corresponding fleet's data is reduced
#        by n years starting from the most recent year.  
1 1 1

Then you edit that to:

# This allows to exclude data in ways customized for retrospective runs
# The following specifies one integer for each fleet (catches and surveys)
# if:
#     0: all data for that fleet is used
#    -1: all data for that fleet is excluded
#     n: n is a positive integer the corresponding fleet's data is reduced
#        by n years starting from the most recent year.  
2 2 2

and so on.

Can be done via R code like (assuming the 0-run is already done):

make.retro<-function(){
  setwd(sam.home)
  source('conf/common.R')
  system('cp -r run/* runRETRO')
  setwd('runRETRO')
  red<-as.numeric(read.table('reduced.cfg')[1,])
  RETRO<-list()
  for(i in 1:10){
    cat(paste('Now running ',i,' out of ', 10, ' retrospective runs.\n', sep=''), file='header.txt')
    red <- rep(i,length(red))
    cat(red,file='reduced.cfg')
    system('./ssass -noinit')
    RETRO[[i]]<-read.fit('ssass')[c('years','fbar','ssb')]
  }
  setwd(paste(sam.home,'/run',sep=''))
  save(RETRO,file='RETRO.RData')
  setwd(sam.home)
}

But via a makefile on a 10 kernel system you would first run the original run, 
then
all ten retros side by side (following the simstudy makefile example I once 
gave you).

Original comment by markpayn...@gmail.com on 4 Nov 2011 at 7:34

GoogleCodeExporter commented 9 years ago

Original comment by markpayn...@gmail.com on 4 Nov 2011 at 8:03

GoogleCodeExporter commented 9 years ago
More details - a reply from Anders and a reply to the reply. 

Hi Anders and Casper,
(with cc to Niels)

Cheers for the reply - that makes sense, but I have a few questions:

1. Is the reuse of parameters from the previous full assessment run taken care 
of automatically, based on what is sitting in the run directory and what the 
reduced.cfg tells it to do?

Yes exactly. 

2. Parallelising across multiple cores: based on qn 1 and what you say below, 
it sounds like you would need run the full assessment first, then copy the full 
assessment files to 10 separate directories, modify the reduced.cfg in each of 
those, and then run each assessment again in its own directory. Is this correct?

Yes, but you don't really need to copy all of it just the *.par file (if I 
recall correctly)

3. I haven't looked too closely at how reduced.cfg works, but it sounds like 
you can also use it for LOI and LOO runs ie leave-one-in, leave-one-out in the 
same manner ie do a full run, then modify the reduced.cfg by setting the 
appropriate fleet to -1, and it will reuse the results of the first assessment 
as initial conditions. Is this correct?

Yes, this and retro are exactly what I designed it for.

There is also a related question about the use of initialisation parameters. If 
we have two models that we want to compare (e.g. with different parameter 
bindings, for example), is there any way that we can reuse the results of one 
assessment as initialisations for the other? Or does it only work in situations 
where the number of parameters is constant, but the data changes?

It all depends on how different. I tried to make it fairly automatic. It is all 
controlled by the ugly macro 'assignInit' in the beginning of the source file. 
Again I don't see any need to change anything here, but you may, and that is 
OK.  One thing you should be careful about is that you don't always want to 
just skip the same number of years from each source - that could be wrong if 
e.g. a survey is not present in the last couple of years. 

Cheers,

Mark

Original comment by markpayn...@gmail.com on 4 Nov 2011 at 8:46

GoogleCodeExporter commented 9 years ago

Original comment by markpayn...@gmail.com on 8 Nov 2011 at 3:41

GoogleCodeExporter commented 9 years ago

Original comment by markpayn...@gmail.com on 8 Nov 2011 at 3:41

GoogleCodeExporter commented 9 years ago

Original comment by markpayn...@gmail.com on 1 Mar 2012 at 9:21

GoogleCodeExporter commented 9 years ago
Implemented through the use of pin files, rather than reduced.cfg

Original comment by markpayn...@gmail.com on 17 Aug 2012 at 3:57