fix(#22): Fix effort displacement for forced effort fisheries with MPAs #29
Merged
Conversation
eafulton
approved these changes
Apr 25, 2026
eafulton
left a comment
Contributor
There was a problem hiding this comment.
All makes sense so I think good to go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes 8 bugs preventing effort displacement from functioning correctly for forced effort (
readts_effort) fisheries with MPA spatial management. Also renamesOutDisplaceEffort.txttoOutDetailedEffort.txt.fixes #22
Bug fixes
Bug 1 (Beth's patch): mFC fisheries produce no harvest when flagdisplace is on.
The
Effortarray is used as a scalar multiplier for mFC catch but was initialized to 0.0 instead of 1.0. AddedflagMFCdisplace_idto identify mFC fisheries and initialize their Effort to 1.0. Modified the fishery activation check to prevent mFC fisheries with displacement from being skipped.Files:
atlantisboxmodel.h,atManageSetup.c,atManage.cBug 2:
CumDisplaceEffortaccumulated before Effort was calculated.The accumulation block ran early in
Manage_Calculate_Total_Effort()when Effort was still 0.0. Moved accumulation to after the main effort allocation loop, beforeCheck_CAP().File:
atManage.cBug 3:
CumDisplaceEffortaccumulation was in dead code path.Accumulation was in the
if(!bm->EffortModelsActive)block, butEffortModelsActiveis true when any fishery hasflageffortmodel > 0(including forced effort = 11). Placed accumulation in theEffortModelsActivecode path instead.File:
atManage.cBug 4: Wrong box index for MPA scaling in readts_effort branch.
MPA scale was read from
bm->MPA[bm->current_box][fishery_id]instead ofbm->MPA[ij][fishery_id].current_boxwas always 0, so every box got box 0's MPA value. Changed tobm->MPA[ij][fishery_id].File:
atManage.cBug 5:
orig_FCpressureset after MPA scaling instead of before.In the readts_effort branch,
orig_FCpressurewas assigned afterFCpressure *= mpa_scale, soEffort_Displacementcomputedorig_FCpressure - FCpressure = 0. Setorig_FCpressurebefore MPA scaling.File:
atManage.cBug 6:
Effort_Displacementnever triggered for MPA closures.All displacement logic was gated by
TempCPUE < mEff_thresh. For readts_effort fisheries, TempCPUE is never calculated (stays 0.0), and withmEff_thresh = 0.0the condition0.0 < 0.0is false. The manual (Section 15.6.1) states displacement should occur both for low CPUE and when MPAs are imposed. Added MPA as alternative trigger:if ((TempCPUE < mEff_thresh) || (MPA[ij][fishery_id] < 1.0)).File:
atManage.c(Effort_Displacement function)Bug 7: Inverted MPA check in displacement destination scoring.
Adjacent boxes were scored using
MPA_check = 1.0 - bm->MPA[nb][fishery_id]. For open boxes (MPA=1.0) this gives 0.0, zeroing out their biomass attractiveness. Changed toMPA_check = bm->MPA[nb][fishery_id]so open boxes retain full attractiveness.File:
atManage.c(Effort_Displacement function)Bug 8: Biomass comparison blocked MPA-imposed displacement.
Displacement was conditional on
maxfishthere > fishhere. Closed MPA boxes can have high target biomass, causing this condition to fail. The manual states displacement "will still occur" when MPAs are imposed. Separated MPA-imposed displacement (unconditional, find best open neighbour) from CPUE-triggered displacement (conditional on better biomass elsewhere).File:
atManage.c(Effort_Displacement function)Other changes
OutDisplaceEffort.txttoOutDetailedEffort.txt(atHarvestIO.c)Files changed
atlantisboxmodel.hflagMFCdisplace_idenum valueatManageSetup.cflagMFCdisplaceinitialization for mFC fisheriesatManage.cCumDisplaceEffortaccumulation;orig_FCpressureordering; MPA box index fix; fishery activation check; MPA trigger and destination scoring inEffort_DisplacementatHarvestIO.cValidation
Tested with:
Results:
Notes
flagmanageis used uninitialized in thereadts_effortbranch (pre-existing issue, not addressed in this PR)CumDisplaceEffortis accumulated beforeCheck_CAP()— if caps modify Effort, the diagnostic represents pre-cap values