Skip to content

MBM: optional GP-based M sampling on InfiniteGDP models - #139

Open
dnguyen227 wants to merge 14 commits into
infiniteopt:masterfrom
dnguyen227:mbm_gp
Open

MBM: optional GP-based M sampling on InfiniteGDP models #139
dnguyen227 wants to merge 14 commits into
infiniteopt:masterfrom
dnguyen227:mbm_gp

Conversation

@dnguyen227

Copy link
Copy Markdown
Contributor

Implementation of MBM

using AbstractGPs 

optimize!(model, gdp_method = MBM(HiGHS.Optimizer)) 

MBM(HiGHS.Optimizer, M_sampler = :exact)                        # every support, as before
MBM(HiGHS.Optimizer, M_sampler = GPSampler(budget = 0.1))       # solve 10% of supports
MBM(HiGHS.Optimizer, M_sampler = GPSampler(kappa = 4.0))        # more conservative M

Not sure how to work around needing to make a new extension.

@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.53%. Comparing base (a4ebe8a) to head (0b49a6e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #139      +/-   ##
==========================================
+ Coverage   99.51%   99.53%   +0.02%     
==========================================
  Files          17       19       +2     
  Lines        2061     2153      +92     
==========================================
+ Hits         2051     2143      +92     
  Misses         10       10              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dnguyen227

Copy link
Copy Markdown
Contributor Author

@pulsipher ready for review

@pulsipher pulsipher left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is better, but I think it can be made less complicated.

Comment thread src/datatypes.jl Outdated
Comment thread src/datatypes.jl Outdated
Comment thread src/datatypes.jl Outdated
Comment thread src/extension_api.jl Outdated
Comment thread ext/InfiniteDisjunctiveProgramming.jl Outdated
Comment thread ext/InfiniteDisjunctiveProgramming.jl
Comment thread ext/InfiniteDisjunctiveProgramming.jl
Comment thread ext/InfiniteDisjunctiveProgramming.jl
Comment thread ext/AbstractGPsDisjunctiveProgramming.jl Outdated
Comment thread src/datatypes.jl Outdated
@dnguyen227
dnguyen227 requested a review from pulsipher August 30, 2026 21:26
Comment thread src/extension_api.jl Outdated
julia> method = MBM(HiGHS.Optimizer, sampler = GPSampler(kappa = 4.0))
```
"""
struct GPSampler{K} <: AbstractMBMSampler

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Move to AbstractGPsDisjunctiveProgramming.jl

Comment on lines +7 to +46
################################################################################
# SAMPLER CONFIG
################################################################################
# The concrete sampler behind DP.GPSampler; the base package only
# carries the function stub, so constructing one requires AbstractGPs.
struct _GPSampler{F} <: DP.AbstractMBMSampler
f::F
std_dev_margin::Float64
frac_supports::Float64
detect_uniform_M::Bool
initial_supports::Union{Int, Vector{Float64}}

function _GPSampler(
f::F;
std_dev_margin::Real = 2.5,
frac_supports::Real = 0.25,
detect_uniform_M::Bool = true,
initial_supports = 4
) where {F}
f isa Union{Nothing, AbstractGPs.GP} || error(
"`f` must be an `AbstractGPs.GP` prior, e.g. " *
"`GP(Matern52Kernel())`.")
std_dev_margin >= 0 || error("`std_dev_margin` must be nonnegative.")
0 < frac_supports <= 1 || error("`frac_supports` must be in `(0, 1]`.")
if initial_supports isa Int
initial_supports >= 2 ||
error("`initial_supports` must be at least 2.")
else
initial_supports = collect(Float64, initial_supports)
(!isempty(initial_supports) &&
all(frac -> 0 <= frac <= 1, initial_supports)) ||
error("`initial_supports` must be fractions in `[0, 1]`.")
end
new{F}(f, Float64(std_dev_margin), Float64(frac_supports),
detect_uniform_M, initial_supports)
end
end

DP.GPSampler(f = nothing; kwargs...) = _GPSampler(f; kwargs...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pulsipher is this ok?

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