Skip to content

fix(#22): Fix effort displacement for forced effort fisheries with MPAs #29

Merged
eafulton merged 2 commits into
devfrom
fix-effort-displacement
Apr 25, 2026
Merged

fix(#22): Fix effort displacement for forced effort fisheries with MPAs #29
eafulton merged 2 commits into
devfrom
fix-effort-displacement

Conversation

@jacobkasper

@jacobkasper jacobkasper commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes 8 bugs preventing effort displacement from functioning correctly for forced effort (readts_effort) fisheries with MPA spatial management. Also renames OutDisplaceEffort.txt to OutDetailedEffort.txt.

fixes #22

Bug fixes

Bug 1 (Beth's patch): mFC fisheries produce no harvest when flagdisplace is on.
The Effort array is used as a scalar multiplier for mFC catch but was initialized to 0.0 instead of 1.0. Added flagMFCdisplace_id to 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.c

Bug 2: CumDisplaceEffort accumulated 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, before Check_CAP().
File: atManage.c

Bug 3: CumDisplaceEffort accumulation was in dead code path.
Accumulation was in the if(!bm->EffortModelsActive) block, but EffortModelsActive is true when any fishery has flageffortmodel > 0 (including forced effort = 11). Placed accumulation in the EffortModelsActive code path instead.
File: atManage.c

Bug 4: Wrong box index for MPA scaling in readts_effort branch.
MPA scale was read from bm->MPA[bm->current_box][fishery_id] instead of bm->MPA[ij][fishery_id]. current_box was always 0, so every box got box 0's MPA value. Changed to bm->MPA[ij][fishery_id].
File: atManage.c

Bug 5: orig_FCpressure set after MPA scaling instead of before.
In the readts_effort branch, orig_FCpressure was assigned after FCpressure *= mpa_scale, so Effort_Displacement computed orig_FCpressure - FCpressure = 0. Set orig_FCpressure before MPA scaling.
File: atManage.c

Bug 6: Effort_Displacement never 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 with mEff_thresh = 0.0 the condition 0.0 < 0.0 is 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 to MPA_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

  • Renamed output file from OutDisplaceEffort.txt to OutDetailedEffort.txt (atHarvestIO.c)

Files changed

File Changes
atlantisboxmodel.h Added flagMFCdisplace_id enum value
atManageSetup.c flagMFCdisplace initialization for mFC fisheries
atManage.c CumDisplaceEffort accumulation; orig_FCpressure ordering; MPA box index fix; fishery activation check; MPA trigger and destination scoring in Effort_Displacement
atHarvestIO.c Output filename rename

Validation

Tested with:

  • Single box closure (box 37 fully closed for FCDD)
  • Adjacent two-box closure (boxes 37, 39 for FCDD)
  • Multi-fishery closure (boxes 5, 33, 34 for MIXD; boxes 37, 39 for FCDD)

Results:

  • Effort conservation ratio ≈ 1.0 across all tests (total effort preserved, only redistributed)
  • Displaced effort correctly redistributes to adjacent open boxes with highest target species biomass
  • Closed adjacent boxes correctly skipped as displacement destinations
  • mFC fisheries unaffected (harvest preserved)

Notes

  • flagmanage is used uninitialized in the readts_effort branch (pre-existing issue, not addressed in this PR)
  • CumDisplaceEffort is accumulated before Check_CAP() — if caps modify Effort, the diagnostic represents pre-cap values

@jacobkasper jacobkasper changed the title Fix effort displacement for forced effort fisheries with MPAs (closes… Fix effort displacement for forced effort fisheries with MPAs (closes issue #22) Apr 9, 2026
@jacobkasper jacobkasper requested a review from eafulton April 14, 2026 14:34
@andybeet andybeet changed the title Fix effort displacement for forced effort fisheries with MPAs (closes issue #22) fix(#22): Fix effort displacement for forced effort fisheries with MPAs Apr 16, 2026

@eafulton eafulton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All makes sense so I think good to go

@eafulton eafulton merged commit d6b8cc4 into dev Apr 25, 2026
1 check passed
@andybeet andybeet mentioned this pull request Apr 27, 2026
4 tasks
@andybeet andybeet deleted the fix-effort-displacement branch April 28, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Effort displacement does not function for forced effort fisheries with MPAs

2 participants