Skip to content

Bug in SOCtoPSDBridge #838

@JiazhengZhu

Description

@JiazhengZhu

There is a bug in Bridges/Constraints/soc_to_psd.jl at line 19: https://github.com/JuliaOpt/MathOptInterface.jl/blob/f5a10367c70aad3ff26adc062462498d0da41cec/src/Bridges/Constraint/soc_to_psd.jl#L19

Here the constant vector for the resultant VAF was not filled in correctly. It seems that the constants from input VAF f was directly written into the beginning of this vector, rather than going into the entries corresponding to the vectorised matrix using trimap. For this part the code perhaps should be

constant = zeros(T, n)
    for i in 1:dim
        constant[trimap(i,1)] = f.constants[i]
    end

A non-working example would be

using SCS
using MathOptInterface
MOI = MathOptInterface
MOIU = MathOptInterface.Utilities
MOIU.@model(ModelData, (), (),
                         (MOI.Zeros, MOI.Nonnegatives, MOI.SecondOrderCone,
                          MOI.ExponentialCone, MOI.PositiveSemidefiniteConeTriangle),
                         (), (), (), (), (MOI.VectorAffineFunction,));
x = MOI.add_variables(MOIU.CachingOptimizer(MOIU.UniversalFallback(ModelData{Float64}()), SCS.Optimizer()), 3);
Fterms = MOI.ScalarAffineTerm.([0., 0., 0.], x);
F = MOI.VectorAffineFunction(MOI.VectorAffineTerm.([1, 2, 3], Fterms), [1., 2., 3.]);
g = MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.([0., 0., 0.], x), 4.);
psd_constr = MOI.Bridges._SOCtoPSDaff(F, g);
psd_constr.constants

So the constants in the output VAF should be a vector representation of the upper triangular part of

when every entry is labelled vertically. However, the output VAF has a constant vector [1.0, 2.0, 4.0, 0.0, 0.0, 4.0] where the expected return would be [1.0, 2.0, 4.0, 3.0, 0.0, 4.0]. In fact the original code would be correct if trimap labelled the entries horizontally instead.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions