8000 Properly free resources after solve with gurobipy · Issue #459 · PyPSA/linopy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Properly free resources after solve with gurobipy #459

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

Open
2 tasks done
FBumann opened this issue May 20, 2025 · 0 comments
Open
2 tasks done

Properly free resources after solve with gurobipy #459

FBumann opened this issue May 20, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@FBumann
Copy link
Contributor
FBumann commented May 20, 2025

Version Checks (indicate both or one)

  • I have confirmed this bug exists on the lastest release of Linopy.

  • I have confirmed this bug exists on the current master branch of Linopy.

Issue Description

Using gurobipy with a non-academic license leads to issues with the license not being freed after the model was solved.
I would

Im not finished investigating the issue, but it probably arises from not closing the gp.Model before closing the gp.Env
The gurobipy website says the following:

It is good practice to use the with keyword when dealing with environment (and model) objects. That way the resources tied to these objects are properly released even if an exception is raised at some point. The following example illustrates two typical use patterns.

import gurobipy as gp
with gp.Env("gurobi.log") as env, gp.Model(env=env) as model:
    # Populate model object here...
    model.optimize()

with gp.Env(empty=True) as env:
    env.setParam("ComputeServer", "myserver1:32123")
    env.setParam("ServerPassword", "pass")
    env.start()
    with gp.Model(env=env) as model:
        # Populate model object here...
        model.optimize()

I will correct this and open a PR.
Is there any reason to not close the model after the solve? Maybe because of IIS calculation?

Reproducible Example

Unfortunately I can provide a reproducible example without a usage restricted license

Expected Behavior

I would expect to be able to solve a linty model in a new python thread/console, after the model in another console finished.
This is not possible, due to the license not being released properly.

Installed Versions

bottleneck==1.5.0 click==8.2.0 cloudpickle==3.1.1 dask==2025.5.0 deprecation==2.1.0 fsspec==2025.3.2 importlib-metadata==8.7.0 linopy==0.5.5 locket==1.0.0 numexpr==2.10.2 numpy==2.2.6 packaging==25.0 pandas==2.2.3 partd==1.4.2 polars==1.29.0 python-dateutil==2.9.0.post0 pytz==2025.2 pyyaml==6.0.2 scipy==1.15.3 six==1.17.0 toolz==1.0.0 tqdm==4.67.1 tzdata==2025.2 xarray==2025.4.0 zipp==3.21.0
@FBumann FBumann added the bug Something isn't working label May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant
0