Skip to content

Commit

Permalink
Merge pull request #2342 from oscar-system/lk/refactor/keyword_arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
lkastner committed May 8, 2023
2 parents fadb17e + 02d51d1 commit 88ef91f
Show file tree
Hide file tree
Showing 58 changed files with 513 additions and 356 deletions.
4 changes: 2 additions & 2 deletions docs/src/DeveloperDocumentation/serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ loading larger objects twice (or multiple times). Consider the following
example code snippet:
```
c = cube(3);
LP0 = LinearProgram(c, [2,2,-3]);
LP1 = LinearProgram(c, [2,2,4]);
LP0 = linear_program(c, [2,2,-3]);
LP1 = linear_program(c, [2,2,4]);
v = [LP0, LP1];
save("vector_of_lp.json", v)
```
Expand Down
4 changes: 2 additions & 2 deletions docs/src/PolyhedralGeometry/Polyhedra/constructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ from other objects in OSCAR.
### Intersecting halfspaces: $H$-representation

```@docs
Polyhedron{T}(A::AnyVecOrMat, b::AbstractVector) where T<:scalar_types
Polyhedron{T}(I::Union{Nothing, AbstractCollection[AffineHalfspace]}, E::Union{Nothing, AbstractCollection[AffineHyperplane]} = nothing) where T<:scalar_types
polyhedron(::Type{T}, A::AnyVecOrMat, b::AbstractVector) where T<:scalar_types
polyhedron(::Type{T}, I::Union{Nothing, AbstractCollection[AffineHalfspace]}, E::Union{Nothing, AbstractCollection[AffineHyperplane]} = nothing) where T<:scalar_types
```

The complete $H$-representation can be retrieved using [`facets`](@ref facets)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/PolyhedralGeometry/fans.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To construct a polyhedral fan, you must pass the rays of each cone in the fan,
along with an `IncidenceMatrix` encoding which rays generate which cones.

```@docs
PolyhedralFan
polyhedral_fan
polyhedral_fan_from_rays_action
```

Expand Down
3 changes: 2 additions & 1 deletion docs/src/PolyhedralGeometry/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ row(i::IncidenceMatrix, n::Int)
column(i::IncidenceMatrix, n::Int)
```

A typical application is the assignment of rays to the cones of a polyhedral fan for its construction, see [`PolyhedralFan{T}`](@ref).
A typical application is the assignment of rays to the cones of a polyhedral
fan for its construction, see [`polyhedral_fan`](@ref).


## Visualization
Expand Down
10 changes: 5 additions & 5 deletions docs/src/PolyhedralGeometry/linear_programs.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ which is described by a vector and (optionally) a translation. One can select wh
problem is to maximize or to minimize the objective function.

```@docs
LinearProgram
linear_program
```

## Solving a linear program - an example
Expand All @@ -35,7 +35,7 @@ Computationally, this means first defining a linear program:
julia> P = cube(3)
Polyhedron in ambient dimension 3
julia> LP = LinearProgram(P,[3,-2,4];k=2,convention = :min)
julia> LP = linear_program(P,[3,-2,4];k=2,convention = :min)
Linear program
min{c⋅x + k | x ∈ P}
where P is a Polyhedron{QQFieldElem} and
Expand All @@ -48,7 +48,7 @@ The information about the linear program `LP` can be easily extracted.
```jldoctest
julia> P = cube(3);
julia> LP = LinearProgram(P,[3,-2,4];k=2,convention = :min);
julia> LP = linear_program(P,[3,-2,4];k=2,convention = :min);
julia> c, k = objective_function(LP)
(QQFieldElem[3, -2, 4], 2)
Expand All @@ -63,7 +63,7 @@ where the optimal value is `m`, and that value is attained at `v`.
```jldoctest
julia> P = cube(3);
julia> LP = LinearProgram(P,[3,-2,4];k=2,convention = :min);
julia> LP = linear_program(P,[3,-2,4];k=2,convention = :min);
julia> m, v = solve_lp(LP)
(-7, QQFieldElem[-1, 1, -1])
Expand All @@ -84,7 +84,7 @@ The optimal value and an optimal vertex may be obtained individually as well.
```jldoctest
julia> P = cube(3);
julia> LP = LinearProgram(P,[3,-2,4];k=2,convention = :min);
julia> LP = linear_program(P,[3,-2,4];k=2,convention = :min);
julia> M = optimal_value(LP)
-7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ to minimize the objective function. Furthermore one can optionally specify
given as a set of integers, their respective indices.

```@docs
MixedIntegerLinearProgram
mixed_integer_linear_program
```

## Functions
Expand Down
2 changes: 1 addition & 1 deletion docs/src/PolyhedralGeometry/polyhedral_complexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ along with an `IncidenceMatrix` encoding which points generate which
polyhedron.

```@docs
PolyhedralComplex
polyhedral_complex
```


Expand Down
4 changes: 2 additions & 2 deletions docs/src/PolyhedralGeometry/subdivisions_of_points.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ vector, but if it does, it is called `regular`.


```@docs
SubdivisionOfPoints(Points::Union{Oscar.MatElem,AbstractMatrix}, Incidence::IncidenceMatrix)
SubdivisionOfPoints(Points::Union{Oscar.MatElem,AbstractMatrix}, Weights::AbstractVector)
subdivision_of_points(::Type{T}, Points::Union{Oscar.MatElem,AbstractMatrix}, Incidence::IncidenceMatrix) where T<:scalar_types
subdivision_of_points(::Type{T}, Points::Union{Oscar.MatElem,AbstractMatrix}, Weights::AbstractVector) where T<:scalar_types
```

From a subdivision of points one can construct the
Expand Down
4 changes: 2 additions & 2 deletions experimental/FTheoryTools/src/auxiliary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function _ambient_space_from_base(base::AbstractNormalToricVariety)
ambient_space_max_cones = IncidenceMatrix(vcat(ambient_space_max_cones...))

# Construct and return the ambient space
ambient_space = normal_toric_variety(PolyhedralFan(ambient_space_rays, ambient_space_max_cones; non_redundant = true))
ambient_space = normal_toric_variety(polyhedral_fan(ambient_space_rays, ambient_space_max_cones; non_redundant = true))
set_coordinate_names(ambient_space, vcat([string(k) for k in gens(cox_ring(base))], ["x", "y", "z"]))
return ambient_space

Expand Down Expand Up @@ -131,7 +131,7 @@ function sample_toric_variety()
[5, 11, 12], [5, 6, 32], [5, 6, 12], [4, 31, 32], [4, 10, 11], [4, 5, 32],
[4, 5, 11], [3, 30, 31], [3, 9, 10], [3, 4, 31], [3, 4, 10], [2, 29, 30],
[2, 8, 9], [2, 3, 30], [2, 3, 9], [1, 8, 29], [1, 2, 29], [1, 2, 8]])
return normal_toric_variety(PolyhedralFan(rays, cones))
return normal_toric_variety(polyhedral_fan(rays, cones))
end

@doc raw"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ ideal(-x1*x2 + x3*x4)
```
"""
function toric_ideal(R::MPolyRing, antv::AffineNormalToricVariety)
cone = Cone(pm_object(antv).WEIGHT_CONE)
gens = pm_object(cone).CONE_TORIC_IDEAL.BINOMIAL_GENERATORS
C = cone(pm_object(antv).WEIGHT_CONE)
gens = pm_object(C).CONE_TORIC_IDEAL.BINOMIAL_GENERATORS
return binomial_exponents_to_ideal(R, gens)
end

Expand All @@ -481,8 +481,8 @@ ideal(-x1*x2 + x3*x4)
```
"""
@attr MPolyIdeal function toric_ideal(antv::AffineNormalToricVariety)
cone = Cone(pm_object(antv).WEIGHT_CONE)
n = length(hilbert_basis(cone))
C = cone(pm_object(antv).WEIGHT_CONE)
n = length(hilbert_basis(C))
R, _ = polynomial_ring(coefficient_ring(antv), n, cached=false)
return toric_ideal(R, antv)
end
Expand Down Expand Up @@ -910,7 +910,7 @@ julia> dim(nef)
1
```
"""
@attr Cone nef_cone(v::NormalToricVariety) = Cone(pm_object(v).NEF_CONE)
@attr Cone nef_cone(v::NormalToricVariety) = cone(pm_object(v).NEF_CONE)


"""
Expand All @@ -930,7 +930,7 @@ julia> dim(mori)
1
```
"""
@attr Cone mori_cone(v::NormalToricVariety) = Cone(pm_object(v).MORI_CONE)
@attr Cone mori_cone(v::NormalToricVariety) = cone(pm_object(v).MORI_CONE)


@doc raw"""
Expand Down Expand Up @@ -1039,7 +1039,7 @@ julia> affine_open_covering(p2)
@attr Vector{AffineNormalToricVariety} function affine_open_covering(v::AbstractNormalToricVariety)
charts = Vector{AffineNormalToricVariety}(undef, pm_object(v).N_MAXIMAL_CONES)
for i in 1:pm_object(v).N_MAXIMAL_CONES
charts[i] = affine_normal_toric_variety(Cone(Polymake.fan.cone(pm_object(v), i-1)))
charts[i] = affine_normal_toric_variety(cone(Polymake.fan.cone(pm_object(v), i-1)))
end
return charts
end
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Normal, affine toric variety
```
"""
function affine_normal_toric_variety(C::Cone; set_attributes::Bool = true)
fan = PolyhedralFan(C)
fan = polyhedral_fan(C)
pmntv = Polymake.fulton.NormalToricVariety(Oscar.pm_object(fan))
variety = AffineNormalToricVariety(pmntv)

Expand Down Expand Up @@ -71,7 +71,7 @@ Normal, affine toric variety
```
"""
function normal_toric_variety(C::Cone; set_attributes::Bool = true)
fan = PolyhedralFan(C)
fan = polyhedral_fan(C)
pmntv = Polymake.fulton.NormalToricVariety(Oscar.pm_object(fan))
variety = NormalToricVariety(pmntv)

Expand Down Expand Up @@ -123,7 +123,7 @@ Normal toric variety
```
"""
function normal_toric_variety(rays::Vector{Vector{Int64}}, max_cones::Vector{Vector{Int64}}; non_redundant::Bool = false, set_attributes::Bool = true)
fan = PolyhedralFan(transpose(hcat(rays...)), IncidenceMatrix(max_cones); non_redundant = non_redundant)
fan = polyhedral_fan(transpose(hcat(rays...)), IncidenceMatrix(max_cones); non_redundant = non_redundant)
return normal_toric_variety(fan; set_attributes = set_attributes)
end

Expand Down Expand Up @@ -234,7 +234,7 @@ Normal, affine, 2-dimensional toric variety
"""
function affine_space(::Type{NormalToricVariety}, d::Int; set_attributes::Bool = true)
C = positive_hull(identity_matrix(ZZ, d))
fan = PolyhedralFan(C)
fan = polyhedral_fan(C)
pmntv = Polymake.fulton.NormalToricVariety(Oscar.pm_object(fan))
variety = NormalToricVariety(pmntv)

Expand Down Expand Up @@ -342,7 +342,7 @@ function weighted_projective_space(::Type{NormalToricVariety}, w::Vector{T}; set
tr,_ = pseudo_inv(lattice_gens)
ray_gens = ray_gens * transpose(tr)
mc = IncidenceMatrix(subsets(Vector{Int}(1:length(w)), length(w)-1))
variety = normal_toric_variety(PolyhedralFan(ray_gens, mc; non_redundant=true ))
variety = normal_toric_variety(polyhedral_fan(ray_gens, mc; non_redundant=true ))

# make standard choice for the weights of the cox ring
set_attribute!(variety, :torusinvariant_weil_divisor_group, free_abelian_group(length(w)))
Expand Down Expand Up @@ -381,7 +381,7 @@ Normal, non-affine, smooth, projective, gorenstein, non-fano, 2-dimensional tori
function hirzebruch_surface(::Type{NormalToricVariety}, r::Int; set_attributes::Bool = true)
fan_rays = [1 0; 0 1; -1 r; 0 -1]
cones = IncidenceMatrix([[1, 2], [2, 3], [3, 4], [4, 1]])
variety = normal_toric_variety(PolyhedralFan(fan_rays, cones; non_redundant = true))
variety = normal_toric_variety(polyhedral_fan(fan_rays, cones; non_redundant = true))

# make standard choice for the weights of the cox ring
set_attribute!(variety, :torusinvariant_cartier_divisor_group, free_abelian_group(4))
Expand Down Expand Up @@ -457,7 +457,7 @@ function del_pezzo_surface(::Type{NormalToricVariety}, b::Int; set_attributes::B
fan_rays = [1 0; 0 1; -1 -1; 1 1; 0 -1; -1 0]
cones = IncidenceMatrix([[1, 4], [2, 4], [1, 5], [5, 3], [2, 6], [6, 3]])
end
variety = normal_toric_variety(PolyhedralFan(fan_rays, cones; non_redundant = true))
variety = normal_toric_variety(polyhedral_fan(fan_rays, cones; non_redundant = true))

# make standard choice for weights of the cox ring
if b == 1
Expand Down Expand Up @@ -754,7 +754,7 @@ function normal_toric_varieties_from_star_triangulations(P::Polyhedron; set_attr
max_cones = [IncidenceMatrix([[c[i]-1 for i in 2:length(c)] for c in t]) for t in max_cones]

# construct the varieties
return [normal_toric_variety(PolyhedralFan(integral_rays, cones; non_redundant = true), set_attributes = set_attributes) for cones in max_cones]
return [normal_toric_variety(polyhedral_fan(integral_rays, cones; non_redundant = true), set_attributes = set_attributes) for cones in max_cones]
end


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ julia> is_feasible(polyhedron(td2))
false
```
"""
@attr Polyhedron polyhedron(td::ToricDivisor) = Polyhedron(pm_tdivisor(td).SECTION_POLYTOPE)
@attr Polyhedron polyhedron(td::ToricDivisor) = polyhedron(pm_tdivisor(td).SECTION_POLYTOPE)


@doc raw"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function toric_morphism(domain::AbstractNormalToricVariety, grid_morphism::GrpAb
# compute the image
image_rays = matrix(ZZ, rays(domain)) * matrix(grid_morphism)
image_rays = hcat([[Int(image_rays[i, j]) for i in 1:nrows(image_rays)] for j in 1:ncols(image_rays)]...)
image = normal_toric_variety(PolyhedralFan(image_rays, ray_indices(maximal_cones(domain))))
image = normal_toric_variety(polyhedral_fan(image_rays, ray_indices(maximal_cones(domain))))

# compute the morphism
if codomain === nothing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A toric morphism
mapping_matrix = matrix(ZZ, rays(fan(variety)))
max_cones_for_cox_variety = ray_indices(maximal_cones(variety))
rays_for_cox_variety = matrix(ZZ, [[if i==j 1 else 0 end for j in 1:nrays(variety)] for i in 1:nrays(variety)])
cox_variety = normal_toric_variety(PolyhedralFan(rays_for_cox_variety, max_cones_for_cox_variety))
cox_variety = normal_toric_variety(polyhedral_fan(rays_for_cox_variety, max_cones_for_cox_variety))
return toric_morphism(cox_variety, mapping_matrix, variety)
end

Expand Down
2 changes: 1 addition & 1 deletion src/AlgebraicGeometry/TropicalGeometry/curve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ end
function TropicalCurve(graph::IncidenceMatrix, M::Union{typeof(min),typeof(max)}=min)
# Columns correspond to nodes
# Rows correpons to edges
empty = PolyhedralComplex(Polymake.fan.PolyhedralComplex())
empty = polyhedral_complex(Polymake.fan.PolyhedralComplex())
result = TropicalCurve{M, false}(empty)
set_attribute!(result, :graph, graph)
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ function groebner_polyhedron(GB::Vector{<:MPolyRingElem}, inGB::Vector{<:MPolyRi
end
end

return Polyhedron(A,b)
return polyhedron(A,b)
end
2 changes: 1 addition & 1 deletion src/AlgebraicGeometry/TropicalGeometry/hypersurface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function TropicalHypersurface(f::AbstractAlgebra.Generic.MPoly{Oscar.TropicalSem
pmpoly = Polymake.common.totropicalpolynomial(fstr...)
pmhypproj = Polymake.tropical.Hypersurface{M}(POLYNOMIAL=pmpoly)
pmhyp = Polymake.tropical.affine_chart(pmhypproj)
Vf = TropicalHypersurface{M, true}(PolyhedralComplex(pmhyp))
Vf = TropicalHypersurface{M, true}(polyhedral_complex(pmhyp))
w = pmhypproj.WEIGHTS
set_attribute!(Vf,:polymake_bigobject,pmhypproj)
set_attribute!(Vf,:tropical_polynomial,f)
Expand Down
2 changes: 1 addition & 1 deletion src/AlgebraicGeometry/TropicalGeometry/links.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function homogeneity_space(I; compute_groebner_basis::Bool=false)
end
end

return Polyhedron((zeros(Int,0,n),zeros(Int,0)),(A,b))
return polyhedron((zeros(Int,0,n),zeros(Int,0)),(A,b))
end


Expand Down
6 changes: 3 additions & 3 deletions src/AlgebraicGeometry/TropicalGeometry/variety.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ julia> VR = [0 0; 1 0; 0 1; -1 -1];
julia> far_vertices = [2,3,4];
julia> Sigma = PolyhedralComplex(IM, VR, far_vertices);
julia> Sigma = polyhedral_complex(IM, VR, far_vertices);
julia> tropicalLine = TropicalVariety{min,true}(Sigma)
"""
Expand Down Expand Up @@ -277,7 +277,7 @@ function tropical_variety(I::MPolyIdeal, val::TropicalSemiringMap, convention::U
# 3.0.1: dehomogenize Groebner polyhedra
zeroth_unit_vector_as_row_vector = zeros(Int,1,n)
zeroth_unit_vector_as_row_vector[1,1] = 1
dehomogenising_hyperplane = Polyhedron((zeros(Int,0,n),zeros(Int,0)),
dehomogenising_hyperplane = polyhedron((zeros(Int,0,n),zeros(Int,0)),
(zeroth_unit_vector_as_row_vector,[1]))
for wCG in working_list_done
wCG[2] = intersect(wCG[2],dehomogenising_hyperplane)
Expand Down Expand Up @@ -333,7 +333,7 @@ function tropical_variety(I::MPolyIdeal, val::TropicalSemiringMap, convention::U



PC = PolyhedralComplex(IncidenceMatrix(incidence_matrix),
PC = polyhedral_complex(IncidenceMatrix(incidence_matrix),
verts_rays_matrix,
far_vertices,
lineality_space_gens)
Expand Down
4 changes: 2 additions & 2 deletions src/Combinatorics/Graphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ julia> fractional_cut_polytope(G)
Polyhedron in ambient dimension 6
```
"""
fractional_cut_polytope(G::Graph{Undirected}) = Polyhedron(Polymake.polytope.fractional_cut_polytope(pm_object(G)))
fractional_cut_polytope(G::Graph{Undirected}) = polyhedron(Polymake.polytope.fractional_cut_polytope(pm_object(G)))


@doc raw"""
Expand All @@ -944,4 +944,4 @@ julia> fractional_matching_polytope(G)
Polyhedron in ambient dimension 6
```
"""
fractional_matching_polytope(G::Graph{Undirected}) = Polyhedron(Polymake.polytope.fractional_matching_polytope(pm_object(G)))
fractional_matching_polytope(G::Graph{Undirected}) = polyhedron(Polymake.polytope.fractional_matching_polytope(pm_object(G)))
Loading

0 comments on commit 88ef91f

Please sign in to comment.