Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recruitment ycs syntax change 202208 #404

Merged
merged 19 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 7 additions & 7 deletions .github/workflows/Casal2_testsuite_modelrunner_archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ on:
## for a release idea linux is fairly easy
## for windows look at this example https://github.com/freenet/wininstaller-innosetup/actions/runs/768471071/workflow
jobs:
Compile-Casal2-linux:
Compile-Casal2-Linux:
# should run on linux based operating system
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
runs-on: ubuntu-20.04
timeout-minutes: 150
timeout-minutes: 180
env:
CC: gcc-10
CXX: g++-10
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
continue-on-error: true
uses: actions/[email protected]
with:
name: Casal2-linux-modelrunner
name: Casal2-Linux-modelrunner
path: TestModels/

- name: Run Unit Tests from frontend build
Expand All @@ -126,10 +126,10 @@ jobs:
continue-on-error: true
uses: actions/[email protected]
with:
name: Casal2-linux-unittest
name: Casal2-Linux-unittest
path: BuildSystem/Casal2/unittests.log
Base-R-Ubuntu:
needs: Compile-Casal2-linux
needs: Compile-Casal2-Linux
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
Expand All @@ -154,7 +154,7 @@ jobs:
uses: actions/[email protected]
with:
# Artifact name
name: Casal2-linux-modelrunner # optional
name: Casal2-Linux-modelrunner # optional
# Destination path
path: CheckTestModels # optional
## now run an R script that will check R-library compatible with exe output
Expand All @@ -164,7 +164,7 @@ jobs:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
# https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md
runs-on: windows-2019
timeout-minutes: 150
timeout-minutes: 180
steps:
- uses: actions/checkout@v2

Expand Down
2 changes: 1 addition & 1 deletion BuildSystem/Version.iss
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// WARNING: THIS FILE IS AUTOMATICALLY GENERATED BY doBuild version. DO NOT EDIT THIS FILE
AppVersion='v22.08 (2022-08-24)'
AppVersion='v22.08 (2022-08-30)'
24 changes: 23 additions & 1 deletion BuildSystem/buildtools/classes/ModelRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def start(self):
success_count = 0
fail_count = 0
##estimation_dir_list = {"Simple", "SBW"} # requires a config.csl2 file (uses whatever minimiser is defined)
estimation_betadiff_dir_list = {"TwoSex", "TwoSexHybridMortality", "SBW", "Simple","ComplexTag", "SexedLengthBased"} # requires a config-betadiff.csl2 file
estimation_betadiff_dir_list = {"TwoSex", "TwoSexHybridMortality", "SBW", "Simple","ComplexTag", "SexedLengthBased", "BCO_tc", "HAK_tc", "HOK_tc", "LIN_tc", "ORH_tc", "SBW_tc", "SCI_tc"} # requires a config-betadiff.csl2 file
estimation_gammadiff_dir_list = {"TwoSex", "TwoSexHybridMortality", "SBW", "Simple", "SexedLengthBased"} # requires a config-gammadiff.csl2 file
estimation_adolc_dir_list = {"TwoSex", "TwoSexHybridMortality", "SBW", "Simple", "SexedLengthBased"} # requires a config-adolc.csl2 file
simulate_dash_i_dir_list = {"ORH3B", "SimAllObs"} # if you change this you will need to formulate the report or python code below, not very general.
Expand Down Expand Up @@ -83,8 +83,10 @@ def start(self):
print('[OK] - ' + folder + ' in ' + str(round(elapsed, 2)) + ' seconds')
success_count += 1
os.chdir(cwd)

# test -i functionality
for folder in run_dash_i_dir_list:
start = time.time()
os.chdir("../TestModels/" + folder)
if os.system(f"{exe_path} -r -i pars.out > run.log 2> run.err") != EX_OK:
elapsed = time.time() - start
Expand All @@ -97,8 +99,10 @@ def start(self):
print('[OK] - ' + folder + ' -i run in ' + str(round(elapsed, 2)) + ' seconds')
success_count += 1
os.chdir(cwd)

# test -I functionality
for folder in run_dash_I_dir_list:
start = time.time()
os.chdir("../TestModels/" + folder)
if os.system(f"{exe_path} -r -I pars.out > run.log 2> run.err") != EX_OK:
elapsed = time.time() - start
Expand All @@ -111,16 +115,20 @@ def start(self):
print('[OK] - ' + folder + ' -I run in ' + str(round(elapsed, 2)) + ' seconds')
success_count += 1
os.chdir(cwd)

# test -s functionality
for folder in simulate_dash_i_dir_list:
start = time.time()
os.chdir("../TestModels/" + folder)

# create sim directory casal will fail if this doesn't exist
if not os.path.exists("sim"):
os.mkdir("sim")
## first delete any previous simulated observations from previous model runners
for filename in os.listdir('sim'):
file_path = os.path.join('sim', filename)
os.remove(file_path)

if os.system(f"{exe_path} -s 10 -i samples.1 > multi_sim.log 2> multi_sim.err") != EX_OK:
elapsed = time.time() - start
print('[FAILED] - ' + folder + ' -s run in ' + str(round(elapsed, 2)) + ' seconds')
Expand All @@ -131,6 +139,7 @@ def start(self):
elapsed = time.time() - start
print('[OK] - ' + folder + ' -s run in ' + str(round(elapsed, 2)) + ' seconds')
success_count += 1

if folder == "ORH3B":
# check the correct files were generated
if not os.path.exists("sim/CPUEandes.1_01"):
Expand All @@ -151,8 +160,10 @@ def start(self):
print('[FAILED] - ' + folder + ' -s run in ' + str(round(elapsed, 2)) + ' expected simulated file sim/sim_all_obs.1_10')
fail_count += 1
os.chdir(cwd)

# test -M mpd.log functionality
for folder in resume_mcmc_from_mpd_dir_list:
start = time.time()
os.chdir("../TestModels/" + folder)
if os.system(f"{exe_path} -E mpd.log > estimate.log 2> esimate.err") != EX_OK:
elapsed = time.time() - start
Expand All @@ -164,6 +175,8 @@ def start(self):
elapsed = time.time() - start
print('[OK] - ' + folder + ' -E mpd.log run in ' + str(round(elapsed, 2)) + ' seconds')
success_count += 1

start = time.time()
if os.system(f"{exe_path} -M mpd.log > mcmc.log 2> mcmc.err ") != EX_OK:
elapsed = time.time() - start
print('[FAILED] - ' + folder + ' -M mpd.log run in ' + str(round(elapsed, 2)) + ' seconds')
Expand All @@ -175,8 +188,10 @@ def start(self):
print('[OK] - ' + folder + ' -M mpd.log run in ' + str(round(elapsed, 2)) + ' seconds')
success_count += 1
os.chdir(cwd)

# test -R mpd.log
for folder in resume_mcmc_dir_list:
start = time.time()
os.chdir("../TestModels/" + folder)
if os.system(f"{exe_path} -R mpd.log --objective-file objectives.1 --sample-file samples.1 > mcmc.log 2>&1") != EX_OK:
elapsed = time.time() - start
Expand All @@ -189,8 +204,10 @@ def start(self):
print('[OK] - ' + folder + ' -R run in ' + str(round(elapsed, 2)) + ' seconds')
success_count += 1
os.chdir(cwd)

# test -e functionality
for folder in estimation_betadiff_dir_list:
start = time.time()
os.chdir("../TestModels/" + folder)
if os.system(f"{exe_path} -e -g 20 -c config_betadiff.csl2 > estimate_betadiff.log 2> estimate_betadiff.err") != EX_OK:
elapsed = time.time() - start
Expand All @@ -203,7 +220,9 @@ def start(self):
print('[OK] - ' + folder + ' betadiff estimation in ' + str(round(elapsed, 2)) + ' seconds')
success_count += 1
os.chdir(cwd)

for folder in estimation_gammadiff_dir_list:
start = time.time()
os.chdir("../TestModels/" + folder)
if os.system(f"{exe_path} -e -g 20 -c config_gammadiff.csl2 > estimate_gammadiff.log 2> estimate_gammadiff.err") != EX_OK:
elapsed = time.time() - start
Expand All @@ -216,7 +235,9 @@ def start(self):
print('[OK] - ' + folder + ' gammadiff estimation in ' + str(round(elapsed, 2)) + ' seconds')
success_count += 1
os.chdir(cwd)

for folder in estimation_adolc_dir_list:
start = time.time()
os.chdir("../TestModels/" + folder)
if os.system(f"{exe_path} -e -g 20 --config config_adolc.csl2 > estimate_adolc.log 2> estimate_adolc.err") != EX_OK:
elapsed = time.time() - start
Expand All @@ -229,6 +250,7 @@ def start(self):
print('[OK] - ' + folder + ' adolc estimation in ' + str(round(elapsed, 2)) + ' seconds')
success_count += 1
os.chdir(cwd)

print('')
print('Total Models: ' + str(success_count + fail_count))
print('Failed Models: ' + str(fail_count))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ type recruitment_beverton_holt
categories stock
proportions 1
b0 75000
standardise_ycs_years 1975 1976 1977
ycs_values 1.00 1.02472 1.04658
ycs_years 1974:1976
standardise_years 1976:1978
recruitment_multipliers 1.00 1.02472 1.04658
steepness 0.9
ssb biomass_t1
age 1
Expand Down Expand Up @@ -145,7 +144,7 @@ b 3.288
const std::string avg_diff_fail = R"(
@parameter_transformation ycs_avg_diff
type average_difference
parameters process[Recruitment].ycs_values{1975} process[Recruitment].ycs_values{1976}
parameters process[Recruitment].recruitment_multipliers{1976} process[Recruitment].recruitment_multipliers{1977}

@estimate ycs_avg
type uniform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ class AddressableTransformation : public niwa::base::Object {
void set_single_values_for_multiple_maps(vector<Double> values);
void set_single_values_for_multiple_vectors(vector<Double> values);
void set_single_values_for_multiple_string_maps(vector<Double> values);
// how is process[Recruit].ycs_values{2013} treated? is this a single value or a map?
// how is process[Recruit].recruitment_multipliers{2013} treated? is this a single value or a map?
// and process[Instan_mort].m{male} treated? is this a single value or a map?
// I want these to be single values is that easy?

// These should only be used for special transformations which operate on an entire map/subset or vector/subset vector
// i.e only on process[Recruit].ycs_values or process[Recruit].ycs_values{1990:2013}
// i.e only on process[Recruit].recruitment_multipliers or process[Recruit].recruitment_multipliers{1990:2013}
// or
// selectivity[all_values_bounded].v or selectivity[all_values_bounded].v{1:5}
// We can catch these from the above separate case as if we
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ type recruitment_beverton_holt
categories stock
proportions 1
b0 75000
ycs_values 1.3464 1.3797 1.4091 1.4315 1.4447 1.4468 1.4345 1.4047 1.3708 1.3502 0.5748 0.6419 0.7007 0.5146 0.7098 0.5994 0.9078 1.3517 1.0249 0.8798 0.7981 0.6579 0.4325 0.4085 0.2981 0.4483 0.2961 0.4426 1.2456 0.7079 0.5855 0.2521 0.4138 0.3496 0.3109 0.3503 4.0392 4.0392
ycs_years 1974:2011
recruitment_multipliers 1.3464 1.3797 1.4091 1.4315 1.4447 1.4468 1.4345 1.4047 1.3708 1.3502 0.5748 0.6419 0.7007 0.5146 0.7098 0.5994 0.9078 1.3517 1.0249 0.8798 0.7981 0.6579 0.4325 0.4085 0.2981 0.4483 0.2961 0.4426 1.2456 0.7079 0.5855 0.2521 0.4138 0.3496 0.3109 0.3503 4.0392 4.0392
steepness 0.9
ssb biomass_t1
age 1
Expand Down Expand Up @@ -204,7 +203,7 @@ b 3.288

@parameter_transformation simplex_ycs
type simplex
parameters process[Recruitment].ycs_values
parameters process[Recruitment].recruitment_multipliers
sum_to_one false
prior_applies_to_restored_parameters true

Expand All @@ -225,7 +224,7 @@ TEST_F(InternalEmptyModel, AddressableTransformations_simplex_validate_simplex_c
vector<Double>* simplex = model_->objects().GetAddressableVector("parameter_transformation[simplex_ycs].simplex");
vector<Double> result = {0.3068, 0.3422, 0.3759, 0.4059, 0.4308, 0.4493, 0.4587, 0.4562, 0.4506, 0.4552, -0.4109, -0.3105, -0.2308, -0.5567, -0.2442, -0.4285, -0.014, 0.4078, 0.1384, -0.0151, -0.1188, -0.3286, -0.7825, -0.8793, -1.2468, -0.8848, -1.3637, -1.0216, 0.0146, -0.6021, -0.8672, -1.8379, -1.48, -1.8324, -2.2012, -2.4449, 0};
vector<Double> ycs_vals_in_config = {1.3464, 1.3797, 1.4091, 1.4315, 1.4447, 1.4468, 1.4345, 1.4047, 1.3708, 1.3502, 0.5748, 0.6419, 0.7007, 0.5146, 0.7098, 0.5994, 0.9078, 1.3517, 1.0249, 0.8798, 0.7981, 0.6579, 0.4325, 0.4085, 0.2981, 0.4483, 0.2961, 0.4426, 1.2456, 0.7079, 0.5855, 0.2521, 0.4138, 0.3496, 0.3109, 0.3503, 4.0392, 4.0392};
map<unsigned, Double>* restored_ycs_values = model_->objects().GetAddressableUMap("process[Recruitment].ycs_values");
map<unsigned, Double>* restored_recruitment_multipliers_values = model_->objects().GetAddressableUMap("process[Recruitment].recruitment_multipliers");
// This result was generated against the following R-code
// Assuming you copy the config about and run casal2 -r > run.out
// With the added @reports
Expand Down Expand Up @@ -259,7 +258,7 @@ TEST_F(InternalEmptyModel, AddressableTransformations_simplex_validate_simplex_c
EXPECT_NEAR(result[i], (*simplex)[i], 1e-3) << " with i = " << i + 1;
}
unsigned counter = 0;
for(auto ycs_val : (*restored_ycs_values)) {
for(auto ycs_val : (*restored_recruitment_multipliers_values)) {
EXPECT_NEAR(ycs_vals_in_config[counter], ycs_val.second, 1e-3) << " year = " << ycs_val.first << " counter = " << counter;
++counter;
}
Expand Down
5 changes: 2 additions & 3 deletions CASAL2/source/AgeLengths/Age/Data.Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ proportions 0.5 0.5
r0 5e6
age 2
steepness 0.9
ycs_values 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
recruitment_multipliers 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
ssb ssb
ycs_years 1973:2000
standardise_ycs_years 1973:1999
standardise_years 1975:2001

@mortality halfm
type constant_rate
Expand Down
5 changes: 2 additions & 3 deletions CASAL2/source/AgeLengths/AgeLength.Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ type recruitment_beverton_holt
categories stock
proportions 1
b0 5.18767e+008
ycs_years 1974:1976
standardise_ycs_years 1974:1976
ycs_values 1.00 1.00 1.00
standardise_years 1975:1977
recruitment_multipliers 1.00 1.00 1.00
steepness 0.9
ssb biomass_t1
age 1
Expand Down
9 changes: 4 additions & 5 deletions CASAL2/source/AgeWeights/Age/Data.Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,16 @@ type recruitment_beverton_holt_with_deviations
categories Stock
proportions 1.0
b0 5973.9
last_year_with_no_bias 1986
first_year_with_bias 1986
last_year_with_bias 2005
first_recent_year_with_no_bias 2005
last_year_with_no_bias 1987
first_year_with_bias 1987
last_year_with_bias 2006
first_recent_year_with_no_bias 2006
b_max 1.0
deviation_values 0.161055491247 0.0935823574532 -0.454148603651 -0.143755692424 -0.979662527968 1.70885246646 0.207878584523 -0.142998000652 0.448480496158 -1.25142717617 0.621050539438 0.0732265269830 0.0247523483886 0.137793954591 0.199439856167 -0.701101119095 0.613584736138 -0.103102553946 -0.101487357908 -0.412014325737
steepness 0.5792984
ssb SSB
age 1
sigma_r 0.6
deviation_years 1985:2004

@process Ageing
type ageing
Expand Down
5 changes: 2 additions & 3 deletions CASAL2/source/Catchabilities/Common/Nuisance.Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ type recruitment_beverton_holt
categories stock
proportions 1
b0 52583
standardise_ycs_years 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
ycs_values 1.00 1.02472 1.04658 1.06324 1.07299 1.07458 1.06541 1.04328 1.01815 1.00285 0.426938 0.476756 0.520428 0.382199 0.527158 0.445187 0.67427 1.00397 0.761247 0.653433 0.592745 0.488619 0.321246 0.303421 0.221372 0.33299 0.219917 0.328752 0.925172 0.525766 0.434871 0.18722 0.307342 0.259689 0.230941 0.260211 3 3
standardise_years 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010
recruitment_multipliers 1.00 1.02472 1.04658 1.06324 1.07299 1.07458 1.06541 1.04328 1.01815 1.00285 0.426938 0.476756 0.520428 0.382199 0.527158 0.445187 0.67427 1.00397 0.761247 0.653433 0.592745 0.488619 0.321246 0.303421 0.221372 0.33299 0.219917 0.328752 0.925172 0.525766 0.434871 0.18722 0.307342 0.259689 0.230941 0.260211 3 3
steepness 0.9
ssb biomass_t1
age 1
ycs_years 1974:2011

@process Ageing
type ageing
Expand Down
7 changes: 3 additions & 4 deletions CASAL2/source/Observations/Age/Abundance/Process.Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @date 26/02/2014
* @section LICENSE
*
* Copyright NIWA Science �2014 - www.niwa.co.nz
* Copyright NIWA Science �2014 - www.niwa.co.nz
*
*/
#ifdef TESTMODE
Expand Down Expand Up @@ -72,10 +72,9 @@ proportions 0.5 0.5
r0 5e6
age 2
steepness 0.9
ycs_values 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
recruitment_multipliers 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
ssb ssb
ycs_years 1973:2000
standardise_ycs_years 1973:1999
standardise_years 1975:2001

@mortality halfm
type constant_rate
Expand Down
Loading