[ADMB Users] a conditional statement under PARAMETER_SECTION

Jim Ianelli Jim.Ianelli at noaa.gov
Sat Mar 19 12:41:52 PDT 2011


Hi Saang-Yoon,

In those cases I have the conditional statements in the data section and
linked to an integer that's used as phase.

E.g., 

DATA_SECTION
...
  init_int phase_mypar1
  init_int phase_mypar2
...
  !! if (phase_mypar1<0) 
  !!   phase_mypar2=abs(phase_mypar1);
  !! else 
  !!   phase_mypar2= -phase_mypar1;
  // Shuts off parameters conditional on the 1st one...
...

PARAMETER_SECTION
...
  init_number par1(phase_mypar1) 
  init_number par2(phase_mypar2)
...

Could that logic help?

Cheers,
Jim

James Ianelli
REFM Division, Alaska Fisheries Science Center
National Marine Fisheries Service, National Oceanic and Atmospheric
Administration
7600 Sand Point Way NE
Seattle WA 98115

Ph. 206 526 6510


| -----Original Message-----
| From: users-bounces at admb-project.org [mailto:users-bounces at admb-
| project.org] On Behalf Of Saang-Yoon
| Sent: Saturday, March 19, 2011 12:15 PM
| To: users at admb-project.org
| Subject: Re: [ADMB Users] a conditional statement under
| PARAMETER_SECTION
| 
| Hello, Steve.
| Thank you very much for your prompt response, which is helpful.  By the
way,
| the conditional statement in your example is used below
| "init_bounded_matrix_vector sel_par".   Now if we want to ignore the
| parameter vector, "sel_par" by an option, then we may want to put the
| parameter declaration ("init_bounded_matrix_vector sel_par") under the
| optional statement, which would lead to a compile/link error.  I wonder
about
| how you or others get around in "one" TPL file.  Again thank you.
| Saang-Yoon
| 
| 
| On Mar 19, 2:35 pm, Steve Martell <s.mart... at fisheries.ubc.ca> wrote:
| > Sanng-Yoon,
| >
| > Statements such as this work fine for me in the PARAMETER_SECTION
| >
| >         //Selectivity parameters (A very complicated ragged array)
| >         init_bounded_matrix_vector
| > sel_par(1,ngear,1,jsel_npar,1,isel_npar,-5.,5.,sel_phz);
| >         LOC_CALCS
| >                 //initial values for logistic selectivity parameters
| >                 //set phase to -1 for fixed selectivity.
| >                 for(int k=1;k<=ngear;k++)
| >                 {
| >                         if( isel_type(k)==1 || isel_type(k)==6 )
| >                         {
| >                                 sel_par(k,1,1) = log(ahat(k));
| >                                 sel_par(k,1,2) = log(ghat(k));
| >                         }
| >                 }
| >         END_CALCS
| >
| > On 2011-03-19, at 11:31 AM, Saang-Yoon wrote:
| >
| > > Hi, all.
| > > Whenever I put a conditional statement (e.g., if - else) under
| > >PARAMETER_SECTION, I run into an error.   I wonder whether ADMB is
| > >designed not to allow a conditional statement under
| PARAMETER_SECTION
| > >ever.  Sometimes I need to consider or ignore a parameter, depending
| > >on a model assumption.  If you were, how would you get around in
| > >ADMB?   Temporarily I make two TPL files (e.g., two EXE files) by the
| > >assumption.  But I suspect some of you may get around in "one" TPL
| > >file (i.e., "one" EXE file).
| > > Saang-Yoon
| > > _______________________________________________
| > > Users mailing list
| > > Us... at admb-project.org
| > >http://lists.admb-project.org/mailman/listinfo/users
| >
| > _______________________________________________
| > Users mailing list
| > Us... at admb-project.orghttp://lists.admb-project.org/mailman/listinfo/u
| > sers
| _______________________________________________
| Users mailing list
| Users at admb-project.org
| http://lists.admb-project.org/mailman/listinfo/users




More information about the Users mailing list