Skip to content

Commit

Permalink
Add support for collections of variables in ComplexPlane (#3184)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Jan 11, 2023
1 parent 3bec576 commit 5c0b0d8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,22 @@ function JuMP.add_variable(
)
end

function build_variable(
_error::Function,
variables::AbstractArray{<:ScalarVariable},
set::ComplexPlane,
)
return build_variable.(_error, variables, Ref(set))
end

function add_variable(
model::Model,
variables::AbstractArray{<:ComplexVariable},
name::Union{<:AbstractArray{String},String} = "",
)
return add_variable.(model, variables, name)
end

"""
reduced_cost(x::VariableRef)::Float64
Expand Down
9 changes: 9 additions & 0 deletions test/test_variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,15 @@ function test_complex_variable()
return
end

function test_complex_variable()
model = Model()
@variable(model, x[1:2] in ComplexPlane())
@test x[1] isa GenericAffExpr{ComplexF64,VariableRef}
@test x[2] isa GenericAffExpr{ComplexF64,VariableRef}
@test num_variables(model) == 4
return
end

function test_extension_complex_variable_errors(
ModelType = Model,
VariableRefType = VariableRef,
Expand Down

0 comments on commit 5c0b0d8

Please sign in to comment.