Skip to content

Commit 2f9b11b

Browse files
authored
ConicForm -> GeometricConicForm (#17)
1 parent 16208a4 commit 2f9b11b

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/conic_form.jl

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mutable struct ConicForm{T, AT, VT, C} <: MOI.ModelLike
1+
mutable struct GeometricConicForm{T, AT, VT, C} <: MOI.ModelLike
22
num_rows::Vector{Int}
33
dimension::Dict{Int, Int}
44
sense::MOI.OptimizationSense
@@ -9,7 +9,7 @@ mutable struct ConicForm{T, AT, VT, C} <: MOI.ModelLike
99
cone_types::C
1010
cone_types_dict::Dict{DataType, Int}
1111

12-
function ConicForm{T, AT, VT}(cone_types) where {T, AT, VT}
12+
function GeometricConicForm{T, AT, VT}(cone_types) where {T, AT, VT}
1313
model = new{T, AT, VT, typeof(cone_types)}()
1414
model.cone_types = cone_types
1515
model.cone_types_dict = Dict{DataType, Int}(
@@ -29,7 +29,7 @@ function get_conic_form(::Type{T}, model::M, con_idx) where {T, M <: MOI.Abstrac
2929
cones = _set_type.(con_idx)
3030
cones = unique(cones)
3131

32-
conic = ConicForm{T, SparseMatrixCSRtoCSC{T, Int}, Vector{T}}(Tuple(cones))
32+
conic = GeometricConicForm{T, SparseMatrixCSRtoCSC{T, Int}, Vector{T}}(Tuple(cones))
3333

3434
idxmap = MOI.copy_to(conic, model)
3535

@@ -41,8 +41,8 @@ function get_conic_form(::Type{T}, model::M, con_idx) where {T, M <: MOI.Abstrac
4141
return conic
4242
end
4343

44-
MOI.is_empty(model::ConicForm) = model.A === nothing
45-
function MOI.empty!(model::ConicForm{T}) where T
44+
MOI.is_empty(model::GeometricConicForm) = model.A === nothing
45+
function MOI.empty!(model::GeometricConicForm{T}) where T
4646
empty!(model.dimension)
4747
fill!(model.num_rows, 0)
4848
model.A = nothing
@@ -51,53 +51,53 @@ function MOI.empty!(model::ConicForm{T}) where T
5151
end
5252

5353
function MOI.supports_constraint(
54-
model::ConicForm,
54+
model::GeometricConicForm,
5555
::Type{MOI.VectorAffineFunction{Float64}},
5656
::Type{S}) where S <: MOI.AbstractVectorSet
5757
return haskey(model.cone_types_dict, S)
5858
end
5959

60-
function _allocate_variables(model::ConicForm{T, AT, VT}, vis_src, idxmap) where {T, AT, VT}
60+
function _allocate_variables(model::GeometricConicForm{T, AT, VT}, vis_src, idxmap) where {T, AT, VT}
6161
model.A = AT(length(vis_src))
6262
for (i, vi) in enumerate(vis_src)
6363
idxmap[vi] = MOI.VariableIndex(i)
6464
end
6565
return
6666
end
6767

68-
function rows(model::ConicForm, ci::CI{MOI.VectorAffineFunction{Float64}})
68+
function rows(model::GeometricConicForm, ci::CI{MOI.VectorAffineFunction{Float64}})
6969
return ci.value .+ (1:model.dimension[ci.value])
7070
end
7171

72-
function MOI.set(::ConicForm, ::MOI.VariablePrimalStart,
72+
function MOI.set(::GeometricConicForm, ::MOI.VariablePrimalStart,
7373
::MOI.VariableIndex, ::Nothing)
7474
end
75-
function MOI.set(model::ConicForm, ::MOI.VariablePrimalStart,
75+
function MOI.set(model::GeometricConicForm, ::MOI.VariablePrimalStart,
7676
vi::MOI.VariableIndex, value::Float64)
7777
model.primal[vi.value] = value
7878
end
79-
function MOI.set(::ConicForm, ::MOI.ConstraintPrimalStart,
79+
function MOI.set(::GeometricConicForm, ::MOI.ConstraintPrimalStart,
8080
::MOI.ConstraintIndex, ::Nothing)
8181
end
82-
function MOI.set(model::ConicForm, ::MOI.ConstraintPrimalStart,
82+
function MOI.set(model::GeometricConicForm, ::MOI.ConstraintPrimalStart,
8383
ci::MOI.ConstraintIndex, value)
8484
offset = constroffset(model, ci)
8585
model.slack[rows(model, ci)] .= value
8686
end
87-
function MOI.set(::ConicForm, ::MOI.ConstraintDualStart,
87+
function MOI.set(::GeometricConicForm, ::MOI.ConstraintDualStart,
8888
::MOI.ConstraintIndex, ::Nothing)
8989
end
90-
function MOI.set(model::ConicForm, ::MOI.ConstraintDualStart,
90+
function MOI.set(model::GeometricConicForm, ::MOI.ConstraintDualStart,
9191
ci::MOI.ConstraintIndex, value)
9292
offset = constroffset(model, ci)
9393
model.dual[rows(model, ci)] .= value
9494
end
95-
function MOI.set(model::ConicForm, ::MOI.ObjectiveSense, sense::MOI.OptimizationSense)
95+
function MOI.set(model::GeometricConicForm, ::MOI.ObjectiveSense, sense::MOI.OptimizationSense)
9696
model.sense = sense
9797
end
9898
variable_index_value(t::MOI.ScalarAffineTerm) = t.variable_index.value
9999
variable_index_value(t::MOI.VectorAffineTerm) = variable_index_value(t.scalar_term)
100-
function MOI.set(model::ConicForm, ::MOI.ObjectiveFunction,
100+
function MOI.set(model::GeometricConicForm, ::MOI.ObjectiveFunction,
101101
f::MOI.ScalarAffineFunction{Float64})
102102
c = Vector(sparsevec(variable_index_value.(f.terms), MOI.coefficient.(f.terms),
103103
model.A.n))
@@ -106,7 +106,7 @@ function MOI.set(model::ConicForm, ::MOI.ObjectiveFunction,
106106
return nothing
107107
end
108108

109-
function _allocate_constraint(model::ConicForm, src, indexmap, cone_id, ci)
109+
function _allocate_constraint(model::GeometricConicForm, src, indexmap, cone_id, ci)
110110
# TODO use `CanonicalConstraintFunction`
111111
func = MOI.get(src, MOI.ConstraintFunction(), ci)
112112
func = MOIU.is_canonical(func) ? func : MOI.Utilities.canonical(func)
@@ -116,22 +116,22 @@ function _allocate_constraint(model::ConicForm, src, indexmap, cone_id, ci)
116116
return ci, offset, func
117117
end
118118

119-
function _allocate_constraints(model::ConicForm, src, indexmap, cone_id, ::Type{S}) where S
119+
function _allocate_constraints(model::GeometricConicForm, src, indexmap, cone_id, ::Type{S}) where S
120120
cis = MOI.get(src, MOI.ListOfConstraintIndices{MOI.VectorAffineFunction{Float64}, S}())
121121
return map(cis) do ci
122122
_allocate_constraint(model, src, indexmap, cone_id, ci)
123123
end
124124
end
125125

126-
function _load_variables(model::ConicForm, nvars::Integer)
126+
function _load_variables(model::GeometricConicForm, nvars::Integer)
127127
m = sum(model.num_rows)
128128
model.A.m = m
129129
model.b = zeros(m)
130130
model.c = zeros(model.A.n)
131131
allocate_nonzeros(model.A)
132132
end
133133

134-
function _load_constraints(model::ConicForm, src, indexmap, cone_offset, i, cache)
134+
function _load_constraints(model::GeometricConicForm, src, indexmap, cone_offset, i, cache)
135135
for (ci_src, offset_in_cone, func) in cache
136136
offset = cone_offset + offset_in_cone
137137
set = MOI.get(src, MOI.ConstraintSet(), ci_src)
@@ -142,7 +142,7 @@ function _load_constraints(model::ConicForm, src, indexmap, cone_offset, i, cach
142142
end
143143
end
144144

145-
function MOI.copy_to(dest::ConicForm, src::MOI.ModelLike; copy_names::Bool=true)
145+
function MOI.copy_to(dest::GeometricConicForm, src::MOI.ModelLike; copy_names::Bool=true)
146146
MOI.empty!(dest)
147147

148148
vis_src = MOI.get(src, MOI.ListOfVariableIndices())

0 commit comments

Comments
 (0)