Skip to content

Basic steps implementation - #141

Open
dnguyen227 wants to merge 5 commits into
infiniteopt:masterfrom
dnguyen227:basic_steps
Open

Basic steps implementation#141
dnguyen227 wants to merge 5 commits into
infiniteopt:masterfrom
dnguyen227:basic_steps

Conversation

@dnguyen227

Copy link
Copy Markdown
Contributor
  • apply_basic_step(model, [Y1, Y2, ...]) replaces the input disjunctions with their product: one new disjunct per combination, containing the union of the parents' constraints
  • Global constraints can be intersected into every product disjunct
  • Original logical vars Y are kept and linked via Y[i] in Exactly(w_slice) → reformulates to y_i = sum_j w_ij, so the model is equivalent.
  • relax_products = true makes the product binaries continuous [0,1] (the linking equalities force them integral), so binaries don't multiply (Pyomo doesnt do this, its valid according to the lit).
  • Right now, basic steps is destructive, as this all takes place before the user calls optimize and triggers the reformulation workflow.
  • Also InfiniteGDP implementation (it doesnt seem to benefit solve times at all from my minimal testing).
model = GDPModel(HiGHS.Optimizer)
@variable(model, 0 <= x[1:2] <= 10)
@variable(model, Y[1:2], Logical)
@variable(model, Z[1:2], Logical)
@objective(model, Max, x[1] + x[2])
@constraint(model, x[1] <= 1, Disjunct(Y[1]))
@constraint(model, 2 <= x[1] <= 3, Disjunct(Y[2]))
@constraint(model, x[2] <= 1, Disjunct(Z[1]))
@constraint(model, 4 <= x[2] <= 5, Disjunct(Z[2]))
d1 = disjunction(model, Y)
d2 = disjunction(model, Z)
g = @constraint(model, x[1] + x[2] <= 6)

# replace d1 and d2 with their product disjunction (2x2 = 4 disjuncts),
# intersecting the global constraint g into every product disjunct
bs = apply_basic_step(model, [d1, d2], constraints = [g], name = "bs")

optimize!(model, gdp_method = Hull())   # tighter relaxation, same optimum

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #141      +/-   ##
==========================================
+ Coverage   99.51%   99.54%   +0.03%     
==========================================
  Files          17       18       +1     
  Lines        2061     2204     +143     
==========================================
+ Hits         2051     2194     +143     
  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.

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.

1 participant