Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the extreme rays of a model, please #3902

Closed
zhx-11 opened this issue Dec 13, 2024 · 2 comments
Closed

How to get the extreme rays of a model, please #3902

zhx-11 opened this issue Dec 13, 2024 · 2 comments

Comments

@zhx-11
Copy link

zhx-11 commented Dec 13, 2024

If a model has already been established, and during the solution process it is found that the model is solvable but the objective function is unbounded, what methods can be used to obtain its extreme rays? And how to calculate the values of the decision variables corresponding to the extreme rays?

My code is as follows:

using JuMP
using Gurobi

model = Model(Gurobi.Optimizer)
set_optimizer_attribute(model, "OutputFlag", 0)
@variable(model, x[1:4]>=0)
@variable(model, y[1:5]>=0)
@constraint(model, [i in 1:4,j in 1:5], i*x[i]+j*y[j]>=i*j)
@objective(model, Max, sum(x[i] for i in 1:4)+sum(y[j] for j in 1:5 ) )

optimize!(model)

Of course, you can also give a simple example of how to get it。
If there is no direct method to obtain the extreme rays, please also give me some feedback, thank you

@blegat
Copy link
Member

blegat commented Dec 15, 2024

Hi @zhx-11. In the future, I recommend posting in https://discourse.julialang.org/c/domain/opt/13, you'll get a faster answer.
The details are here: https://jump.dev/JuMP.jl/stable/moi/background/infeasibility_certificates/#Unbounded-problems
If primal_status(model) returns INFEASIBILITY_CERTIFICATE then value.(x) and value.(y) give you the value of x and y in the extreme ray.

@odow
Copy link
Member

odow commented Dec 16, 2024

See this example:

julia> using JuMP

julia> using Gurobi

julia> begin
           model = Model(Gurobi.Optimizer)
           set_optimizer_attribute(model, "OutputFlag", 0)
           @variable(model, x[1:4]>=0)
           @variable(model, y[1:5]>=0)
           @constraint(model, [i in 1:4,j in 1:5], i*x[i]+j*y[j]>=i*j)
           @objective(model, Max, sum(x[i] for i in 1:4)+sum(y[j] for j in 1:5 ) )
           optimize!(model)
           solution_summary(model)
       end
Set parameter LicenseID to value 890341
* Solver : Gurobi

* Status
  Result count       : 0
  Termination status : INFEASIBLE_OR_UNBOUNDED
  Message from the solver:
  "Model was proven to be either infeasible or unbounded. To obtain a more definitive conclusion, set the DualReductions parameter to 0 and reoptimize."

* Candidate solution (result #1)
  Primal status      : NO_SOLUTION
  Dual status        : NO_SOLUTION

* Work counters
  Solve time (sec)   : 6.79493e-05
  Simplex iterations : 0
  Barrier iterations : 0
  Node count         : 0


julia> begin
           set_attribute(model, "DualReductions", 0)
           optimize!(model)
           solution_summary(model)
       end
* Solver : Gurobi

* Status
  Result count       : 1
  Termination status : DUAL_INFEASIBLE
  Message from the solver:
  "Model was proven to be unbounded. Important note: an unbounded status indicates the presence of an unbounded ray that allows the objective to improve without limit. It says nothing about whether the model has a feasible solution. If you require information on feasibility, you should set the objective to zero and reoptimize."

* Candidate solution (result #1)
  Primal status      : INFEASIBILITY_CERTIFICATE
  Dual status        : NO_SOLUTION
  Objective value    : 9.00000e+00

* Work counters
  Solve time (sec)   : 3.09944e-04
  Simplex iterations : 0
  Barrier iterations : 0
  Node count         : 0


julia> value.(x)
4-element Vector{Float64}:
 1.0
 1.0
 1.0
 1.0

julia> value.(y)
5-element Vector{Float64}:
 1.0
 1.0
 1.0
 1.0
 1.0

@odow odow closed this as completed Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants