cvx

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2024 License: LGPL-3.0 Imports: 11 Imported by: 0

README

cvx

Package cvx is a Go package for solving convex optimization problems.

Forked from https://github.com/hrautila/cvx and updated for newer versions of go.

Depends on access to BLAS and LAPACK linear algebra libraries.

Documentation

Overview

Package cvx is a package for solving convex optimization problems.

It is a straightforward translation of parts of the CVXOPT python package for convex optimization. Spefically it provides interfaces for solving linear and quadratic cone programs and convex programs with non-linear objectives.

Package cvx depends on column order matrix implementation and access to BLAS and LAPACK linear algebra libraries.

Solvers

Following solvers are provided:

ConeLp		Linear Cone programs
ConeQp		Quadratic Cone programs
Lp		Linear programs
Qp		Quadratic programs
Socp		Second-Order Cone programs
Sdp		Semidefinite programs
Cpl		Convex programs with linear objectives
Cp		Convex programs with non-linear objectives
Gp		Geometric programs

Main solvers for Cone Programs are ConeLp and ConeQp which provide interfaces for advanced usage with custom solvers.

The non-linear convex optimization solvers are Cp and Cpl. They provide interfaces for advanced usage with solvers.

The Lp, Qp, Socp, Sdp and Gp solvers provide only the standard matrix interface without any customization options.

Output

All solvers return

Extended Usage

Package support three levels of advanced usage to allow exploiting the problem structure.

Custom KKT Solver

On the first level a custom KKT solver can be provided to solve the KKT equations. The call f = KKTConeSolver(W) or f = KKTCpSolver(W, x, z)should return a function f that solves the KKT system by f(x, y, z). On entry, x, y, z contain the righthand side bx, by, bz. On exit, they contain the solution, with uz scaled: the argument z contains W*uz. In other words, on exit, x, y, z are the solution of

[ 0  A'  G'*W^{-1} ] [ ux ]   [ bx ]
[ A  0   0         ] [ uy ] = [ by ].
[ G  0  -W'        ] [ uz ]   [ bz ]

W is a scaling matrix, a block diagonal mapping

W*u = ( W0*u_0, ..., W_{N+M}*u_{N+M} )

defined as follows.

For the 'l' block (W_0):

W_0 = diag(d),

with d a positive vector of length ml.

For the 'q' blocks (W_{k+1}, k = 0, ..., N-1):

W_{k+1} = beta_k * ( 2 * v_k * v_k' - J )

where beta_k is a positive scalar, v_k is a vector in R^mq[k] with v_k[0] > 0 and v_k'*J*v_k = 1, and J = [1, 0; 0, -I].

For the 's' blocks (W_{k+N}, k = 0, ..., M-1):

W_k * u = vec(r_k' * mat(u) * r_k)

where r_k is a nonsingular matrix of order ms[k], and mat(x) is the inverse of the vec operation.

The kktsolver is a function that will be called as g = kktsolver(W) for ConeLp and ConeQp solvers. It will be called as g = kktsolver(W, x, z) for Cp and Cpl solvers.

W is a FloatMatrixSet that contains the parameters of the scaling:

W.At("d")    is a positive  matrix of size (ml,1). (array of size one)
W.At("di")   is a positive  matrix matrix with the elementwise inverse of W.At("d").
W.At("beta") is a matrix [ beta_0, ..., beta_{N-1} ]
W.At("v")    is an array [ v_0, ..., v_{N-1} ] of float matrices.
W.At("r")    is an array [ r_0, ..., r_{M-1} ] of matrices
W.At("rti")  is an array [ rti_0, ..., rti_{M-1} ],
             with rti_k the inverse of the transpose of r_k of W.At("rti")

Public interfaces providing this extension are named XxxCustomKKT where Xxx is solver name.

Specifying constraints via interfaces

In the default use the linear constraints G, A for ConeLP, ConeQp, Cp and Cpl solvers and the quadratic term P for ConeQp solver are defined as matrices. It is possible to specify these parameters as interfaces evaluating corresponding matrix-vector products and their adjoints. If constraints are specified as interfaces then kktsolver function must also be provided.

The argument G for ConeLp, ConeQp, Cp and Cpl can be defined as implementation of MatrixG interface. Then call Gf(u, v, alpha, beta, trans) should evaluate the matrix-vector products

v := alpha * G * u + beta * v   if trans is linalg.OptNoTrans
v := alpha * G' * u + beta * v  if trans is linalg.OptTrans

The argument A for ConeLp, ConeQp, Cp and Cpl can be defined as implementation of MatrixA interface. Then call Af(u, v, alpha, beta, trans) should evaluate the matrix-vector products

v := alpha * A * u + beta * v   if trans is linalg.OptNoTrans
v := alpha * A' * u + beta * v  if trans is linalg.OptTrans

The quadratic term P for ConeQp solver can be defines as implementation of MatrixP interface The call Pf(u, v, alpha, beta) should evaluate the matrix-vectors product.

v := alpha * P * u + beta * v.

Public interfaces providing this extension are named XxxCustomMatrix where Xxx is solver name.

Custom primal and dual variables

Currently no public interfaces are provided to use of non-matrix primal and dual variables. The main solvers ConeLp, ConeQp and Cpl are implemented with internal custom variable types.

Custom variables are specified as implementation of interface MatrixVariable.

Cvxopt User's Guide

For more detailed discussion on using solvers see

http://abel.ee.ucla.edu/cvxopt/userguide/index.html

Index

Constants

View Source
const (
	Optimal = StatusCode(1 + iota)
	PrimalInfeasible
	DualInfeasible
	Unknown
)
View Source
const (
	MAXITERS = 100
	ABSTOL   = 1e-7
	RELTOL   = 1e-6
	FEASTOL  = 1e-7
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConvexProg

type ConvexProg interface {
	// Returns (mnl, x0) where mln number of nonlinear inequality constraints
	// and x0 is a point in the domain of f.
	F0() (mnl int, x0 *matrix.FloatMatrix, err error)

	// Returns a tuple (f, Df) where f is of size (mnl, 1) containing f(x)
	// Df is matrix of size (mnl, n) containing the derivatives of f at x:
	// Df[k,:] is the transpose of the gradient of fk at x. If x is not in
	// domf, return non-nil error.
	F1(x *matrix.FloatMatrix) (f, Df *matrix.FloatMatrix, err error)

	// F(x, z) with z a positive  matrix of size (mnl, 1). Return a tuple
	// (f, Df, H), where f, Df as above. H is matrix of size (n, n).
	F2(x, z *matrix.FloatMatrix) (f, Df, H *matrix.FloatMatrix, err error)
}

ConvexProg is an interface that handles the following functions.

F0() returns a tuple (mnl, x0, error).

  • mnl is the number of nonlinear inequality constraints.
  • x0 is a point in the domain of f.

F1(x) returns a tuple (f, Df, error).

  • f is a matrix of size (mnl, 1) containing f(x).
  • Df is a matrix of size (mnl, n), containing the derivatives of f at x. Df[k,:] is the transpose of the gradient of fk at x. If x is not in dom f, F1(x) returns (nil, nil, error)

F2(x, z) with z a positive matrix of size (mnl,1), returns a tuple (f, Df, H, error).

  • f and Df are defined as above.
  • H is a matrix of size (n,n). The lower triangular part of H contains the lower triangular part of sum_k z[k] * Hk where Hk is the Hessian of fk at x.

When F2() is called, it can be assumed that x is dom f.

type ConvexVarProg

type ConvexVarProg interface {
	// Returns (mnl, x0) where mln number of nonlinear inequality constraints
	// and x0 is a point in the domain of f.
	F0() (mnl int, x0 MatrixVariable, err error)

	// Returns a tuple (f, Df) where f contains f(x) and Df is instance of
	// MatrixVarDf interface.
	F1(x MatrixVariable) (f MatrixVariable, Df MatrixVarDf, err error)

	// F(x, z) with z a positive matrix variable. Return a tuple
	// (f, Df, H), where f, Df as above. H is an instance of MatrixVarH interface.
	F2(x MatrixVariable, z *matrix.FloatMatrix) (f MatrixVariable, Df MatrixVarDf, H MatrixVarH, err error)
}

ConvexVarProg provides interface for extended customization with non-matrix type primal and dual variables.

type KKTConeSolver

type KKTConeSolver func(W *sets.FloatMatrixSet) (KKTFunc, error)

KKTConeSolver produces solver function for cone problems with matrix variables

type KKTConeSolverVar

type KKTConeSolverVar func(W *sets.FloatMatrixSet) (KKTFuncVar, error)

KKTConeSolver produces solver function for cone problems with custom variables

type KKTCpSolver

KKTCpSolver produces solver function for convex problems

type KKTCpSolverVar

type KKTCpSolverVar func(W *sets.FloatMatrixSet, x MatrixVariable, znl *matrix.FloatMatrix) (KKTFuncVar, error)

type KKTFunc

type KKTFunc func(x, y, z *matrix.FloatMatrix) error

KKTFunc solves KKT equations for matrix arguments

type KKTFuncVar

type KKTFuncVar func(x, y MatrixVariable, z *matrix.FloatMatrix) error

KKTFuncVar solves KKT equations for custom variable arguments

type MatrixA

type MatrixA interface {
	Af(u, v *matrix.FloatMatrix, alpha, beta float64, trans la.Option) error
}

Public interface to provide custom A matrix-vector products

The call Af(u, v, alpha, beta, trans) should evaluate the matrix-vector products

v := alpha * A * u + beta * v   if trans is linalg.OptNoTrans
v := alpha * A' * u + beta * v  if trans is linalg.OptTrans

type MatrixDf

type MatrixDf interface {
	Df(u, v *matrix.FloatMatrix, alpha, beta float64, trans la.Option) error
}

Public interface to provide custom Df matrix-vector products

The call Df(u, v, alpha, beta, trans) should evaluate the matrix-vectors products

v := alpha * Df(x) * u + beta * v if trans is linalg.OptNoTrans
v := alpha * Df(x)' * u + beta * v if trans is linalg.OptTrans.

type MatrixG

type MatrixG interface {
	Gf(u, v *matrix.FloatMatrix, alpha, beta float64, trans la.Option) error
}

Public interface to provide custom G matrix-vector products

The call Gf(u, v, alpha, beta, trans) should evaluate the matrix-vector products

v := alpha * G * u + beta * v   if trans is linalg.OptNoTrans
v := alpha * G' * u + beta * v  if trans is linalg.OptTrans

type MatrixH

type MatrixH interface {
	Hf(u, v *matrix.FloatMatrix, alpha, beta float64) error
}

Public interface to provide custom H matrix-vector products

The call H(u, v, alpha, beta) should evaluate the matrix-vectors product

v := alpha * H * u + beta * v.

type MatrixP

type MatrixP interface {
	Pf(u, v *matrix.FloatMatrix, alpha, beta float64) error
}

Public interface to provide custom P matrix-vector products

The call Pf(u, v, alpha, beta) should evaluate the matrix-vectors product.

v := alpha * P * u + beta * v.

type MatrixVarA

type MatrixVarA interface {
	Af(u, v MatrixVariable, alpha, beta float64, trans la.Option) error
}

MatrixVarA provides interface for extended customization with non-matrix type primal and dual variables.

type MatrixVarDf

type MatrixVarDf interface {
	Df(u, v MatrixVariable, alpha, beta float64, trans la.Option) error
}

MatrixVarDf provides interface for extended customization with non-matrix type primal and dual variables.

type MatrixVarG

type MatrixVarG interface {
	Gf(u, v MatrixVariable, alpha, beta float64, trans la.Option) error
}

MatrixVarG provides interface for extended customization with non-matrix type primal and dual variables.

type MatrixVarH

type MatrixVarH interface {
	Hf(u, v MatrixVariable, alpha, beta float64) error
}

MatrixVarH provides interface for extended customization with non-matrix type primal and dual variables.

type MatrixVarP

type MatrixVarP interface {
	Pf(u, v MatrixVariable, alpha, beta float64) error
}

MatrixVarP provides interface for extended customization with non-matrix type primal and dual variables.

type MatrixVariable

type MatrixVariable interface {
	// Provide internal matrix value
	Matrix() *matrix.FloatMatrix
	// Create a new copy
	Copy() MatrixVariable
	// Computes v := alpha*u + v for a scalar alpha and vectors u and v.
	Axpy(v MatrixVariable, alpha float64)
	// Return the inner product of two vectors u and v in a vector space.
	Dot(v MatrixVariable) float64
	// Computes u := alpha*u for a scalar alpha and vectors u in a vector space.
	Scal(alpha float64)
	// Implement checkpnt.Verifiable to allow checkpoint checking
	Verify(dataline string) float64
	// Implement checkpnt.Verifiable to allow checkpoint checking
	ShowError(dataline string)
	// Convert to string for printing
	String() string
}

MatrixVariable interface for any type used to represent primal variables and the dual variables as something else than one-column float matrices.

type Solution

type Solution struct {
	// Solution status
	Status StatusCode
	// Solution result set.
	Result *sets.FloatMatrixSet
	// The primal objective c'*x
	PrimalObjective float64
	// The dual objective value
	DualObjective float64
	// Solution duality gap.
	Gap float64
	// Solution relative gap
	RelativeGap float64
	// Solution primal infeasibility
	PrimalInfeasibility float64
	// Solution dual infeasibility: the residual of the dual contraints
	DualInfeasibility float64
	// The smallest primal slack: min( min_k sl_k, sup{t | sl >= te}
	PrimalSlack float64
	// The smallest dual slack: min( min_k sl_k, sup{t | sl >= te}
	DualSlack          float64
	PrimalResidualCert float64
	DualResidualCert   float64
	// Number of iterations run
	Iterations int
}

If the exit status is Optimal, then the primal and dual infeasibilities are guaranteed to be less than SolversOptions.FeasTol (default 1e-7). The gap is less than SolversOptions.AbsTol (default 1e-7) or the relative gap is less than SolversOptions.RelTol (defaults 1e-6).

Termination with status Unknown indicates that the algorithm failed to find a solution that satisfies the specified tolerances. In some cases, the returned solution may be fairly accurate. If the primal and dual infeasibilities, the gap, and the relative gap are small, then x, y, snl, sl, znl, zl are close to optimal.

func ConeLp

func ConeLp(c, G, h, A, b *matrix.FloatMatrix, dims *sets.DimensionSet, solopts *SolverOptions,
	primalstart, dualstart *sets.FloatMatrixSet) (sol *Solution, err error)

Solves a pair of primal and dual cone programs

minimize    c'*x
subject to  G*x + s = h
            A*x = b
            s >= 0

maximize    -h'*z - b'*y
subject to  G'*z + A'*y + c = 0
            z >= 0.

The inequalities are with respect to a cone C defined as the Cartesian product of N + M + 1 cones:

C = C_0 x C_1 x .... x C_N x C_{N+1} x ... x C_{N+M}.

The first cone C_0 is the nonnegative orthant of dimension ml. The next N cones are second order cones of dimension r[0], ..., r[N-1]. The second order cone of dimension m is defined as

{ (u0, u1) in R x R^{m-1} | u0 >= ||u1||_2 }.

The next M cones are positive semidefinite cones of order t[0], ..., t[M-1] >= 0.

The structure of C is specified by DimensionSet dims which holds following sets

dims.At("l")  l, the dimension of the nonnegative orthant (array of length 1)
dims.At("q")  r[0], ... r[N-1], list with the dimesions of the second-order cones
dims.At("s")  t[0], ... t[M-1], array with the dimensions of the positive
              semidefinite cones

The default value for dims is l: []int{G.Rows()}, q: []int{}, s: []int{}.

Arguments primalstart, dualstart are optional starting points for primal and dual problems. If non-nil then primalstart is a FloatMatrixSet having two entries.

primalstart.At("x")[0]  starting point for x
primalstart.At("s")[0]  starting point for s
dualstart.At("y")[0]    starting point for y
dualstart.At("z")[0]    starting point for z

On exit Solution contains the result and information about the accurancy of the solution. if SolutionStatus is Optimal then Solution.Result contains solutions for the problems.

Result.At("x")[0]  solution for x
Result.At("y")[0]  solution for y
Result.At("s")[0]  solution for s
Result.At("z")[0]  solution for z

func ConeLpCustomKKT

func ConeLpCustomKKT(c, G, h, A, b *matrix.FloatMatrix, dims *sets.DimensionSet,
	kktsolver KKTConeSolver, solopts *SolverOptions, primalstart,
	dualstart *sets.FloatMatrixSet) (sol *Solution, err error)

Solves a pair of primal and dual cone programs using custom KKT solver.

func ConeLpCustomMatrix

func ConeLpCustomMatrix(c *matrix.FloatMatrix, G MatrixG, h *matrix.FloatMatrix,
	A MatrixA, b *matrix.FloatMatrix, dims *sets.DimensionSet, kktsolver KKTConeSolver,
	solopts *SolverOptions, primalstart, dualstart *sets.FloatMatrixSet) (sol *Solution, err error)

Solves a pair of primal and dual cone programs using custom KKT solver and constraint interfaces MatrixG and MatrixA

func ConeQp

func ConeQp(P, q, G, h, A, b *matrix.FloatMatrix, dims *sets.DimensionSet, solopts *SolverOptions,
	initvals *sets.FloatMatrixSet) (sol *Solution, err error)

Solves a pair of primal and dual convex quadratic cone programs

minimize    (1/2)*x'*P*x + q'*x
subject to  G*x + s = h
            A*x = b
            s >= 0

maximize    -(1/2)*(q + G'*z + A'*y)' * pinv(P) * (q + G'*z + A'*y)
            - h'*z - b'*y
subject to  q + G'*z + A'*y in range(P)
            z >= 0.

The inequalities are with respect to a cone C defined as the Cartesian product of N + M + 1 cones:

C = C_0 x C_1 x .... x C_N x C_{N+1} x ... x C_{N+M}.

The first cone C_0 is the nonnegative orthant of dimension ml. The next N cones are 2nd order cones of dimension r[0], ..., r[N-1]. The second order cone of dimension m is defined as

{ (u0, u1) in R x R^{m-1} | u0 >= ||u1||_2 }.

The next M cones are positive semidefinite cones of order t[0], ..., t[M-1] >= 0.

The structure of C is specified by DimensionSet dims which holds following sets

dims.At("l")  l, the dimension of the nonnegative orthant (array of length 1)
dims.At("q")  r[0], ... r[N-1], list with the dimesions of the second-order cones
dims.At("s")  t[0], ... t[M-1], array with the dimensions of the positive
              semidefinite cones

The default value for dims is l: []int{G.Rows()}, q: []int{}, s: []int{}.

Argument initval contains optional starting points for primal and dual problems. If non-nil then initval is a FloatMatrixSet having following entries.

initvals.At("x")[0]  starting point for x
initvals.At("s")[0]  starting point for s
initvals.At("y")[0]  starting point for y
initvals.At("z")[0]  starting point for z

On exit Solution contains the result and information about the accurancy of the solution. if SolutionStatus is Optimal then Solution.Result contains solutions for the problems.

Result.At("x")[0]  solution for x
Result.At("y")[0]  solution for y
Result.At("s")[0]  solution for s
Result.At("z")[0]  solution for z

func ConeQpCustomKKT

func ConeQpCustomKKT(P, q, G, h, A, b *matrix.FloatMatrix, dims *sets.DimensionSet, kktsolver KKTConeSolver,
	solopts *SolverOptions, initvals *sets.FloatMatrixSet) (sol *Solution, err error)

Solves a pair of primal and dual convex quadratic cone programs using custom KKT solver.

func ConeQpCustomMatrix

func ConeQpCustomMatrix(P MatrixP, q *matrix.FloatMatrix, G MatrixG, h *matrix.FloatMatrix,
	A MatrixA, b *matrix.FloatMatrix, dims *sets.DimensionSet, kktsolver KKTConeSolver,
	solopts *SolverOptions, initvals *sets.FloatMatrixSet) (sol *Solution, err error)

Solves a pair of primal and dual cone programs using custom KKT solver and custom matrices P, G and A.

P must implement interface MatrixP, G must implement interface MatrixG and A must implement interface MatrixA.

func Cp

func Cp(F ConvexProg, G, h, A, b *matrix.FloatMatrix, dims *sets.DimensionSet, solopts *SolverOptions) (sol *Solution, err error)

Solves a convex optimization problem with a linear objective

minimize    f0(x)
subject to  fk(x) <= 0, k = 1, ..., mnl
            G*x   <= h
            A*x    = b.

f is vector valued, convex and twice differentiable. The linear inequalities are with respect to a cone C defined as the Cartesian product of N + M + 1 cones:

C = C_0 x C_1 x .... x C_N x C_{N+1} x ... x C_{N+M}.

The first cone C_0 is the nonnegative orthant of dimension ml. The next N cones are second order cones of dimension r[0], ..., r[N-1]. The second order cone of dimension m is defined as

{ (u0, u1) in R x R^{m-1} | u0 >= ||u1||_2 }.

The next M cones are positive semidefinite cones of order t[0], ..., t[M-1] >= 0.

The structure of C is specified by DimensionSet dims which holds following sets

dims.At("l")  l, the dimension of the nonnegative orthant (array of length 1)
dims.At("q")  r[0], ... r[N-1], list with the dimesions of the second-order cones
dims.At("s")  t[0], ... t[M-1], array with the dimensions of the positive
              semidefinite cones

The default value for dims is l: []int{h.Rows()}, q: []int{}, s: []int{}.

On exit Solution contains the result and information about the accurancy of the solution. if SolutionStatus is Optimal then Solution.Result contains solutions for the problems.

Result.At("x")[0]    primal solution
Result.At("snl")[0]  non-linear constraint slacks
Result.At("sl")[0]   linear constraint slacks
Result.At("y")[0]    values for linear equality constraints y
Result.At("znl")[0]  values of dual variables for nonlinear inequalities
Result.At("zl")[0]   values of dual variables for linear inequalities

If err is non-nil then sol is nil and err contains information about the argument or computation error.

func CpCustomKKT

func CpCustomKKT(F ConvexProg, G, h, A, b *matrix.FloatMatrix, dims *sets.DimensionSet,
	kktsolver KKTCpSolver, solopts *SolverOptions) (sol *Solution, err error)

Solves a convex optimization problem with a linear objective

minimize    f0(x)
subject to  fk(x) <= 0, k = 1, ..., mnl
            G*x   <= h
            A*x    = b.

using custom solver for KKT equations.

func CpCustomMatrix

func CpCustomMatrix(F ConvexProg, G MatrixG, h *matrix.FloatMatrix, A MatrixA,
	b *matrix.FloatMatrix, dims *sets.DimensionSet, kktsolver KKTCpSolver,
	solopts *SolverOptions) (sol *Solution, err error)

Solves a convex optimization problem with a linear objective

minimize    f0(x)
subject to  fk(x) <= 0, k = 1, ..., mnl
            G*x   <= h
            A*x    = b.

using custom solver for KKT equations and constraint equations G and A.

func Cpl

func Cpl(F ConvexProg, c, G, h, A, b *matrix.FloatMatrix, dims *sets.DimensionSet, solopts *SolverOptions) (sol *Solution, err error)

Solves a convex optimization problem with a linear objective

minimize    c'*x
subject to  f(x) <= 0
            G*x <= h
            A*x = b.

f is vector valued, convex and twice differentiable. The linear inequalities are with respect to a cone C defined as the Cartesian product of N + M + 1 cones:

C = C_0 x C_1 x .... x C_N x C_{N+1} x ... x C_{N+M}.

The first cone C_0 is the nonnegative orthant of dimension ml. The next N cones are second order cones of dimension r[0], ..., r[N-1]. The second order cone of dimension m is defined as

{ (u0, u1) in R x R^{m-1} | u0 >= ||u1||_2 }.

The next M cones are positive semidefinite cones of order t[0], ..., t[M-1] >= 0.

The structure of C is specified by DimensionSet dims which holds following sets

dims.At("l")  l, the dimension of the nonnegative orthant (array of length 1)
dims.At("q")  r[0], ... r[N-1], list with the dimesions of the second-order cones
dims.At("s")  t[0], ... t[M-1], array with the dimensions of the positive
              semidefinite cones

The default value for dims is l: []int{h.Rows()}, q: []int{}, s: []int{}.

On exit Solution contains the result and information about the accurancy of the solution. if SolutionStatus is Optimal then Solution.Result contains solutions for the problems.

Result.At("x")[0]    primal solution
Result.At("snl")[0]  non-linear constraint slacks
Result.At("sl")[0]   linear constraint slacks
Result.At("y")[0]    values for linear equality constraints y
Result.At("znl")[0]  values of dual variables for nonlinear inequalities
Result.At("zl")[0]   values of dual variables for linear inequalities

If err is non-nil then sol is nil and err contains information about the argument or computation error.

func CplCustomKKT

func CplCustomKKT(F ConvexProg, c *matrix.FloatMatrix, G, h, A, b *matrix.FloatMatrix,
	dims *sets.DimensionSet, kktsolver KKTCpSolver,
	solopts *SolverOptions) (sol *Solution, err error)

Solves a convex optimization problem with a linear objective

minimize    c'*x
subject to  f(x) <= 0
            G*x <= h
            A*x = b.

using custom KTT equation solver.

func CplCustomMatrix

func CplCustomMatrix(F ConvexProg, c *matrix.FloatMatrix, G MatrixG, h *matrix.FloatMatrix,
	A MatrixA, b *matrix.FloatMatrix, dims *sets.DimensionSet, kktsolver KKTCpSolver,
	solopts *SolverOptions) (sol *Solution, err error)

Solves a convex optimization problem with a linear objective

minimize    c'*x
subject to  f(x) <= 0
            G*x <= h
            A*x = b.

using custom KTT equation solver and custom constraints G and A.

func Gp

func Gp(K []int, F, g, G, h, A, b *matrix.FloatMatrix, solopts *SolverOptions) (sol *Solution, err error)

Solves a geometric program

minimize    log sum exp (F0*x+g0)
subject to  log sum exp (Fi*x+gi) <= 0,  i=1,...,m
            G*x <= h
            A*x = b

func Lp

func Lp(c, G, h, A, b *matrix.FloatMatrix, solopts *SolverOptions,
	primalstart, dualstart *sets.FloatMatrixSet) (sol *Solution, err error)

Solves a pair of primal and dual LPs

minimize    c'*x
subject to  G*x + s = h
            A*x = b
            s >= 0

maximize    -h'*z - b'*y
subject to  G'*z + A'*y + c = 0
              z >= 0.

func Qp

func Qp(P, q, G, h, A, b *matrix.FloatMatrix, solopts *SolverOptions,
	initvals *sets.FloatMatrixSet) (sol *Solution, err error)

Solves a quadratic program

minimize    (1/2)*x'*P*x + q'*x
subject to  G*x <= h
            A*x = b.

func Sdp

func Sdp(c, Gl, hl, A, b *matrix.FloatMatrix, Ghs *sets.FloatMatrixSet, solopts *SolverOptions,
	primalstart, dualstart *sets.FloatMatrixSet) (sol *Solution, err error)

Solves a pair of primal and dual SDPs

minimize    c'*x
subject to  Gl*x + sl = hl
            mat(Gs[k]*x) + ss[k] = hs[k], k = 0, ..., N-1
            A*x = b
            sl >= 0,  ss[k] >= 0, k = 0, ..., N-1

maximize    -hl'*z - sum_k trace(hs[k]*zs[k]) - b'*y
subject to  Gl'*zl + sum_k Gs[k]'*vec(zs[k]) + A'*y + c = 0
            zl >= 0,  zs[k] >= 0, k = 0, ..., N-1.

The inequalities sl >= 0 and zl >= 0 are elementwise vector inequalities. The inequalities ss[k] >= 0, zs[k] >= 0 are matrix inequalities, i.e., the symmetric matrices ss[k] and zs[k] must be positive semidefinite. mat(Gs[k]*x) is the symmetric matrix X with X[:] = Gs[k]*x. For a symmetric matrix, zs[k], vec(zs[k]) is the vector zs[k][:].

func Socp

func Socp(c, Gl, hl, A, b *matrix.FloatMatrix, Ghq *sets.FloatMatrixSet, solopts *SolverOptions,
	primalstart, dualstart *sets.FloatMatrixSet) (sol *Solution, err error)

Solves a pair of primal and dual SOCPs

minimize    c'*x
subject to  Gl*x + sl = hl
            Gq[k]*x + sq[k] = hq[k],  k = 0, ..., N-1
            A*x = b
            sl >= 0,
            sq[k] >= 0, k = 0, ..., N-1

maximize   -hl'*z - sum_k hq[k]'*zq[k] - b'*y
subject to  Gl'*zl + sum_k Gq[k]'*zq[k] + A'*y + c = 0
            zl >= 0,  zq[k] >= 0, k = 0, ..., N-1.

The inequalities sl >= 0 and zl >= 0 are elementwise vector inequalities. The inequalities sq[k] >= 0, zq[k] >= 0 are second order cone inequalities, i.e., equivalent to

sq[k][0] >= || sq[k][1:] ||_2,  zq[k][0] >= || zq[k][1:] ||_2.

type SolverOptions

type SolverOptions struct {
	// Absolute tolerance
	AbsTol float64
	// Relative tolerance
	RelTol float64
	// Feasibility tolerance
	FeasTol float64
	// Maximum number of iterations
	MaxIter int
	// Show progress flag
	ShowProgress bool
	// Debug flag
	Debug bool
	// Refinement count
	Refinement int
	// KKT solver function name; "ldl", "ldl2", "qr", "chol", "chol2"
	// NOTE: currently all solvers mapped to "ldl".
	KKTSolverName string
}

Solver options.

type StatusCode

type StatusCode int

Directories

Path Synopsis
Package for saving and check execution variables at checkpoints.
Package for saving and check execution variables at checkpoints.
blas
Interface to the double-precision real and complex BLAS library.
Interface to the double-precision real and complex BLAS library.
Package matrix implements column major matrices.
Package matrix implements column major matrices.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL