Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Mar 4, 2024
1 parent 1cd76ea commit c5678c1
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions docs/src/tutorials/getting_started/transitioning_from_matlab.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,29 @@ model = Model()
# | JuMP | YALMIP | CVX |
# | :------------------------------------------------ | :-------------------------------------- | :-------------------------- |
# | `@variable(model, x)` | `x = sdpvar` | `variable x` |
# | `@variable(model, x, Int)` | `x = intvar` | `variable x integer` |
# | `@variable(model, x, Bin)` | `x = binvar` | `variable x binary` |
# | `@variable(model, v[1:d])` | `v = sdpvar(d, 1)` | `variable v(d)` |
# | `@variable(model, m[1:d, 1:d])` | `m = sdpvar(d,d,'full')` | `variable m(d, d)` |
# | `@variable(model, m[1:d, 1:d] in ComplexPlane())` | `m = sdpvar(d,d,'full','complex')` | `variable m(d,d) complex` |
# | `@variable(model, m[1:d, 1:d], Symmetric)` | `m = sdpvar(d)` | `variable m(d,d) symmetric` |
# | `@variable(model, m[1:d, 1:d], Hermitian)` | `m = sdpvar(d,d,'hermitian','complex')` | `variable m(d,d) hermitian` |

# Like CVX, but unlike YALMIP, JuMP can also constrain variables upon creation:

# | JuMP | CVX |
# | :---------------------------------------------------- | :------------------------------------- |
# | `@variable(model, v[1:d] >= 0)` | `variable v(d) nonnegative` |
# | `@variable(model, m[1:d, 1:d], PSD)` | `variable m(d,d) semidefinite` |
# | `@variable(model, m[1:d, 1:d] in PSDCone())` | `variable m(d,d) semidefinite` |
# | `@variable(model, m[1:d, 1:d] in HermitianPSDCone())` | `variable m(d,d) complex semidefinite` |

# JuMP can additionally set variable bounds, which may be handled more
# efficiently by a solver than an equivalent linear constraint. For example:

@variable(model, -1 <= x[i in 1:3] <= i)
upper_bound.(x)

# A more interesting case is when you want to declare, for example, `n` real
# symmetric matrices. Both YALMIP and CVX allow you to put the matrices as the
# slices of a 3-dimensional array, via the commands `m = sdpvar(d, d, n)` and
Expand Down Expand Up @@ -118,14 +135,6 @@ m[2]
# `PSDCone()` or `HermitianPSDCone()` to make a matrix positive semidefinite, as
# the `>=` ambiguity in YALMIP is common source of bugs.

# Like CVX, but unlike YALMIP, JuMP can also constrain variables upon creation:

# | JuMP | CVX |
# | :---------------------------------------------------- | :------------------------------------- |
# | `@variable(model, v[1:d] >= 0)` | `variable v(d) nonnegative` |
# | `@variable(model, m[1:d, 1:d] in PSDCone())` | `variable m(d,d) semidefinite` |
# | `@variable(model, m[1:d, 1:d] in HermitianPSDCone())` | `variable m(d,d) complex semidefinite` |

# ## Setting the objective

# Like CVX, but unlike YALMIP, JuMP has a specific command for setting an
Expand Down

0 comments on commit c5678c1

Please sign in to comment.