Skip to content

Conversation

@RobbieKiwi
Copy link
Contributor

@RobbieKiwi RobbieKiwi commented Dec 23, 2025

Closes #236

Changes proposed in this Pull Request

Allow the objective cost function to contain a constant. While the constant is not needed for optimization, it can make life easier in some cases (see linked issue for discussion).

It was previously forbidden to have a constant in the objective cost function, I assume this is because most solvers expect the ocf to only contain variables.
To get around this without having to touch too many different parts of code, I allowed the objective function itself to have a constant, but added some special logic to deal with constants in a decorator for Model.solve.

Before solving, the constant part is removed, after solving it is added again.

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in doc.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes doc/release_notes.rst of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

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.

Support constant values in objective

1 participant