Skip to content

Optimization variables - #1844

Open
dallan-keylogic wants to merge 4 commits into
IDAES:mainfrom
dallan-keylogic:optimization_variables
Open

dallan-keylogic wants to merge 4 commits into
IDAES:mainfrom
dallan-keylogic:optimization_variables

Conversation

@dallan-keylogic

@dallan-keylogic dallan-keylogic commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary/Motivation:

The Flowsheet Inspector tool displays model diagnostic information after both initialization and optimization. The problem with displaying model diagnostic information is that an optimization model is always going to have positive degrees of freedom. That causes a DOF warning to be emitted, as well as a warning about structural singularity.

The solution I propose is to add the optimization_variables config option to the DiagnosticToolbox. This is a list of variables that are known to be unfixed in order to optimize the flowsheet. If such a list is passed in, we expect the number of degrees of freedom to equal the number of "optimization variables" (barring the edge case of an "optimization variable" appearing exclusively in inequality constraints or the objective function). The Flowsheet Inspector will be modified in a future PR to have a way for the user to declare "optimization variables" and thereby allow the user to keep track of their degrees of freedom.

However, adding this option added a bunch of edge cases: what if an "optimization variable" is fixed? What if it's entirely unused? To solve these problems, additional methods were added to warn the user about these situations.

One idea for a future PR is to also add an option to check for structural singularity when the "optimization variables" are fixed. If the system is indeed structurally singular, then there is an algebraic relationship between the "optimization variables", and their values will be confined to a lower dimensional surface. This would indicate that the user doesn't understand their system well and that there are some other combinations of variables which are really being optimized.

Changes proposed in this PR:

  • Add the optimization_variables config argument to the DiagnosticsToolbox
  • Adjust the DiagnosticsToolbox reporting for degrees of freedom and structural singularity to allow for the fast that the system has nonzero DOF
  • Add the display_fixed_optimization_variables and display_unused_optimization_variables diagnostic methods to prevent user error when declaring these variables.
  • Add the variables_in_activated_objectives_set model statistics option to keep track of variables in objective functions and modify the unused_variables_set method in model statistics so that variables that appear exclusively in objective expressions do not count as "unused".

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.93939% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.60%. Comparing base (6489942) to head (a486426).

Files with missing lines Patch % Lines
...core/util/diagnostics_tools/diagnostics_toolbox.py 93.22% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1844   +/-   ##
=======================================
  Coverage   77.60%   77.60%           
=======================================
  Files         424      424           
  Lines       67657    67717   +60     
  Branches    11437    11452   +15     
=======================================
+ Hits        52503    52552   +49     
- Misses      12535    12541    +6     
- Partials     2619     2624    +5     

☔ View full report in Codecov by Harness.
📢 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.

@dallan-keylogic
dallan-keylogic marked this pull request as ready for review August 31, 2026 15:34
@ksbeattie ksbeattie added the Priority:Normal Normal Priority Issue or PR label Sep 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority:Normal Normal Priority Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants