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

support reuse of Gurobi environment for multistage models #783

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

NLaws
Copy link
Contributor

@NLaws NLaws commented Oct 21, 2024

Description

This PR allows for the use of the Gurobi.Optimizer with multistage models.

When running a multistage model with a "single use" Gurobi license like:

using GenX
using Gurobi

run_genx_case!(dirname(@__FILE__), Gurobi.Optimizer)

one will get

ERROR: LoadError: Gurobi Error 10009: Single-use license. Another Gurobi process with pid 12345 running.

The solution looks like:

using GenX
using Gurobi

if !(@isdefined GRB_ENV)  # the whole point is to only create GRB_ENV once per Julia session
    const GRB_ENV = Gurobi.Env()
end

run_genx_case!(dirname(@__FILE__), () -> Gurobi.Optimizer(GRB_ENV))

What type of PR is this? (check all applicable)

  • Bug Fix
  • Documentation Update

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and .md files under /docs/src have been updated if necessary.
  • The latest changes on the target branch have been incorporated, so that any conflicts are taken care of before merging. This can be accomplished either by merging in the target branch (e.g. 'git merge develop') or by rebasing on top of the target branch (e.g. 'git rebase develop'). Please do not hesitate to reach out to the GenX development team if you need help with this.
  • Code has been tested to ensure all functionality works as intended.
  • CHANGELOG.md has been updated (if this is a 'notable' change).
  • I consent to the release of this PR's code under the GNU General Public license.

How this can be tested

see examples above

@NLaws NLaws force-pushed the nl/support-gurobi-multistage branch 2 times, most recently from 6ad5336 to 1620708 Compare November 2, 2024 03:18
@lbonaldo
Copy link
Collaborator

lbonaldo commented Nov 4, 2024

Hi @NLaws, thanks so much for this contribution! I’m updating the target branch to develop since we're preparing for an upcoming release that will include this update along with other fixes.

@lbonaldo lbonaldo changed the base branch from main to develop November 4, 2024 22:36
@lbonaldo lbonaldo self-requested a review November 4, 2024 22:36
Copy link
Collaborator

@lbonaldo lbonaldo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you, @NLaws.

@NLaws
Copy link
Contributor Author

NLaws commented Nov 5, 2024

Thanks @lbonaldo. I cannot merge the PR since I'm not a contributor. Can you please merge it?

@lbonaldo lbonaldo force-pushed the nl/support-gurobi-multistage branch from 1620708 to d415c98 Compare November 5, 2024 14:46
@lbonaldo
Copy link
Collaborator

lbonaldo commented Nov 5, 2024

Absolutely. I've just rebased it with the latest develop and updated the changelog. Thanks again, @NLaws, for this addition!

@lbonaldo lbonaldo merged commit 654e49d into GenXProject:develop Nov 5, 2024
7 of 9 checks passed
@GenXProject GenXProject added this to the v0.4.2 milestone Jan 16, 2025
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.

3 participants