Skip to content

FIBERALLOC-64: Charge the assignment arc cost to the objective only once - #31

Merged
monodera merged 1 commit into
masterfrom
tickets/FIBERALLOC-64
Aug 26, 2026
Merged

FIBERALLOC-64: Charge the assignment arc cost to the objective only once#31
monodera merged 1 commit into
masterfrom
tickets/FIBERALLOC-64

Conversation

@monodera

@monodera monodera commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

tcost accumulates vis_cost, cobraMoveCost and blackDotPenalty in turn, but f*tcost was added to the objective both before and after the black-dot term, so the visibility and cobra-move contributions were counted twice. An arc cost 2*(vis_cost + cobraMoveCost) + blackDotPenalty instead of (vis_cost + cobraMoveCost) + blackDotPenalty.

History

The duplicate dates back to dd6695f ("first iteration for black spot proximity penalty function"), which introduced the black-spot penalty along with a second accumulation rather than moving the existing one. Before that commit there was exactly one accumulation, so this is a copy-paste leftover rather than deliberate weighting.

Impact

Affects every backend (Gurobi, HiGHS, PuLP). The visibility and cobra-move terms carried double their configured weight relative to nonObservationCost, partialObservationCost and blackDotPenalty, so the optimizer traded them off differently than the configuration intends.

Note for review

This changes results wherever vis_cost or cobraMoveCost is nonzero. Correcting it effectively halves those terms relative to the other costs, and fiber assignments will shift. If the cost functions were tuned empirically against the current behaviour, we may prefer to rescale them alongside this fix rather than take the correction on its own.

Testing

python -m py_compile passes, and the single remaining accumulation now runs after all three cost terms are summed into tcost. The solver was not run end to end, so the effect on actual fiber assignments is unverified here and needs scientific validation.

Refs FIBERALLOC-64

🤖 Generated with Claude Code

tcost accumulates vis_cost, cobraMoveCost and blackDotPenalty in turn, but
f*tcost was added to the objective both before and after the black-dot term,
so the visibility and cobra-move contributions were counted twice: an arc
cost 2*(vis_cost + cobraMoveCost) + blackDotPenalty instead of
(vis_cost + cobraMoveCost) + blackDotPenalty.

The duplicate dates back to dd6695f, which introduced the black-spot penalty
along with a second accumulation rather than moving the existing one.

Note that this changes results wherever vis_cost or cobraMoveCost is nonzero:
both now carry their configured weight relative to nonObservationCost,
partialObservationCost and blackDotPenalty instead of twice that weight.

FIBERALLOC-64

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CsehUfGABWV8uBhVQWUBet
@monodera
monodera requested review from mreineck and a lite review from Copilot August 25, 2026 08:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an objective-function accounting bug in buildProblem() where the assignment arc cost was added to the optimization objective twice, causing vis_cost and cobraMoveCost to be double-counted relative to other cost terms.

Changes:

  • Removes the earlier prob.cost += f*tcost so the arc cost is charged only once.
  • Ensures the single remaining objective accumulation occurs after vis_cost, cobraMoveCost, and blackDotPenalty have all been summed into tcost.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mreineck

Copy link
Copy Markdown
Contributor

Ouch, that was a really stupid copy/paste mistake on my part!
Since this affects results in potentially many cases, I'm not sure how we should proceed with merging? I can bring this up in the ICS/PFI+MCS telecon ... do you think this is enough?

@monodera

Copy link
Copy Markdown
Contributor Author

I'm not sure how large the impact is. In addition to the ICS/PFI+MCS telecon (I'm not a part of it), you can also tell people in the pfs-netflow-users channel on Slack about it? I guess that the SSP WG representatives are more concerned about the change.

@mreineck

Copy link
Copy Markdown
Contributor

Good point, I'll do that!
I will also make an entry in the ChangeLog referring to this (also for FIBERALLOC-63).

@mreineck mreineck 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.

I'm perfectly happy with the change!

Given the lack of objections on Slack, I think this can now be merged.

@monodera
monodera merged commit acc9c44 into master Aug 26, 2026
1 check passed
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.

3 participants