Skip to content

MOAI decision trees as GDP disjunctions - #149

Merged
pulsipher merged 5 commits into
infiniteopt:masterfrom
dnguyen227:linear_model_trees
Oct 30, 2026
Merged

pulsipher merged 5 commits into
infiniteopt:masterfrom
dnguyen227:linear_model_trees

Conversation

@dnguyen227

Copy link
Copy Markdown
Member

Adds a MathOptAI package extension so a trained predictor can be embedded in a GDPModel as a disjunction instead of MOAI's MIP formulation.

  using DisjunctiveProgramming, MathOptAI, HiGHS

  # x[1] <= 1 ? 2x[1] - x[2] : x[1] + 3x[2] + 1
  tree = MathOptAI.BinaryDecisionTree{Float64, MathOptAI.Affine{Float64}}(
      1, 1.0, MathOptAI.Affine([2.0 -1.0], [0.0]), MathOptAI.Affine([1.0 3.0], [1.0]))

  model = GDPModel(HiGHS.Optimizer)
  @variable(model, -3 <= x[1:2] <= 3)
  y, formulation = MathOptAI.add_predictor(model, Disjunctive(tree), x)
  @objective(model, Max, y[1])
  optimize!(model, gdp_method = Hull())   # or BigM(), MBM(HiGHS.Optimizer), ...

for InfiniteGDP

  using InfiniteOpt

  model = InfiniteGDPModel(HiGHS.Optimizer)
  @infinite_parameter(model, t ∈ [0, 1], num_supports = 11)
  @variable(model, -3 <= x <= 3, Infinite(t))
  y, _ = MathOptAI.add_predictor(model, Disjunctive(tree), [x, t])  # y(t), Z(t)
  optimize!(model, gdp_method = Hull())

@dnguyen227
dnguyen227 marked this pull request as ready for review October 29, 2026 16:25

@pulsipher pulsipher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See below, the other thing is making sure all the test pass.

Comment thread ext/MathOptAIDisjunctiveProgramming.jl Resolved
Comment thread ext/MathOptAIDisjunctiveProgramming.jl Resolved
Comment thread ext/MathOptAIDisjunctiveProgramming.jl Resolved
Comment thread ext/MathOptAIDisjunctiveProgramming.jl Resolved
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.73%. Comparing base (6ab70a6) to head (9c3d251).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #149   +/-   ##
=======================================
  Coverage   99.73%   99.73%           
=======================================
  Files          22       23    +1     
  Lines        2608     2659   +51     
=======================================
+ Hits         2601     2652   +51     
  Misses          7        7           

☔ 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
dnguyen227 requested a review from pulsipher October 30, 2026 15:05
@pulsipher
pulsipher merged commit ecbe5c6 into infiniteopt:master Oct 30, 2026
6 checks passed
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