Skip to content

Commit 4652d04

Browse files
authored
Merge pull request #26 from jump-dev/type-param
different type parameters for b anc c
2 parents 49647d9 + 2327074 commit 4652d04

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/conic_form.jl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ s.t. b_i - A_i x ∈ C_i ∀ i
99
```
1010
with each `C_i` a cone defined in MOI.
1111
"""
12-
mutable struct GeometricConicForm{T, AT, VT, C} <: MOI.ModelLike
12+
mutable struct GeometricConicForm{T, AT, VB, VC, C} <: MOI.ModelLike
1313
num_rows::Vector{Int}
1414
dimension::Dict{Int, Int}
1515
sense::MOI.OptimizationSense
1616
objective_constant::T # The objective
1717
A::Union{Nothing, AT} # The constraints
18-
b::VT # `b - Ax in cones`
19-
c::VT # `sense c'x + objective_constant`
18+
b::VB # `b - Ax in cones`
19+
c::VC # `sense c'x + objective_constant`
2020
cone_types::C
2121
cone_types_dict::Dict{DataType, Int}
2222

23-
function GeometricConicForm{T, AT, VT}(cone_types) where {T, AT, VT}
24-
model = new{T, AT, VT, typeof(cone_types)}()
23+
function GeometricConicForm{T, AT, VB, VC}(cone_types) where {T, AT, VB, VC}
24+
model = new{T, AT, VB, VC, typeof(cone_types)}()
2525
model.cone_types = cone_types
2626
model.cone_types_dict = Dict{DataType, Int}(
2727
s => i for (i, s) in enumerate(cone_types)
@@ -33,6 +33,10 @@ mutable struct GeometricConicForm{T, AT, VT, C} <: MOI.ModelLike
3333
end
3434
end
3535

36+
function GeometricConicForm{T, AT, VT}(cone_types) where {T, AT, VT}
37+
return GeometricConicForm{T, AT, VT, VT}(cone_types)
38+
end
39+
3640
_set_type(::MOI.ConstraintIndex{F,S}) where {F,S} = S
3741

3842
MOI.is_empty(model::GeometricConicForm) = model.A === nothing
@@ -68,7 +72,7 @@ function MOI.set(::GeometricConicForm, ::MOI.VariablePrimalStart,
6872
::MOI.VariableIndex, ::Nothing)
6973
end
7074
function MOI.set(model::GeometricConicForm{T}, ::MOI.VariablePrimalStart,
71-
vi::MOI.VariableIndex, value::T) where T
75+
vi::MOI.VariableIndex, value::T) where {T}
7276
model.primal[vi.value] = value
7377
end
7478
function MOI.set(::GeometricConicForm, ::MOI.ConstraintPrimalStart,
@@ -93,7 +97,7 @@ end
9397
variable_index_value(t::MOI.ScalarAffineTerm) = t.variable_index.value
9498
variable_index_value(t::MOI.VectorAffineTerm) = variable_index_value(t.scalar_term)
9599
function MOI.set(model::GeometricConicForm{T}, ::MOI.ObjectiveFunction,
96-
f::MOI.ScalarAffineFunction{T}) where T
100+
f::MOI.ScalarAffineFunction{T}) where {T}
97101
c = Vector(sparsevec(variable_index_value.(f.terms), MOI.coefficient.(f.terms),
98102
model.A.n))
99103
model.objective_constant = f.constant

0 commit comments

Comments
 (0)