Cones
ConicSolve.NonNegativeOrthant
— TypeNonNegativeOrthant
Represents a nonnegative p-vector conic constraint.
ConicSolve.PSDCone
— TypePSDCone
Represents a positive semidefinite cone constraint.
ConicSolve.SecondOrderCone
— TypeSecondOrderCone
Represents a second order cone constraint.
SDP
ConicSolve.SDP
— TypeSDP
Represents a Semidefinite Program (SDP).
i.e. An optimization of the form
\[\begin{aligned} \text{minimize}\qquad & c^Tx \\ \text{subject to}\qquad & Ax = b \\ & x \succeq 0 \end{aligned}\]
NOTE: Linear Matrix Inequalities not supported yet.
ConicSolve.get_X1
— Methodget_X1(sdp, x)
Returns the values of X1 in the SDP matrix
\[X = \begin{bmatrix} X_2 & X_1^T \\ X_1 & X_4 \end{bmatrix}\]
ConicSolve.get_off_diag_nonnegative_constraint
— Methodget_off_diag_nonnegative_constraint(A)
Set a nonnegative constraint on the off diagonal entries of the SDP matrix.
Output
The matrix G to pass as argument to ConeQP.
ConicSolve.get_trace
— Methodget_trace(sdp)
Used to express the trace of the decision variable $X$ in the objective function.
Output
The vector c to pass as argument to ConeQP.
ConicSolve.sdp_to_qp
— Methodsdp_to_qp(sdp)
Get the Cone QP object representing the SDP problem
ConicSolve.set_b_from_data
— Methodset_b_from_data(sdp, data)
Set the values of the vector b in ConeQP based on the data matrix.
ConicSolve.set_nonnegative_constraint
— Methodset_nonnegative_constraint(sdp)
Impose a nonnegative constraint on all values of the SDP matrix.
ConicSolve.set_objective
— Methodset_objective(sdp, c)
Set the objective function of the SDP, which is the function $\langle c, x \rangle$
ConicSolve.set_off_diag_constraint
— Methodset_off_diag_constraint(sdp, data, mask)
Set the off diagonal entries in the SDP matrix. i.e. [Y data; data' Z] The mask is a boolean matrix that corresponds to which elements of the data matrix to keep.
Output
The precomputed matrices A, G and the vector b to pass as arguments to ConeQP.
ConicSolve.set_values
— Methodset_values(sdp, mask)
Set linear equalities of the SDP constraints where values of the SDP matrix $X$ are determined by $X_1$ and the mask.
if mask[i, j]
X_1[i, j] = X_1[i, j]
end
SOS
ConicSolve.SOS
— TypeSOS
Represents a Sum of Squares Optimization (SOS) Program.
The univariate polynomial $p(x) = a_nx^n + a_{n-1}x^{n-1} + ... + a_{1}x^1 + a_0$ is represented in quadratic form as: $p(x) = v^TQv$ where:
\[v = \begin{bmatrix} x^n \\ x^{n-1} \\ ... \\ x^{1} \\ 1 \end{bmatrix}\]
Multivariate polynomials and other monomial basis are not supported at this stage.
ConicSolve.add_polynomial_equality_constraint
— Methodadd_polynomial_equality_constraint(sos, b, p)
Set an equality constraint on the polynomial to equal the value b.
ConicSolve.add_polynomial_inequality_constraint
— Methodadd_polynomial_inequality_constraint(sos, h, p)
Set an inequality constraint on the polynomial to equal the value h.
ConicSolve.set_objective
— Methodset_objective(sos, P, c)
Set the objective function of the SOS
ConicSolve.set_objective
— Methodset_objective(sos, c)
Set the objective function of the SOS, which is the function $\langle c, x \rangle$
ConicSolve.sos_to_qp
— Methodsos_to_qp(sos)
Get the Cone QP object representing the SOS optimization problem
Solver
ConicSolve.qr_chol_solve
— Functionqr_chol_solve(device, kktsystem, b_x, b_y, b_z, check)
Calculates the vectors $x$ and $y$ (if linear equality constraints present) by solving the KKT system of linear equations where the KKT matrix is given by kktsystem, $K$ and b_x (i.e. $b_x$), b_z (i.e. $W^{-T}b_z$) are vectors and b_y (i.e. $b_y$, if linear equality constraints present).
Parameters
device
:CPU
orGPU
kktsystem
: KKTSystem objectb_x
: The x component of the vector bb_y
: The y component of the vector bb_z
: The z component of the vector bcheck
: true or false depending on whether matrix decompositions are valid
Output
The KKT solution vector [x; y; 0].
ConicSolve.ConeQP
— TypeConeQP
Represents a Conic Quadratic Program.
ConicSolve.KKTSystem
— TypeKKTSystem
The KKT System solved by the KKT solver. In the absence of linear equalities, the system solved is:
\[K = \begin{bmatrix} P & G^T \\ G & -W^TW \\ \end{bmatrix}\]
In the presence of linear equalities, the system solved is:
\[K = \begin{bmatrix} P & A^T & G^T \\ A & 0 & 0 \\ G & 0 & -W^TW \\ \end{bmatrix}\]
ConicSolve.Solver
— TypeSolver
Represents an Interior Point Method solver for solving Conic Quadratic Programs. All parameters are optional except program
.
Parameters:
cb_after_iteration
: Callback function of the form: function cb(solver::Solver) endcb_before_iteration
: Callback function of the form: function cb(solver::Solver) enddevice
: CPU or GPUprogram
: The Cone QP to solvekktsolver
: The object to represent the KKT solver used to solve the KKT system. Thekktsolve
argument will construct the appropriate KKTSolver object. Possible values for kktsolve areconjgrad
,minres
andqrchol
.qrchol
is the default.limit_obj
: The minimum/maximum objective value the solver will terminatelimit_soln
: The 2-norm difference between the current and previous estimatesmax_iterations
: The maximum number of iterations before the solver terminatesnum_threads
: The number of threads used on the CPU to perform certain BLAS and parallelized operationstime_limit_sec
: The maximum number of seconds elapsed before the solver terminates after the current iterationtol_gap_abs
: The absolute gap tolerancetol_gap_rel
: The relative gap tolerancetol_optimality
: The absolute tolerance for satisfying the optimality conditionsη
: Optimization parameter typically set to zero or σ, default is 0.0. Set η as nothing to set to σ.γ
: Mehrotra correction parameter set to γ ∈ [0, 1], default is 1.0
ConicSolve.get_objective
— Methodget_objective(P, c, x)
Get the current objective value to the conic quadratic program $x^TPx + c^Tx$
ConicSolve.get_solution
— Methodget_solution(solver)
Get the solution to the optimization problem.
ConicSolve.get_solver_status
— Methodget_solver_status(solver)
Returns the object of type SolverStatus
used by the solver.
ConicSolve.is_optimal
— Methodis_optimal(solver, gap_atol, gap_rtol, tol)
The stopping criterion used to determine convergence. Convergence is based on the following criteria:
- residuals close to zero (within tol)
- solution is primal-dual feasible
- duality gap close to zero (within tol)
- minimal change in primal objective value
ConicSolve.run_solver
— Functionrun_solver(solver)
Executes the solver on the optimization problem.
Helper Methods
ConicSolve.apply_cart_on_f
— Methodapply_cart_on_f(f, args...)
Output
Returns an array of f(x...) passing each value x of the cartesian product args... i.e. example input
a = [0, 1]
b = [3, 2]
vals = apply_cart_on_f(f, a, b)
yields vals = [f(0, 3), f(0, 2), f(1, 3), f(1, 2)]
ConicSolve.dropzero_rows
— Methoddropzero_rows(X)
Removes row of zeros from a given matrix X.
ConicSolve.get_block_matrix
— Methodget_block_matrix(X, x_l, y_l, x_u, y_u)
Get block matrix defined by the row and column range.
x_l <= i <= x_u
y_l <= j <= y_u
ConicSolve.get_diagonal_idx
— Methodget_diagonal_idx(n)
Get vectorized diagonal indices. For example, the following entries returned: idx = [1, 5, 8, 10] correspond to the matrix of n=4: [1 2 3 4; 2 5 6 7; 4 7 9 10]
ConicSolve.get_mask
— Methodget_mask(cond, data)
Creates a mask given a predicate function, cond against the data matrix.
ConicSolve.get_off_diagonal_idx
— Methodget_off_diagonal_idx(n)
Get vectorized lower triangular off diagonal indices. For example, the following entries returned: idx = [2, 3, 4, 6, 7, 9] correspond to the matrix of n=4: [1 2 3 4; 2 5 6 7; 3 6 8 9; 4 7 9 10]
ConicSolve.get_triangular_idx
— Methodget_triangular_idx(A_idx, mask)
Get vectorized lower triangular indices given a 2d mask.
ConicSolve.lower_triangular_from_2d_idx
— Methodlower_triangular_from_2d_idx(n, idx)
Converts 2d index values of a square matrix of size n x n.
Output
Return the index values of a vectorized lower triangular matrix.
ConicSolve.mat
— Methodmat(u)
Performs the inverse operation of vec(U), i.e. mat(vec(U)) = U
Output
Returns a matrix representation of the vector u.
\[\begin{bmatrix} u_{1} & u_{2}/\sqrt{2} & u_{3}/\sqrt{2} & \dots & u_{n}/\sqrt{2} \\ u_{2}/\sqrt{2} & u_{p+1} & u_{23}/\sqrt{2} & \dots & u_{2p-1}/\sqrt{2} \\ \vdots & \vdots & \vdots & & \vdots \\ u_{p}/\sqrt{2} & u_{2p-1}/\sqrt{2} & u_{d3}/\sqrt{2} & \dots & u_{p(p+1)/2} \end{bmatrix}\]
ConicSolve.svec
— Methodsvec(U)
Output
Returns a vectorized representation of the square matrix U as $(U_{11}, \sqrt{2}U_{21}, ..., \sqrt{2}U_{p1}, U_{22}, \sqrt{2}U_{32}, ..., \sqrt{2}U_{p2}, ..., U_{p-1,p-1}, \sqrt{2}U_{p,p-1}, U_{pp})$