From 2634e1185d75e7ca0796df689fc10e8dac510726 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 29 Jun 2023 10:06:35 +1200 Subject: [PATCH] Update tips_and_tricks.jl --- docs/src/tutorials/conic/tips_and_tricks.jl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/src/tutorials/conic/tips_and_tricks.jl b/docs/src/tutorials/conic/tips_and_tricks.jl index e6ea9b74842..2d7f7b46bdf 100644 --- a/docs/src/tutorials/conic/tips_and_tricks.jl +++ b/docs/src/tutorials/conic/tips_and_tricks.jl @@ -95,7 +95,7 @@ set_silent(model) @variable(model, x[1:3]) @variable(model, t) @constraint(model, sum(x) == 1) -@constraint(model, [t; x] in SecondOrderCone()) +@constraint(model, (t, x) in SecondOrderCone()) @objective(model, Min, t) optimize!(model) value(t), value.(x) @@ -117,7 +117,7 @@ set_silent(model) @variable(model, θ) @variable(model, t) @expression(model, residuals, θ * data .- target) -@constraint(model, [t; 0.5; residuals] in RotatedSecondOrderCone()) +@constraint(model, (t, 0.5, residuals) in RotatedSecondOrderCone()) @objective(model, Min, t) optimize!(model) value(θ), value(t) @@ -140,7 +140,7 @@ set_silent(model) @variable(model, x == 1.5) @variable(model, z) @objective(model, Min, z) -@constraint(model, [x, 1, z] in MOI.ExponentialCone()) +@constraint(model, (x, 1, z) in MOI.ExponentialCone()) optimize!(model) value(z), exp(1.5) @@ -153,7 +153,7 @@ set_silent(model) @variable(model, x) @variable(model, z == 1.5) @objective(model, Max, x) -@constraint(model, [x, 1, z] in MOI.ExponentialCone()) +@constraint(model, (x, 1, z) in MOI.ExponentialCone()) optimize!(model) value(x), log(1.5) @@ -170,7 +170,7 @@ set_silent(model) @objective(model, Min, t) @variable(model, u[1:N]) @constraint(model, sum(u) <= 1) -@constraint(model, [i = 1:N], [x[i] - t, 1, u[i]] in MOI.ExponentialCone()) +@constraint(model, [i = 1:N], (x[i] - t, 1, u[i]) in MOI.ExponentialCone()) optimize!(model) value(t), log(sum(exp.(x0))) @@ -214,7 +214,7 @@ set_silent(model) @objective(model, Max, sum(t)) @constraint(model, sum(x) == 1) @constraint(model, A * x .<= b) -@constraint(model, [i = 1:n], [t[i], x[i], 1] in MOI.ExponentialCone()) +@constraint(model, [i = 1:n], (t[i], x[i], 1) in MOI.ExponentialCone()) optimize!(model) objective_value(model) @@ -232,7 +232,7 @@ set_silent(model) @objective(model, Max, -t) @constraint(model, sum(x) == 1) @constraint(model, A * x .<= b) -@constraint(model, [t; ones(n); x] in MOI.RelativeEntropyCone(2n + 1)) +@constraint(model, (t, ones(n), x) in MOI.RelativeEntropyCone(2n + 1)) optimize!(model) objective_value(model) @@ -252,7 +252,7 @@ model = Model(SCS.Optimizer) set_silent(model) @variable(model, t) @variable(model, x >= 1.5) -@constraint(model, [t, 1, x] in MOI.PowerCone(1 / 3)) +@constraint(model, (t, 1, x) in MOI.PowerCone(1 / 3)) @objective(model, Min, t) optimize!(model) value(t), value(x) @@ -273,7 +273,7 @@ function p_norm(x::Vector, p) set_silent(model) @variable(model, r[1:N]) @variable(model, t) - @constraint(model, [i = 1:N], [r[i], t, x[i]] in MOI.PowerCone(1 / p)) + @constraint(model, [i = 1:N], (r[i], t, x[i]) in MOI.PowerCone(1 / p)) @constraint(model, sum(r) == t) @objective(model, Min, t) optimize!(model) @@ -334,7 +334,7 @@ set_silent(model) @variable(model, x[1:4]) @variable(model, t) @constraint(model, sum(x) == 1) -@constraint(model, [t; x] in MOI.GeometricMeanCone(5)) +@constraint(model, (t, x) in MOI.GeometricMeanCone(5)) optimize!(model) value(t), value.(x)