Skip to content
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

Allow removing objective expression from the model #212

Merged
merged 2 commits into from
Dec 8, 2023
Merged

Conversation

Irieo
Copy link
Contributor

@Irieo Irieo commented Dec 7, 2023

Add functionality to remove a linear expression of the objective from the model.
complements already existing functionality, such as remove_variables() and remove_constraints()
Useful for tutorials, and more generally, for any type of programming exercises when one wants to keep variables and parameters from n.optimize.create_model() but use own objective.

example use:

n.optimize.create_model()
n.model.objective

LinearExpression: +70 Generator-p[now, gas]
Sense: min
Value: None

n.model.remove_objective()

LinearExpression: +0
Sense: min
Value: None

closes #209

Copy link

codecov bot commented Dec 7, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a97febe) 89.26% compared to head (ab97cca) 89.26%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #212   +/-   ##
=======================================
  Coverage   89.26%   89.26%           
=======================================
  Files          15       15           
  Lines        3352     3354    +2     
  Branches      771      771           
=======================================
+ Hits         2992     2994    +2     
  Misses        248      248           
  Partials      112      112           

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

@Irieo Irieo requested a review from FabianHofmann December 7, 2023 16:02
@FabianHofmann
Copy link
Collaborator

Awesome @Irieo, to increase the awesomeness, could you add a test for it, probably in test_model.py?

@Irieo
Copy link
Contributor Author

Irieo commented Dec 8, 2023

Awesome @Irieo, to increase the awesomeness, could you add a test for it, probably in test_model.py?

indeed, let's keep the level of awesomeness pumped up. I added a test.

@FabianHofmann FabianHofmann merged commit 930ceae into master Dec 8, 2023
12 checks 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.

make possible to remove objective
2 participants