Commit c39bbd3 1 parent 3829fb2 commit c39bbd3 Copy full SHA for c39bbd3
File tree 2 files changed +41
-5
lines changed
2 files changed +41
-5
lines changed Original file line number Diff line number Diff line change @@ -1101,6 +1101,21 @@ nonnegative.
1101
1101
` x ` must be a square 2-dimensional ` Array ` of JuMP variables; it cannot be a
1102
1102
DenseAxisArray or a SparseAxisArray.
1103
1103
1104
+ Use [ ` VariableInSetRef ` ] ( @ref ) to obtain the associated constraint reference:
1105
+
1106
+ ``` jldoctest
1107
+ julia> model = Model();
1108
+
1109
+ julia> @variable(model, x[1:2, 1:2], PSD)
1110
+ 2×2 LinearAlgebra.Symmetric{VariableRef, Matrix{VariableRef}}:
1111
+ x[1,1] x[1,2]
1112
+ x[1,2] x[2,2]
1113
+
1114
+ julia> c = VariableInSetRef(x)
1115
+ [x[1,1] x[1,2]
1116
+ ⋯ x[2,2]] ∈ PSDCone()
1117
+ ```
1118
+
1104
1119
The ` PSD ` argument must be provided explicitly to the macro. Passing it via a
1105
1120
variable throws an error:
1106
1121
``` jldoctest
Original file line number Diff line number Diff line change 25
25
26
26
using JuMP
27
27
import Dualization
28
+ import LinearAlgebra
28
29
import SCS
29
30
30
31
# ## Background
@@ -116,7 +117,11 @@ print(model_primal)
116
117
model_dual = Model ()
117
118
@variable (model_dual, y[1 : 2 ])
118
119
@objective (model_dual, Min, sum (y))
119
- @constraint (model_dual, dual_c, [y[1 ]- 1 1 ; 1 y[2 ]- 1 ] in PSDCone ())
120
+ @constraint (
121
+ model_dual,
122
+ dual_c,
123
+ LinearAlgebra. Symmetric ([y[1 ]- 1 1 ; 1 y[2 ]- 1 ]) in PSDCone (),
124
+ )
120
125
print (model_dual)
121
126
122
127
# This problem has two scalar decision variables, and a 2x2 positive
@@ -141,7 +146,11 @@ assert_is_solved_and_feasible(model_primal; dual = true)
141
146
142
147
# The solution we obtain is:
143
148
144
- value .(X)
149
+ value (X)
150
+
151
+ # -
152
+
153
+ dual (VariableInSetRef (X))
145
154
146
155
# -
147
156
@@ -161,7 +170,11 @@ assert_is_solved_and_feasible(model_dual; dual = true)
161
170
162
171
# and the solution we obtain is:
163
172
164
- dual .(dual_c)
173
+ dual (dual_c)
174
+
175
+ # -
176
+
177
+ value (dual_c)
165
178
166
179
# -
167
180
@@ -192,7 +205,11 @@ assert_is_solved_and_feasible(model_primal; dual = true)
192
205
# The performance is the same as if we solved `model_dual`, and the correct
193
206
# solution is returned to `X`:
194
207
195
- value .(X)
208
+ value (X)
209
+
210
+ # -
211
+
212
+ dual (VariableInSetRef (X))
196
213
197
214
# -
198
215
@@ -207,7 +224,11 @@ assert_is_solved_and_feasible(model_dual; dual = true)
207
224
208
225
# -
209
226
210
- dual .(dual_c)
227
+ dual (dual_c)
228
+
229
+ # -
230
+
231
+ value (dual_c)
211
232
212
233
# -
213
234
You can’t perform that action at this time.
0 commit comments