@@ -1602,6 +1602,34 @@ function test_highs_int_frac_ub()
16021602 return
16031603end
16041604
1605+ function test_infix_unary_minus ()
1606+ model = MOI. Utilities. Model {Float64} ()
1607+ x, _ = MOI. add_constrained_variable (model, MOI. Interval (1.0 , 3.0 ))
1608+ solver = MiniZinc. Optimizer {Float64} (" highs" )
1609+ f = MOI. ScalarNonlinearFunction (:- , Any[x])
1610+ MOI. set (model, MOI. ObjectiveSense (), MOI. MAX_SENSE)
1611+ MOI. set (model, MOI. ObjectiveFunction {typeof(f)} (), f)
1612+ index_map, _ = MOI. optimize! (solver, model)
1613+ @test MOI. get (solver, MOI. VariablePrimal (), index_map[x]) ≈ 1.0
1614+ @test MOI. get (solver, MOI. ObjectiveValue ()) ≈ - 1.0
1615+ return
1616+ end
1617+
1618+ function test_infix_unary_addition ()
1619+ for op in (:+ , :* )
1620+ model = MOI. Utilities. Model {Float64} ()
1621+ x, _ = MOI. add_constrained_variable (model, MOI. Interval (1.0 , 3.0 ))
1622+ solver = MiniZinc. Optimizer {Float64} (" highs" )
1623+ f = MOI. ScalarNonlinearFunction (op, Any[x])
1624+ MOI. set (model, MOI. ObjectiveSense (), MOI. MAX_SENSE)
1625+ MOI. set (model, MOI. ObjectiveFunction {typeof(f)} (), f)
1626+ index_map, _ = MOI. optimize! (solver, model)
1627+ @test MOI. get (solver, MOI. VariablePrimal (), index_map[x]) ≈ 3.0
1628+ @test MOI. get (solver, MOI. ObjectiveValue ()) ≈ 3.0
1629+ end
1630+ return
1631+ end
1632+
16051633end
16061634
16071635TestMiniZinc. runtests ()
0 commit comments