Skip to content

Commit 0b1ac38

Browse files
authored
[docs] update MATLAB tutorial (#4012)
1 parent 742d7d6 commit 0b1ac38

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

docs/src/tutorials/transitioning/transitioning_from_matlab.jl

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,7 @@ is_solved_and_feasible(model)
197197
# of your variables after optimization is done, with the function call `value(x)`
198198
# to obtain the value of variable `x`.
199199

200-
value.(m[1][1, 1])
201-
202-
# A subtlety is that, unlike YALMIP, the function `value` is only defined for
203-
# scalars. For vectors and matrices you need to use Julia broadcasting:
204-
# `value.(v)`.
205-
206-
value.(m[1])
200+
value(x)
207201

208202
# There is also a specialized function for extracting the value of the objective,
209203
# `objective_value(model)`, which is useful if your objective doesn't have a
@@ -365,18 +359,18 @@ function random_state_pure(d)
365359
end
366360

367361
function robustness_jump(d)
368-
rho = random_state_pure(d^2)
362+
ρ = random_state_pure(d^2)
369363
id = LinearAlgebra.Hermitian(LinearAlgebra.I(d^2))
370-
rhoT = LinearAlgebra.Hermitian(partial_transpose(rho, 1, [d, d]))
364+
ρᵀ = LinearAlgebra.Hermitian(partial_transpose(ρ, 1, [d, d]))
371365
model = Model(Clarabel.Optimizer)
372366
set_attribute(model, "verbose", false)
373367
@variable(model, λ)
374-
@constraint(model, PPT, rhoT + λ * id in HermitianPSDCone())
368+
@constraint(model, PPT, ρᵀ + λ * id in HermitianPSDCone())
375369
@objective(model, Min, λ)
376370
optimize!(model)
377371
assert_is_solved_and_feasible(model; allow_almost = true)
378-
WT = dual(PPT)
379-
return value(λ), real(LinearAlgebra.dot(WT, rhoT))
372+
Wᵀ = dual(PPT)
373+
return value(λ), LinearAlgebra.dot(Wᵀ, ρᵀ)
380374
end
381375

382376
robustness_jump(3)

0 commit comments

Comments
 (0)