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
100
100
constraint = x >= 1
101
101
```
102
102
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
+
103
108
Matrices can also be constrained to be positive semidefinite.
104
109
105
110
``` julia
Original file line number Diff line number Diff line change @@ -1282,6 +1282,15 @@ function test_variable_primal_start()
1282
1282
return
1283
1283
end
1284
1284
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
+
1285
1294
end # TestUtilities
1286
1295
1287
1296
TestUtilities. runtests ()
You can’t perform that action at this time.
0 commit comments