Are you talking about formulating the problem with Convex.jl? Convex has a pretty different syntax; check out e.g. this tutorial to see.
Convex also works somewhat differently than JuMP, since it is designed around conic problems; see for example this section of the docs on extended formulations. That means nonlinear solvers like Ipopt canβt be used with Convex.jl.
However, your problem does seem to have a conic formulation you can use with Convex:
julia> using Convex, COSMO
julia> x1 = Variable()
Variable
size: (1, 1)
sign: real
vexity: affine
id: 251β¦394
julia> x2 = Variable()
Variable
size: (1, 1)
sign: real
vexity: affine
id: 745β¦182
julia> objective = 126 * x1 - 9 * square(x2) + 182 * x2 - 13 * square(x2)
+ (concave; real)
ββ * (affine; real)
β ββ 126
β ββ real variable (id: 251β¦394)
ββ - (concave; negative)
β ββ * (convex; positive)
β ββ 9
β ββ qol_elem (convex; positive)
β ββ β¦
β ββ β¦
ββ * (affine; real)
β ββ 182
β ββ real variable (id: 745β¦182)
ββ - (concave; negative)
ββ * (convex; positive)
ββ 13
ββ qol_elem (convex; positive)
ββ β¦
ββ β¦
julia> constrs = [ x1 <= 4, 2*x2 <= 12, 3*x1 + 2*x2 <= 25 ]
3-element Array{Convex.LtConstraint,1}:
<= constraint (affine)
ββ real variable (id: 251β¦394)
ββ 4
<= constraint (affine)
ββ * (affine; real)
β ββ 2
β ββ real variable (id: 745β¦182)
ββ 12
<= constraint (affine)
ββ + (affine; real)
β ββ * (affine; real)
β β ββ 3
β β ββ real variable (id: 251β¦394)
β ββ * (affine; real)
β ββ 2
β ββ real variable (id: 745β¦182)
ββ 25
julia> problem = maximize(objective, constrs)
maximize
ββ + (concave; real)
ββ * (affine; real)
β ββ 126
β ββ real variable (id: 251β¦394)
ββ - (concave; negative)
β ββ * (convex; positive)
β ββ β¦
β ββ β¦
ββ * (affine; real)
β ββ 182
β ββ real variable (id: 745β¦182)
ββ - (concave; negative)
ββ * (convex; positive)
ββ β¦
ββ β¦
subject to
ββ <= constraint (affine)
β ββ real variable (id: 251β¦394)
β ββ 4
ββ <= constraint (affine)
β ββ * (affine; real)
β β ββ 2
β β ββ real variable (id: 745β¦182)
β ββ 12
ββ <= constraint (affine)
ββ + (affine; real)
β ββ * (affine; real)
β β ββ β¦
β β ββ β¦
β ββ * (affine; real)
β ββ β¦
β ββ β¦
ββ 25
status: `solve!` not called yet
julia> solve!(problem, COSMO.Optimizer)
------------------------------------------------------------------
COSMO v0.7.7 - A Quadratic Objective Conic Solver
Michael Garstka
University of Oxford, 2017 - 2020
------------------------------------------------------------------
Problem: x β R^{5},
constraints: A β R^{12x5} (15 nnz),
matrix size to factor: 17x17,
Floating-point precision: Float64
Sets: Nonnegatives of dim: 5
SecondOrderCone of dim: 3
SecondOrderCone of dim: 3
ZeroSet of dim: 1
Settings: Ο΅_abs = 1.0e-04, Ο΅_rel = 1.0e-04,
Ο΅_prim_inf = 1.0e-06, Ο΅_dual_inf = 1.0e-04,
Ο = 0.1, Ο = 1e-06, Ξ± = 1.6,
max_iter = 2500,
scaling iter = 10 (on),
check termination every 40 iter,
check infeasibility every 40 iter,
KKT system solver: QDLDL
Setup Time: 0.06ms
Iter: Objective: Primal Res: Dual Res: Rho:
1 -4.8505e+03 5.3450e+01 5.4218e+01 1.0000e-01
40 -1.0916e+03 5.9188e-01 2.7359e-01 1.0000e-01
80 -8.2161e+02 1.9067e-01 1.3309e+00 1.0000e-01
120 -9.1560e+02 1.0889e-01 8.2135e-01 1.0000e-01
160 -8.6509e+02 5.7417e-02 4.1368e-01 1.0000e-01
200 -8.8906e+02 2.9174e-02 2.2977e-01 1.0000e-01
240 -8.7667e+02 1.7140e-02 1.2106e-01 1.0000e-01
280 -8.8263e+02 8.6168e-03 6.4531e-02 1.0000e-01
320 -8.7954e+02 5.3640e-03 3.4586e-02 1.0000e-01
360 -8.8100e+02 2.7692e-03 1.8063e-02 1.0000e-01
400 -8.8022e+02 1.7995e-03 9.7904e-03 1.0000e-01
440 -8.8057e+02 9.6593e-04 5.0276e-03 1.0000e-01
480 -8.8038e+02 6.4959e-04 2.7635e-03 1.0000e-01
520 -8.8046e+02 3.6258e-04 1.3895e-03 1.0000e-01
560 -8.8041e+02 2.5010e-04 7.8054e-04 1.0000e-01
600 -8.8042e+02 1.4421e-04 3.8051e-04 1.0000e-01
640 -8.8041e+02 1.0115e-04 2.2133e-04 1.0000e-01
680 -8.8041e+02 5.9727e-05 1.0284e-04 1.0000e-01
------------------------------------------------------------------
>>> Results
Status: Solved
Iterations: 680
Optimal objective: -880.4
Runtime: 0.011s (10.85ms)
Then you can find the optimal value of the problem and the optimal values of the variables by
julia> problem.optval
880.4139895737471
julia> evaluate(x1)
4.000000045551431
julia> evaluate(x2)
4.1364021235771595
Here, Iβve chosen the optimizer COSMO.jl which supports the second-order cone (SOCP) formulation used in this problem, but you could also try any of the other solvers listed here which support SOCP constraints.
Edit(@odow): removed some spurious lines from the REPL output.