Skip to content

Commit

Permalink
Standardize naming conventions (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtanneau authored Sep 28, 2020
1 parent ea29705 commit 3d93ebc
Show file tree
Hide file tree
Showing 34 changed files with 784 additions and 784 deletions.
20 changes: 10 additions & 10 deletions docs/src/manual/linear_systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ Here is a list of currently supported linear solvers:

| Linear solver type | System | Backend | Method |
|:-------------------|:-------|:--------|:-------|
| [`Dense_SymPosDef`](@ref) | Normal equations | Dense / LAPACK | Cholesky
| [`Cholmod_SymQuasDef`](@ref) | Augmented system | CHOLMOD | LDLᵀ
| [`Cholmod_SymPosDef`](@ref) | Normal equations | CHOLMOD | Cholesky
| [`LDLFact_SymQuasDef`](@ref) | Augmented system | [LDLFactorizations.jl](https://github.com/JuliaSmoothOptimizers/LDLFactorizations.jl) | LDLᵀ
| [`KrylovSPDSolver`](@ref) | Normal equations | [Krylov.jl](https://github.com/JuliaSmoothOptimizers/Krylov.jl) | Krylov
| [`KrylovSIDSolver`](@ref) | Augmented system[^1] | [Krylov.jl](https://github.com/JuliaSmoothOptimizers/Krylov.jl) | Krylov
| [`KrylovSQDSolver`](@ref) | Augmented system[^1] | [Krylov.jl](https://github.com/JuliaSmoothOptimizers/Krylov.jl) | Krylov

[^1]: [`KrylovSIDSolver`](@ref)s view the augmented system as a symmetric indefinite system,
while [`KrylovSQDSolver`](@ref)s exploit its 2x2 structure and quasi-definite property.
| [`DenseSPD`](@ref) | Normal equations | Dense / LAPACK | Cholesky
| [`CholmodSQD`](@ref) | Augmented system | CHOLMOD | LDLᵀ
| [`CholmodSPD`](@ref) | Normal equations | CHOLMOD | Cholesky
| [`LDLFactSQD`](@ref) | Augmented system | [LDLFactorizations.jl](https://github.com/JuliaSmoothOptimizers/LDLFactorizations.jl) | LDLᵀ
| [`KrylovSPD`](@ref) | Normal equations | [Krylov.jl](https://github.com/JuliaSmoothOptimizers/Krylov.jl) | Krylov
| [`KrylovSID`](@ref) | Augmented system[^1] | [Krylov.jl](https://github.com/JuliaSmoothOptimizers/Krylov.jl) | Krylov
| [`KrylovSQD`](@ref) | Augmented system[^1] | [Krylov.jl](https://github.com/JuliaSmoothOptimizers/Krylov.jl) | Krylov

[^1]: [`KrylovSID`](@ref)s view the augmented system as a symmetric indefinite system,
while [`KrylovSQD`](@ref)s exploit its 2x2 structure and quasi-definite property.
See the reference documentation for more details.
14 changes: 7 additions & 7 deletions docs/src/reference/kkt_solvers.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CurrentModule = Tulip.KKT
## Dense/LAPACK

```@docs
Dense_SymPosDef
DenseSPD
```

## CHOLMOD
Expand All @@ -54,17 +54,17 @@ CholmodSolver
```

```@docs
Cholmod_SymQuasDef
CholmodSQD
```

```@docs
Cholmod_SymPosDef
CholmodSPD
```

## LDLFactorizations

```@docs
LDLFact_SymQuasDef
LDLFactSQD
```

## Krylov
Expand All @@ -75,13 +75,13 @@ LDLFact_SymQuasDef


```@docs
KrylovSPDSolver
KrylovSPD
```

```@docs
KrylovSIDSolver
KrylovSID
```

```@docs
KrylovSQDSolver
KrylovSQD
```
2 changes: 1 addition & 1 deletion docs/src/reference/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Numerical tolerances for the interior-point algorithm.
| Parameter | Description | Default |
|:----------|:------------|:--------|
| `MatrixOptions` | See [`TLA.MatrixOptions`](@ref) | `SparseMatrixCSC`
| `KKTOptions` | See [`KKT.SolverOptions`](@ref) | [`KKT.Cholmod_SymQuasDef`](@ref) for `Float64`, [`KKT.LDLFact_SymQuasDef`](@ref) otherwise |
| `KKTOptions` | See [`KKT.SolverOptions`](@ref) | [`KKT.CholmodSQD`](@ref) for `Float64`, [`KKT.LDLFactSQD`](@ref) otherwise |
| `BarrierPRegMin` | Minimum value of primal regularization | ``\sqrt{\epsilon}`` |
| `BarrierDregMin` | Minimum value of dual regularization | ``\sqrt{\epsilon}``

Expand Down
36 changes: 18 additions & 18 deletions src/Interfaces/MOI/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ end
_bounds(s)
"""
_bounds(s::MOI.EqualTo{Tv}) where{Tv} = s.value, s.value
_bounds(s::MOI.LessThan{Tv}) where{Tv} = Tv(-Inf), s.upper
_bounds(s::MOI.GreaterThan{Tv}) where{Tv} = s.lower, Tv(Inf)
_bounds(s::MOI.Interval{Tv}) where{Tv} = s.lower, s.upper
_bounds(s::MOI.EqualTo{T}) where{T} = s.value, s.value
_bounds(s::MOI.LessThan{T}) where{T} = T(-Inf), s.upper
_bounds(s::MOI.GreaterThan{T}) where{T} = s.lower, T(Inf)
_bounds(s::MOI.Interval{T}) where{T} = s.lower, s.upper

const SCALAR_SETS{Tv} = Union{
MOI.LessThan{Tv},
MOI.GreaterThan{Tv},
MOI.EqualTo{Tv},
MOI.Interval{Tv}
} where{Tv}
const SCALAR_SETS{T} = Union{
MOI.LessThan{T},
MOI.GreaterThan{T},
MOI.EqualTo{T},
MOI.Interval{T}
} where{T}



Expand All @@ -76,12 +76,12 @@ const SCALAR_SETS{Tv} = Union{
# ==============================================================================

"""
Optimizer{Tv}
Optimizer{T}
Wrapper for MOI.
"""
mutable struct Optimizer{Tv} <: MOI.AbstractOptimizer
inner::Model{Tv}
mutable struct Optimizer{T} <: MOI.AbstractOptimizer
inner::Model{T}

is_feas::Bool # Model is feasibility problem if true

Expand All @@ -91,7 +91,7 @@ mutable struct Optimizer{Tv} <: MOI.AbstractOptimizer
var_indices_moi::Vector{MOI.VariableIndex}
var_indices::Dict{MOI.VariableIndex, Int}
con_indices_moi::Vector{MOI.ConstraintIndex}
con_indices::Dict{MOI.ConstraintIndex{MOI.ScalarAffineFunction{Tv}, <:SCALAR_SETS{Tv}}, Int}
con_indices::Dict{MOI.ConstraintIndex{MOI.ScalarAffineFunction{T}, <:SCALAR_SETS{T}}, Int}

# Variable and constraint names
name2var::Dict{String, MOI.VariableIndex}
Expand All @@ -104,14 +104,14 @@ mutable struct Optimizer{Tv} <: MOI.AbstractOptimizer
# Keep track of bound constraints
var2bndtype::Dict{MOI.VariableIndex, Set{Type{<:MOI.AbstractScalarSet}}}

function Optimizer{Tv}(;kwargs...) where{Tv}
m = new{Tv}(
Model{Tv}(), false,
function Optimizer{T}(;kwargs...) where{T}
m = new{T}(
Model{T}(), false,
# Variable and constraint counters
0, 0,
# Index mapping
MOI.VariableIndex[], Dict{MOI.VariableIndex, Int}(),
MOI.ConstraintIndex[], Dict{MOI.ConstraintIndex{MOI.ScalarAffineFunction, <:SCALAR_SETS{Tv}}, Int}(),
MOI.ConstraintIndex[], Dict{MOI.ConstraintIndex{MOI.ScalarAffineFunction, <:SCALAR_SETS{T}}, Int}(),
# Name -> index mapping
Dict{String, MOI.VariableIndex}(), Dict{String, MOI.ConstraintIndex}(),
Dict{MOI.ConstraintIndex, String}(), # Variable bounds tracking
Expand Down
12 changes: 6 additions & 6 deletions src/Interfaces/MOI/attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ MOI.get(m::Optimizer, ::MOI.NumberOfVariables) = m.inner.pbdata.nvar
# ObjectiveFunctionType
#
MOI.get(
m::Optimizer{Tv}, ::MOI.ObjectiveFunctionType
) where{Tv} = MOI.ScalarAffineFunction{Tv}
m::Optimizer{T}, ::MOI.ObjectiveFunctionType
) where{T} = MOI.ScalarAffineFunction{T}

#
# ObjectiveSense
Expand Down Expand Up @@ -140,15 +140,15 @@ end
#
# ObjectiveValue
#
function MOI.get(m::Optimizer{Tv}, attr::MOI.ObjectiveValue) where{Tv}
function MOI.get(m::Optimizer{T}, attr::MOI.ObjectiveValue) where{T}
MOI.check_result_index_bounds(m, attr)
return get_attribute(m.inner, ObjectiveValue())
end

#
# DualObjectiveValue
#
function MOI.get(m::Optimizer{Tv}, attr::MOI.DualObjectiveValue) where{Tv}
function MOI.get(m::Optimizer{T}, attr::MOI.DualObjectiveValue) where{T}
MOI.check_result_index_bounds(m, attr)
return get_attribute(m.inner, DualObjectiveValue())
end
Expand All @@ -161,11 +161,11 @@ MOI.get(m::Optimizer, ::MOI.RawSolver) = m.inner
#
# RelativeGap
#
function MOI.get(m::Optimizer{Tv}, ::MOI.RelativeGap) where{Tv}
function MOI.get(m::Optimizer{T}, ::MOI.RelativeGap) where{T}
# TODO: dispatch a function call on m.inner
zp = m.inner.solver.primal_bound_scaled
zd = m.inner.solver.dual_bound_scaled
return (abs(zp - zd) / (Tv(1 // 10^6)) + abs(zd))
return (abs(zp - zd) / (T(1 // 10^6)) + abs(zd))
end

#
Expand Down
Loading

0 comments on commit 3d93ebc

Please sign in to comment.