File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,11 @@ constraint = x == 0
100100constraint = x >= 1
101101```
102102
103+ Note that constraints apply elementwise automatically; that is, ` x >= 1 ` means
104+ that ` x[i, j] >= 1 ` for ` i in 1:5 ` and ` j in 1:5 ` . Consequently, broadcasting
105+ should not be used to constrain arrays, that is, use ` x >= y ` instead of
106+ ` x .>= y ` .
107+
103108Matrices can also be constrained to be positive semidefinite.
104109
105110``` julia
Original file line number Diff line number Diff line change @@ -1282,6 +1282,15 @@ function test_variable_primal_start()
12821282 return
12831283end
12841284
1285+ function test_broadcasting ()
1286+ A = [1 2 ; 3 4 ]
1287+ x = Variable (2 )
1288+ y = [1.1 , 2.2 ]
1289+ @test_throws MethodError (A * x) .<= y
1290+ @test sprint (show, x .== y) == sprint (show, [x[i] == y[i] for i in 1 : 2 ])
1291+ return
1292+ end
1293+
12851294end # TestUtilities
12861295
12871296TestUtilities. runtests ()
You can’t perform that action at this time.
0 commit comments