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

Persistence Of SCIPData Object #290

Merged
merged 2 commits into from
Jun 1, 2024
Merged

Conversation

gtjusila
Copy link
Contributor

@gtjusila gtjusila commented May 31, 2024

This fix an issue with garbage collection when only the inner object of the optimizer is used as exemplified by the following example

import SCIP

function make_optimizer()
    optimizer = SCIP.Optimizer()
    return optimizer.inner
end

function run_test1()
    scip_data = make_optimizer()
    GC.gc(true)
    @assert(scip_data.scip[] != C_NULL)
end

function run_test2()
    scip_data = SCIP.Optimizer()
    inner = scip_data.inner
    scip_data = 0
    GC.gc(true)
    @assert(inner.scip[] != C_NULL)
end

GC.enable_logging(true)

# Both test should fail before fix
run_test1()
run_test2()

The fix is to change the finalizer call to listen to garbage collection events for the SCIPdata object of the MOI Optimizer object instead of listen to garbage collection events for the whole MOI Optimizer object

@matbesancon
Copy link
Member

when only the inner object of the optimizer is used

fundamentally this was one reason the issue is normally not one, we always assume the optimizer is the main structure used, SCIPData is never a stand-alone structure

@gtjusila
Copy link
Contributor Author

gtjusila commented Jun 1, 2024

The problem is once you are interacting with SCIP.jl all the SCIP calls are expecting you to pass a SCIPData object rather than an optimizer object. Two possible solutions here

  1. Implement a convert class that convert optimizer class to SCIPdata on the fly and ask users to only use optimizer to call scip functions
  2. Change the testcase to accommodate the usage of SCIPData as a standalone outside the SCIPData structure.
    The new commit implements the latter. The only requirements remaining now is that SCIPData structure still should not be created as a standalone

@matbesancon matbesancon merged commit cb9766a into scipopt:master Jun 1, 2024
9 checks passed
@gtjusila gtjusila deleted the wrapper_jl branch June 1, 2024 13:43
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