DOI: 10.6084/m9.figshare.3558903
title: Supplement 1. C code for dynamic modeling of pup rearing decisions by adult female pinnipeds, plus simulations using optimal strategies.

description: File List Decs.h (MD5: 528c7f1ba0f30111b25f6ee6c28cbf57) BasOps.c (MD5: ddce0ab877626a5422089708499016ac) Starter.c (MD5: 99b47babbce05fa5e55368b70ea4a283) MassAndFoodConsts.c (MD5: 96ebe6417b6f9dd1491c0a757ea355d7) MainModel.c (MD5: c307f1b50022c0ac4355487454244898) SetSSVs.c (MD5: f7fc9d78395c25f800faf867d2952dbc) FindRs.c (MD5: 381885e2386aa17bce9102dd88d6c6fd) Sim.c (MD5: 13f9d4e6946439869903163674d90b12) Outputs.c (MD5: abb795b9d2aefc59b30a84cbd19ebc21) Acceleration.c (MD5: 68124585da06efa0981ae3cb8abfa6ac) Description There are 10 separate code files, designed to run in Unix compatible C. Decs.h contains declarations, structures and constants. Constants include UR (time to uterine repair); AminI (min time to independence); AdFemBodyMass (size of female in good condition; 2/3rds lean, 1/3rd fat); MaxD (time for independent pup to achieve 99.9% of adult foraging competence); ParamSet (see further below). Structures include CvI (records info on extent of cap and income breeding in model); GI (records fitnesses and decisions, as well as capital vs. income statistics); interimR (records fitness of offspring – located using FindRs.c – according to fat at release and time of year at release); StSpVars (houses info on state specific variables – like metabolism, survival, foraging parameters – so these can be passed around easily, using a single pointer); PupEnergetics (amount of energy in 1 pup store point, above and below current level of energy). Global variables: various output files and TotStates, Accel, Boost, MinimalOP, OneArea. BasOps.c contains basic operations for use in C programs. Basic operations include an array of self-explanatory functions: TimeToMidNight; absint; truncate; PosRND; absdouble; power; roundtoint; CreateFileP; OpenIPFile; commaprint (used to put commas in long numbers, so that they can be read more easily); FreeMem; TimeNow Starter.c contains code to clean arrays and structures; makes preliminary checks to see that nothing’s going to make program output absurd. Also, lists variables at top of output, so conditions can be seen. MassAndFoodConsts.c sets food parameters (depending on ParamSet; e.g., with ParamSet==1, all parameters are set randomly for Monte Carlo analysis); also sets mass related constants like BMR, size of stores, energy lost at birth (by mother) and gained at birth (by pup); also capable of adjusting food availability depending on seasonal abruptness. ParamSet includes: 1, parameters selected randomly as used to produce the main illustrated results; 2, parameters restricted to the high end of Qhalf (Qhalf &gt;120 where outcomes are more variable in terms of K), and (3) looks at a broader range of outcomes (ignoring legitimacy). MainModel.c is the dynamic program; contains the main() function. SetSSVs.c sets and checks food, metabolism and survival. FindRs.c contains the dynamic program for independent young; generates the reward function. Notice that FindRs.c has a constant called MemCheck. If that is set to YES, the code will stop if the local machine is inadequate for the array size. Sim.c contains code for the forwards simulation. Outputs.c contains all output functions, depending on whether output should be in columns or on a single line. Acceleration.c contains functions that can be used to accelerate convergence towards a stable state. If used, this attempts to predict the approximate magnitude of the fitnesses associated with each state and to adjust those fitnesses towards that goal, thereby reducing the running time of the dynamic program. This does not affect the conditions required for convergence, nor the fine scale changes that achieve that convergence (only the initial movement towards the convergent state).