Skip to content

Initial package implementation - #5

Open
dnguyen227 wants to merge 8 commits into
infiniteopt:mainfrom
dnguyen227:package_updates
Open

Initial package implementation#5
dnguyen227 wants to merge 8 commits into
infiniteopt:mainfrom
dnguyen227:package_updates

Conversation

@dnguyen227

@dnguyen227 dnguyen227 commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Sample how we'd use this:

using DisjunctiveProgramming, DisjunctiveAlgorithms, Gurobi, Ipopt
import DisjunctiveAlgorithms as DA

model = GDPModel(() -> DA.Optimizer(Ipopt.Optimizer, Gurobi.Optimizer))
set_silent(model)
@variable(model, 0 <= x <= 10)
@variable(model, Y[1:2], Logical)
@constraint(model, x <= 3, Disjunct(Y[1]))
@constraint(model, x^2 == 64, Disjunct(Y[2]))
@disjunction(model, Y)
@objective(model, Max, x)
optimize!(model, gdp_method = Direct())

# status
termination_status(model)   # MOI.LOCALLY_SOLVED
primal_status(model)        # MOI.FEASIBLE_POINT
raw_status(model)           # solver-reported string from the LOA loop
result_count(model)         # 1
is_solved_and_feasible(model)

#obj and bounds
objective_value(model)      # 8.0
objective_bound(model)      # master bound at termination
relative_gap(model)

# solution (can't get duals)
value(x)                    # 8.0
value(Y[1])                 # false
value(Y[2])                 # true
value.(Y)                   # Bool vector

# Solve statistics
solve_time(model)
solver_name(model)          # "DisjunctiveAlgorithms"

# Algorithm attributes read back through JuMP
get_attribute(model, DA.Algorithm())
get_attribute(model, DA.NumIterationLimit())
get_attribute(model, DA.ConvergenceTolerance())

# example of calls not supported.
# dual(con)                 # DualStatus is always NO_SOLUTION
# value(con)                # ConstraintPrimal is refused, not computed

@dnguyen227

Copy link
Copy Markdown
Collaborator Author

@pulsipher ready for review.

@pulsipher pulsipher left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few comments/questions:

  • I believe this requires that we first at support for MOI disjunctions in DisjunctiveProgramming, right?
  • It doesn't appear that this optimizer supports the full MOI API for queries (i.e., not requiring the user to call the inner solver directly)
  • Are the methods in the main src folder truly general and not specific to LOA? (especially master.jl and nlp.jl)
  • It would be good to have a test for the natural user interface via DisjunctiveProgramming

Comment thread src/problem.jl Outdated
Comment on lines +56 to +62
function _try_convert(T::Type, func)
return try
convert(T, func)
catch
func
end
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

generally, try catch statements should be avoided

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