Skip to content

Conversation

@pulsipher
Copy link
Collaborator

@pulsipher pulsipher commented Mar 14, 2024

This adds an extension such that DisjunctiveProgramming is compatible with InfiniteOpt. It overloads the needed functions and provide the InfiniteGDPModel and InfiniteLogical functions. A basic example is shown below:

using DisjunctiveProgramming, InfiniteOpt, HiGHS

# Create the model
model = InfiniteGDPModel(HiGHS.Optimizer)

# Create the infinite variables
I = 1:4
@infinite_parameter(model, t  [0, 1], num_supports = 100)
@variable(model, 0 <= g[I] <= 10, Infinite(t))

# Add the disjunctions and their indicator variables
@variable(model, G[I, 1:2], InfiniteLogical(t))
@constraint(model, [i  I, j  1:2], 0 <= g[i], Disjunct(G[i, 1]))
@constraint(model, [i  I, j  1:2], g[i] <= 0, Disjunct(G[i, 2]))
@disjunction(model, [i  I], G[i, :])

# Add the logical propositions
@variable(model, W, InfiniteLogical(t))
@constraint(model, G[1, 1]  G[2, 1]  G[3, 1] == W := true)
@constraint(model, 𝔼(binary_variable(W), t) >= 0.95) # incorporate binary variable of logical variable in a nonlogical constraint

# Reformulate and solve 
optimize!(model, gdp_method = Hull())

# check the results
value(W)

Before merging this, I need to make the corresponding release in InfiniteOpt so we can update the compat. In the meantime, this PR will allow us to experiment with this interface.

For those looking to try this out, use the the following to install:

import Pkg
Pkg.add(url = "https://github.com/infiniteopt/InfiniteOpt.jl", rev = "master")
Pkg.add(url = "https://github.com/hdavid16/DisjunctiveProgramming.jl", rev = "infiniteopt_ext")

@codecov
Copy link

codecov bot commented Mar 14, 2024

Codecov Report

Attention: Patch coverage is 0% with 24 lines in your changes missing coverage. Please review.

Project coverage is 97.51%. Comparing base (3406645) to head (3786845).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
ext/InfiniteDisjunctiveProgramming.jl 0.00% 24 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #114      +/-   ##
==========================================
- Coverage   99.80%   97.51%   -2.30%     
==========================================
  Files          11       12       +1     
  Lines        1021     1045      +24     
==========================================
  Hits         1019     1019              
- Misses          2       26      +24     

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

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