Replace pulp.LpVariable() calls with prob.add_variable()#113
Merged
martinlackner merged 1 commit intomasterfrom May 6, 2026
Merged
Replace pulp.LpVariable() calls with prob.add_variable()#113martinlackner merged 1 commit intomasterfrom
martinlackner merged 1 commit intomasterfrom
Conversation
PuLP 3.3.1 deprecated direct LpVariable() construction in favour of prob.add_variable(), which will be the only supported form in PuLP 4.0. With -W error in pytest, these DeprecationWarnings were turned into test failures. Replace all pulp.LpVariable(...) calls with prob.add_variable(...) throughout abcrules_pulp.py. https://claude.ai/code/session_01EKgeNsu9avVGurvMVkyCpV
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #113 +/- ##
=======================================
Coverage 89.33% 89.33%
=======================================
Files 12 12
Lines 3563 3563
Branches 859 859
=======================================
Hits 3183 3183
Misses 257 257
Partials 123 123
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors all variable creation in the PuLP-based voting rules to use the
prob.add_variable()method instead of directly callingpulp.LpVariable(). This change improves code consistency and aligns with PuLP's recommended API for variable management within a problem context.Key Changes
pulp.LpVariable()calls withprob.add_variable()throughout the module_enumerate_committees_standard_pulp()- committee membership variables_enumerate_committees_lex_pulp()- committee and lexicographic optimization variablesset_opt_model_func()- utility, satisfaction, partition, load, and loadbound variables_pulp_minimaxav()- Hamming distance and voter distance variablesset_opt_model()- voter utility variables_enumerate_committees_standard_pulp()for better readabilityImplementation Details
add_variable()method, ensuring proper variable registration with the problem instancehttps://claude.ai/code/session_01EKgeNsu9avVGurvMVkyCpV