Skip to content

Conversation

@tsmbland
Copy link
Collaborator

@tsmbland tsmbland commented Jan 16, 2026

Description

Slightly reworking things so that we can get debug output files in scenarios with unmet demand

Fixes #1083

Type of change

  • Bug fix (non-breaking change to fix an issue)
  • New feature (non-breaking change to add functionality)
  • Refactoring (non-breaking, non-functional change to improve maintainability)
  • Optimization (non-breaking change to speed up the code)
  • Breaking change (whatever its nature)
  • Documentation (improve or add documentation)

Key checklist

  • All tests pass: $ cargo test
  • The documentation builds and looks OK: $ cargo doc
  • Update release notes for the latest release if this PR adds a new feature or fixes a bug
    present in the previous release

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 18.75000% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.31%. Comparing base (25f3813) to head (090fa41).

Files with missing lines Patch % Lines
src/simulation/optimisation.rs 18.75% 12 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1085      +/-   ##
==========================================
+ Coverage   82.26%   82.31%   +0.05%     
==========================================
  Files          53       53              
  Lines        7416     7409       -7     
  Branches     7416     7409       -7     
==========================================
- Hits         6101     6099       -2     
+ Misses       1025     1021       -4     
+ Partials      290      289       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tsmbland tsmbland marked this pull request as ready for review January 16, 2026 14:39
Copilot AI review requested due to automatic review settings January 16, 2026 14:39
Copy link
Contributor

Copilot AI left a comment

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 enables debug file output for scenarios where dispatch optimization fails due to unmet demand. Previously, when the solver encountered an infeasible model, it would re-run with unmet demand variables to identify problematic markets but would not write debug CSV files. Now, debug information is written for both successful runs and infeasible scenarios before returning an error.

Changes:

  • Modified the run method signature from consuming self to borrowing &self
  • Ensured debug info is written in both success and infeasible cases
  • Inlined the get_markets_with_unmet_demand helper function into the main error handling path

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tsmbland tsmbland requested review from Aurashk and alexdewar January 16, 2026 14:43
Copy link
Collaborator

@alexdewar alexdewar left a comment

Choose a reason for hiding this comment

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

I think we should panic if the optimisation run with unmet demand variables fails, but other than that, LGTM!

markets_to_balance,
/*allow_unmet_demand=*/ true,
input_prices,
)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I actually think this should stay as an expect(), because this optimisation should be the same as the last one, but with unmet demand variables, so if we get an error here something has gone badly wrong.

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.

Dispatch results not being saved when there's unmet demand

3 participants