Skip to content

Commit

Permalink
reshape with Hermitian constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Feb 27, 2023
1 parent cbabac9 commit 1ce981e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ jobs:
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: MOI#hermitian_model
shell: julia --project=@. {0}
run: |
using Pkg
Pkg.add(PackageSpec(name="MathOptInterface", rev="bl/hermitian_model"))
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
with:
Expand Down
23 changes: 23 additions & 0 deletions test/test_constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,14 @@ function test_extension_Hermitian_PSD_constraint(
VariableRefType = VariableRef,
)
model = ModelType()
set_optimizer(
model,
() -> MOIU.MockOptimizer(
MOIU.Model{Float64}();
eval_objective_value = false,
eval_variable_constraint_dual = false,
),
)
@variable(model, x)
@variable(model, y)
@variable(model, w)
Expand All @@ -1417,6 +1425,21 @@ function test_extension_Hermitian_PSD_constraint(
@test isequal_canonical(c.func[4], 1 - w)
@test c.set == MOI.HermitianPositiveSemidefiniteConeTriangle(2)
@test c.shape isa HermitianMatrixShape
MOIU.attach_optimizer(model)
model.is_model_dirty = false
mock_optimizer = unsafe_backend(model).model
MOI.set(mock_optimizer, MOI.TerminationStatus(), MOI.OPTIMAL)
MOI.set(mock_optimizer, MOI.DualStatus(), MOI.FEASIBLE_POINT)
F = MOI.VectorAffineFunction{Float64}
MOI.set(
mock_optimizer,
MOI.ConstraintDual(),
optimizer_index(href),
1:MOI.dimension(c.set),
)
d = dual(href)
@test d isa Hermitian
@test parent(d) == [1 2 + 4im; 2 - 4im 3]
return
end

Expand Down

0 comments on commit 1ce981e

Please sign in to comment.