@@ -1866,15 +1866,20 @@ function test_nonlinear_constraint_log(
18661866 x = MOI. add_variable (model)
18671867 t = MOI. add_variable (model)
18681868 MOI. add_constraint (model, x, MOI. LessThan (T (2 )))
1869+ MOI. set (model, MOI. VariablePrimalStart (), x, T (1 ))
18691870 MOI. set (model, MOI. ObjectiveSense (), MOI. MAX_SENSE)
18701871 f = 1.0 * t
1872+ # max t
1873+ # x <= 2
1874+ # log(x) >= t
18711875 MOI. set (model, MOI. ObjectiveFunction {typeof(f)} (), f)
18721876 g = MOI. ScalarNonlinearFunction (
18731877 :- ,
18741878 Any[MOI. ScalarNonlinearFunction (:log , Any[x]), t],
18751879 )
18761880 c = MOI. add_constraint (model, g, MOI. GreaterThan (T (0 )))
18771881 MOI. optimize! (model)
1882+ @test MOI. get (model, MOI. TerminationStatus ()) == config. optimal_status
18781883 x_val = MOI. get (model, MOI. VariablePrimal (), x)
18791884 t_val = MOI. get (model, MOI. VariablePrimal (), t)
18801885 @test ≈ (x_val, T (2 ), config)
@@ -1983,7 +1988,9 @@ function test_nonlinear_quadratic_1(
19831988 #
19841989 # -> x = y = 1/sqrt(2)
19851990 x = MOI. add_variable (model)
1991+ MOI. set (model, MOI. VariablePrimalStart (), x, T (1 ))
19861992 y = MOI. add_variable (model)
1993+ MOI. set (model, MOI. VariablePrimalStart (), y, T (1 ))
19871994 MOI. set (model, MOI. ObjectiveSense (), MOI. MAX_SENSE)
19881995 f = T (1 ) * x + T (1 ) * y
19891996 MOI. set (model, MOI. ObjectiveFunction {typeof(f)} (), f)
@@ -1993,6 +2000,7 @@ function test_nonlinear_quadratic_1(
19932000 g = MOI. ScalarNonlinearFunction (:sqrt , Any[f3])
19942001 c = MOI. add_constraint (model, g, MOI. LessThan (T (1 )))
19952002 MOI. optimize! (model)
2003+ @test MOI. get (model, MOI. TerminationStatus ()) == config. optimal_status
19962004 @test ≈ (MOI. get (model, MOI. ObjectiveValue ()), 2 / sqrt (2 ), config)
19972005 @test ≈ (MOI. get (model, MOI. VariablePrimal (), x), 1 / sqrt (2 ), config)
19982006 @test ≈ (MOI. get (model, MOI. VariablePrimal (), y), 1 / sqrt (2 ), config)
@@ -2029,7 +2037,9 @@ function test_nonlinear_quadratic_2(
20292037 #
20302038 # -> x = y = 1/sqrt(2)
20312039 x = MOI. add_variable (model)
2040+ MOI. set (model, MOI. VariablePrimalStart (), x, T (1 ))
20322041 y = MOI. add_variable (model)
2042+ MOI. set (model, MOI. VariablePrimalStart (), y, T (1 ))
20332043 MOI. set (model, MOI. ObjectiveSense (), MOI. MAX_SENSE)
20342044 f = T (1 ) * x + T (1 ) * y
20352045 MOI. set (model, MOI. ObjectiveFunction {typeof(f)} (), f)
@@ -2039,6 +2049,7 @@ function test_nonlinear_quadratic_2(
20392049 g = MOI. ScalarNonlinearFunction (:sqrt , Any[f3])
20402050 c = MOI. add_constraint (model, g, MOI. LessThan (T (1 )))
20412051 MOI. optimize! (model)
2052+ @test MOI. get (model, MOI. TerminationStatus ()) == config. optimal_status
20422053 @test ≈ (MOI. get (model, MOI. ObjectiveValue ()), 2 / sqrt (2 ), config)
20432054 @test ≈ (MOI. get (model, MOI. VariablePrimal (), x), 1 / sqrt (2 ), config)
20442055 @test ≈ (MOI. get (model, MOI. VariablePrimal (), y), 1 / sqrt (2 ), config)
@@ -2075,7 +2086,9 @@ function test_nonlinear_quadratic_3(
20752086 #
20762087 # -> x = y = 1/sqrt(2)
20772088 x = MOI. add_variable (model)
2089+ MOI. set (model, MOI. VariablePrimalStart (), x, T (1 ))
20782090 y = MOI. add_variable (model)
2091+ MOI. set (model, MOI. VariablePrimalStart (), y, T (1 ))
20792092 MOI. set (model, MOI. ObjectiveSense (), MOI. MAX_SENSE)
20802093 f = T (1 ) * x + T (1 ) * y
20812094 MOI. set (model, MOI. ObjectiveFunction {typeof(f)} (), f)
@@ -2085,6 +2098,7 @@ function test_nonlinear_quadratic_3(
20852098 g = MOI. ScalarNonlinearFunction (:sqrt , Any[f3])
20862099 c = MOI. add_constraint (model, g, MOI. LessThan (T (1 )))
20872100 MOI. optimize! (model)
2101+ @test MOI. get (model, MOI. TerminationStatus ()) == config. optimal_status
20882102 @test ≈ (MOI. get (model, MOI. ObjectiveValue ()), 2 / sqrt (2 ), config)
20892103 @test ≈ (MOI. get (model, MOI. VariablePrimal (), x), 1 / sqrt (2 ), config)
20902104 @test ≈ (MOI. get (model, MOI. VariablePrimal (), y), 1 / sqrt (2 ), config)
@@ -2120,7 +2134,9 @@ function test_nonlinear_quadratic_4(
21202134 #
21212135 # -> x = y = 1/sqrt(2)
21222136 x = MOI. add_variable (model)
2137+ MOI. set (model, MOI. VariablePrimalStart (), x, T (1 ))
21232138 y = MOI. add_variable (model)
2139+ MOI. set (model, MOI. VariablePrimalStart (), y, T (1 ))
21242140 MOI. set (model, MOI. ObjectiveSense (), MOI. MAX_SENSE)
21252141 f = T (1 ) * x + T (1 ) * y
21262142 MOI. set (model, MOI. ObjectiveFunction {typeof(f)} (), f)
@@ -2130,6 +2146,7 @@ function test_nonlinear_quadratic_4(
21302146 g = MOI. ScalarNonlinearFunction (:sqrt , Any[f3])
21312147 c = MOI. add_constraint (model, g, MOI. LessThan (T (1 )))
21322148 MOI. optimize! (model)
2149+ @test MOI. get (model, MOI. TerminationStatus ()) == config. optimal_status
21332150 @test ≈ (MOI. get (model, MOI. ObjectiveValue ()), 2 / sqrt (2 ), config)
21342151 @test ≈ (MOI. get (model, MOI. VariablePrimal (), x), 1 / sqrt (2 ), config)
21352152 @test ≈ (MOI. get (model, MOI. VariablePrimal (), y), 1 / sqrt (2 ), config)
0 commit comments