@@ -314,6 +314,51 @@ function solve_qp_edge_cases(model::MOI.ModelLike, config::TestConfig)
314314end
315315unittests[" solve_qp_edge_cases" ] = solve_qp_edge_cases
316316
317+ """
318+ solve_qp_zero_offdiag(model::MOI.ModelLike, config::TestConfig)
319+
320+ Test quadratic program with a zero off-diagonal term.
321+
322+ If `config.solve=true` confirm that it solves correctly.
323+ """
324+ function solve_qp_zero_offdiag (model:: MOI.ModelLike , config:: TestConfig )
325+ MOI. empty! (model)
326+ x = MOI. add_variables (model, 2 )
327+ MOI. set (model, MOI. ObjectiveSense (), MOI. MIN_SENSE)
328+ vc1 = MOI. add_constraint (
329+ model,
330+ MOI. SingleVariable (x[1 ]),
331+ MOI. GreaterThan (1.0 ),
332+ )
333+ @test vc1. value == x[1 ]. value
334+ vc2 = MOI. add_constraint (
335+ model,
336+ MOI. SingleVariable (x[2 ]),
337+ MOI. GreaterThan (2.0 ),
338+ )
339+ @test vc2. value == x[2 ]. value
340+ MOI. set (
341+ model,
342+ MOI. ObjectiveFunction {MOI.ScalarQuadraticFunction{Float64}} (),
343+ MOI. ScalarQuadraticFunction (
344+ MOI. ScalarAffineTerm{Float64}[], # affine terms
345+ MOI. ScalarQuadraticTerm .(
346+ [2.0 , 0.0 , 2.0 ],
347+ [x[1 ], x[1 ], x[2 ]],
348+ [x[1 ], x[2 ], x[2 ]],
349+ ), # quad
350+ 0.0 , # constant
351+ ),
352+ )
353+ test_model_solution (
354+ model,
355+ config;
356+ objective_value = 5.0 ,
357+ variable_primal = [(x[1 ], 1.0 ), (x[2 ], 2.0 )],
358+ )
359+ end
360+ unittests[" solve_qp_zero_offdiag" ] = solve_qp_zero_offdiag
361+
317362"""
318363 solve_duplicate_terms_obj(model::MOI.ModelLike, config::TestConfig)
319364
0 commit comments