-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BREAKING] Move functionality to extension packages (#328)
* move jump to extension * support for regular dependency in julia 1.6 * reorganize JuMP ext * move RecipesBase and GeometryBasics to ext * uncomment verbose statement * add error message for Mesh * add news file describing breaking change * update docs * update examples * simplify doc * fix verbose print of model * remove exported JuMP function * import functions missing in GeometryBasicsExt * add missing compat entry
- Loading branch information
Showing
15 changed files
with
139 additions
and
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Polyhedra.jl v0.8 Release Notes | ||
|
||
## Load time improvements | ||
- Dependencies on JuMP.jl, RecipesBase.jl, and GeometryBasics.jl were moved to | ||
weak dependencies on Julia versions supporting package extensions, i.e. v1.9 | ||
and above. On v1.10 this reduces installation time by 15% and load time by | ||
18% (see [#328]). | ||
|
||
## Breaking changes | ||
- `JuMP.optimizer_with_attributes` is no longer exported. Call it from JuMP.jl instead. | ||
- The following change is only breaking on Julia v1.9 and above: | ||
`Polyhedra.Mesh` is now implemented in a package extension requiring | ||
GeometryBasics.jl. It is sufficient to load your plotting package, i.e. | ||
Makie.jl or MeshCat.jl, **before** calling `Polyhedra.Mesh` |
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,23 +1,38 @@ | ||
name = "Polyhedra" | ||
uuid = "67491407-f73d-577b-9b50-8179a7c68029" | ||
repo = "https://github.com/JuliaPolyhedra/Polyhedra.jl.git" | ||
version = "0.7.6" | ||
version = "0.7.7" | ||
|
||
[deps] | ||
GenericLinearAlgebra = "14197337-ba66-59df-a3e3-ca00e7dcff7a" | ||
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326" | ||
JuMP = "4076af6c-e467-56ae-b986-b466b2749572" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
JuMP = "4076af6c-e467-56ae-b986-b466b2749572" | ||
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" | ||
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0" | ||
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" | ||
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" | ||
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" | ||
|
||
[weakdeps] | ||
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326" | ||
JuMP = "4076af6c-e467-56ae-b986-b466b2749572" | ||
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" | ||
|
||
[extensions] | ||
PolyhedraGeometryBasicsExt = "GeometryBasics" | ||
PolyhedraJuMPExt = "JuMP" | ||
PolyhedraRecipesBaseExt = "RecipesBase" | ||
|
||
[compat] | ||
GenericLinearAlgebra = "0.2, 0.3" | ||
GeometryBasics = "0.2, 0.3, 0.4" | ||
JuMP = "0.23, 1" | ||
LinearAlgebra = "1.6" | ||
MathOptInterface = "1" | ||
MutableArithmetics = "1" | ||
RecipesBase = "0.7, 0.8, 1.0" | ||
SparseArrays = "1.6" | ||
StaticArrays = "0.12, 1.0" | ||
julia = "1.6" | ||
|
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,53 @@ | ||
module PolyhedraJuMPExt | ||
|
||
import JuMP | ||
import Polyhedra: hrep, LPHRep, polyhedron, _optimize! | ||
using Polyhedra: Rep, Projection, _moi_set, fulldim, dimension_names, PolyhedraToLPBridge, ProjectionBridge | ||
|
||
""" | ||
hrep(model::JuMP.Model) | ||
Builds an H-representation from the feasibility set of the JuMP model `model`. | ||
Note that if non-linear constraint are present in the model, they are ignored. | ||
""" | ||
hrep(model::JuMP.Model) = LPHRep(model) | ||
LPHRep(model::JuMP.Model) = LPHRep(JuMP.backend(model)) | ||
polyhedron(model::JuMP.Model, args...) = polyhedron(hrep(model), args...) | ||
_optimize!(model::JuMP.Model) = JuMP.optimize!(model) | ||
|
||
struct VariableInSet{V <: JuMP.ScalarVariable, S <: Union{Rep, Projection}} <: JuMP.AbstractVariable | ||
variables::Vector{V} | ||
set::S | ||
end | ||
function JuMP.build_variable(error_fun::Function, variables::Vector{<:JuMP.ScalarVariable}, set::Union{Rep, Projection}) | ||
if length(variables) != fulldim(set) | ||
error("Number of variables ($(length(variables))) does not match the full dimension of the polyhedron ($(fulldim(set))).") | ||
end | ||
return VariableInSet(variables, set) | ||
end | ||
function JuMP.add_variable(model::JuMP.AbstractModel, v::VariableInSet, names) | ||
dim_names = dimension_names(v.set) | ||
if dim_names !== nothing | ||
names = copy(names) | ||
for i in eachindex(names) | ||
if isempty(names[i]) && !isempty(dim_names[i]) | ||
names[i] = dim_names[i] | ||
end | ||
end | ||
end | ||
JuMP.add_bridge(model, PolyhedraToLPBridge) | ||
JuMP.add_bridge(model, ProjectionBridge) | ||
return JuMP.add_variable(model, JuMP.VariablesConstrainedOnCreation(v.variables, _moi_set(v.set)), names) | ||
end | ||
function JuMP.build_constraint(error_fun::Function, func, set::Rep) | ||
return JuMP.BridgeableConstraint( | ||
JuMP.build_constraint(error_fun, func, _moi_set(set)), | ||
PolyhedraToLPBridge) | ||
end | ||
function JuMP.build_constraint(error_fun::Function, func, set::Projection) | ||
return JuMP.BridgeableConstraint(JuMP.BridgeableConstraint( | ||
JuMP.build_constraint(error_fun, func, _moi_set(set)), | ||
ProjectionBridge), PolyhedraToLPBridge) | ||
end | ||
|
||
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.