-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove MathProgBase, use JuMP * revamp JuMP dep * use char in sense * make lbounds a scalar * cleanup * swap args * fix linprog for non-floats * make linprog available in Approximations * assign to variable names * load JuMP earlier * wrap LP status checks in functions * fix infeasibility ray * remove unnecesary import * fix input for linprog * skip broken method w/rationals Co-authored-by: schillic <[email protected]>
- Loading branch information
Showing
13 changed files
with
101 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using JuMP.MathOptInterface: AbstractOptimizer, OptimizerWithAttributes | ||
using JuMP: Model, @variable, @objective, @constraint, optimize!, | ||
termination_status, objective_value, value, primal_status | ||
|
||
# solver status | ||
function is_lp_optimal(status) | ||
return status == JuMP.MathOptInterface.OPTIMAL | ||
end | ||
|
||
function is_lp_infeasible(status; strict::Bool=false) | ||
if status == JuMP.MathOptInterface.INFEASIBLE | ||
return true | ||
end | ||
if strict | ||
return false | ||
end | ||
return status == JuMP.MathOptInterface.INFEASIBLE_OR_UNBOUNDED | ||
end | ||
|
||
function is_lp_unbounded(status; strict::Bool=false) | ||
if status == JuMP.MathOptInterface.DUAL_INFEASIBLE | ||
return true | ||
end | ||
if strict | ||
return false | ||
end | ||
return status == JuMP.MathOptInterface.INFEASIBLE_OR_UNBOUNDED | ||
end | ||
|
||
function has_lp_infeasibility_ray(model) | ||
return primal_status(model) == JuMP.MathOptInterface.INFEASIBILITY_CERTIFICATE | ||
end | ||
|
||
# solve a linear program (in the old MathProgBase interface) | ||
function linprog(c, A, sense::Char, b, l::Number, u::Number, solver) | ||
n = length(c) | ||
m = length(b) | ||
return linprog(c, A, fill(sense, m), b, fill(l, n), fill(u, n), solver) | ||
end | ||
|
||
function linprog(c, A, sense, b, l, u, solver) | ||
n = length(c) | ||
model = Model(solver) | ||
@variable(model, l[i] <= x[i=1:n] <= u[i]) | ||
@objective(model, Min, c' * x) | ||
eq_rows, ge_rows, le_rows = sense .== '=', sense .== '>', sense .== '<' | ||
@constraint(model, A[eq_rows, :] * x .== b[eq_rows]) | ||
@constraint(model, A[ge_rows, :] * x .>= b[ge_rows]) | ||
@constraint(model, A[le_rows, :] * x .<= b[le_rows]) | ||
optimize!(model) | ||
return ( | ||
status = termination_status(model), | ||
objval = objective_value(model), | ||
sol = value.(x), | ||
model = model | ||
) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
using LazySets: _isapprox | ||
|
||
for N in [Float64, Float32, Rational{Int}] | ||
# random polygons | ||
rand(HPolygon) | ||
|