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

Add support for bound type MI in pulp.LpProblem.fromMPS #792

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dwr-zroy
Copy link

Adds support for MI bounded variables in the pulp.LpProblem.fromMPS method .

This addresses Issue #791.

Changes

Added an additional clause to readMPSSetBounds in pulp.mps_lp.

def readMPSSetBounds(line, variable_dict):
    bound = line[0]
    var_name = line[2]

    def set_one_bound(bound_type, value):
        variable_dict[var_name][BOUNDS_EQUIV[bound_type]] = value

    def set_both_bounds(value_low, value_up):
        set_one_bound("LO", value_low)
        set_one_bound("UP", value_up)

    if bound == "FR":
        set_both_bounds(None, None)
        return
    elif bound == "BV":
        set_both_bounds(0, 1)
        return
    elif bound == "PL":
        # bounds equal to defaults
        return
    elif bound == "MI":
        # Lower bound -inf
        set_one_bound("LO", None)
        return

    value = float(line[3])
    if bound in ["LO", "UP"]:
        set_one_bound(bound, value)
    elif bound == "FX":
        set_both_bounds(value, value)
    return

Added a test to BaseSolverTest.PuLPTest called test_importMPF_MI_bound, which is similar in form to the existing test_importMPS_PL_bound method. An additional global variable is created, called EXAMPLE_MPS_MI_BOUNDS which is similar in form to the existing EXAMPLE_MPS_PL_BOUNDS variable.

Tests pass on Windows 11, with the PULP_CBC_CMD solver. Additional testing with more solvers is requested.

Documentation was re-built, but no changes are present.

isort also cleaned up the order of imports in each of the changed files. Let me know if this was inappropriate.

Next Steps

Testing with additional solvers should be considered by those more familiar with the project. I do not have licensing for most of the supported solvers so that testing was not done on my part. However, this change doesn't touch any of the library related to the solver APIs.

@CLAassistant
Copy link

CLAassistant commented Feb 13, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@dwr-zroy
Copy link
Author

Just as a note, I think the CLA bot above has commented in the wrong order. I have since signed the CLA.

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.

2 participants