Skip to content

Add minimum node state constraint #1204

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

Merged
merged 11 commits into from
May 7, 2025
Merged

Add minimum node state constraint #1204

merged 11 commits into from
May 7, 2025

Conversation

datejada
Copy link
Member

@datejada datejada commented May 6, 2025

This pull request introduces a new constraint, constraint_min_node_state, to ensure a minimum storage content for nodes in the SpineOpt model. It includes updates to the codebase, documentation, and tests to support this new functionality. Below are the most important changes grouped by theme:

New Constraint Implementation:

  • Added the constraint_min_node_state implementation in src/constraints/constraint_min_node_state.jl, including the constraint logic, indices, and helper functions. This ensures that the node_state variable meets a minimum threshold based on storage capacity and node_state_min.

Integration into SpineOpt Workflow:

  • Included the new constraint file constraint_min_node_state.jl in src/SpineOpt.jl.
  • Updated function _add_constraints! in src/run_spineopt_basic.jl to add the new constraint during the model-building process.

Data Preprocessing:

  • Added a new function, generate_node_state_lower_limit, in src/data_structure/preprocess_data_structure.jl to compute the lower limit for node_state based on input parameters.
  • Updated the preprocessing pipeline in function preprocess_data_structure to include the generation of node_state_lower_limit.

Variable Updates:

  • Modified function add_variable_node_state! in src/variables/variable_node_state.jl to use the new lower bound function node_state_lb for the node_state variable.
  • Introduced node_state_lb in src/variables/variable_node_state.jl to calculate the lower bound for node_state.

Testing:

  • Added a new test, test_constraint_min_node_state_investments, in test/constraints/constraint_node.jl to validate the behavior of the new constraint.
  • Integrated the new test into the overall test suite.

Documentation:

  • Documented the new constraint in docs/src/mathematical_formulation/constraints.md under the "Minimum node state" section.

Fixes #1200

Checklist before merging

  • Documentation is up-to-date
  • Unit tests have been added/updated accordingly
  • Code has been formatted according to SpineOpt's style
  • Unit tests pass

@datejada datejada requested a review from Copilot May 6, 2025 09:19
Copy link

@Copilot 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 adds a new constraint to ensure a minimum storage content for nodes in the SpineOpt model. Key changes include the addition of the constraint_min_node_state, its integration into the SpineOpt workflow, and updates to data preprocessing, variable bounds, testing, and documentation.

Files not reviewed (6)
  • src/SpineOpt.jl: Language not supported
  • src/constraints/constraint_min_node_state.jl: Language not supported
  • src/data_structure/preprocess_data_structure.jl: Language not supported
  • src/run_spineopt_basic.jl: Language not supported
  • src/variables/variable_node_state.jl: Language not supported
  • test/constraints/constraint_node.jl: Language not supported

Copy link

codecov bot commented May 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.39%. Comparing base (fa66a48) to head (1dda716).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1204      +/-   ##
==========================================
+ Coverage   87.35%   87.39%   +0.04%     
==========================================
  Files         144      145       +1     
  Lines        4451     4466      +15     
==========================================
+ Hits         3888     3903      +15     
  Misses        563      563              

☔ 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.

@datejada datejada marked this pull request as ready for review May 6, 2025 11:18
@datejada datejada requested review from DillonJ and gnawin May 6, 2025 11:18
@datejada datejada force-pushed the 1200-node-state-min branch from 4259bc2 to 09ad40e Compare May 6, 2025 15:51
@datejada datejada force-pushed the 1200-node-state-min branch from 09ad40e to 1739c50 Compare May 6, 2025 15:54
@datejada datejada merged commit 70f08ee into master May 7, 2025
7 checks passed
@datejada datejada deleted the 1200-node-state-min branch May 7, 2025 09:16
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.

Add a constraint for the minimum node state limit
1 participant