Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

Minimizing norm subject to linear constraint, using quadratic programming/minimization in Python

I need to solve the following quadratic minimization subject to linear inequality constraint;

enter image description here

Where

||ξ|| is the Euclidean norm of ξ,

ξ and vk are vectors

and λk is a scalar.

I think this can be done with CVXOPT, but I don't have any experience with quadratic minimization so I am a bit lost, some help or just pointers would be greatly appreciated!.

solve ξ? = argmin||ξ|| subject to z.T ξ ≥ ?λk

question from:https://stackoverflow.com/questions/65837531/minimizing-norm-subject-to-linear-constraint-using-quadratic-programming-minimi

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

cvxopt.solvers.qp seems to be able to solve

1/2 xT P x + qT x

subject to

Ax ≤ B

For your case,

||ξ||2 = ξ2 = ξT I ξ = 1/2 ξT (2 × I) ξ + 0 x ξ

where I is an identity matrix. So your P and q are (2 × I) and 0 and A = -z_k, b = l_k.

With the given z_k and l_k (λ), you can solve matrix inequality by

import numpy
from cvxopt import matrix

P  = matrix([
    [2., 0., 0.],
    [0., 2., 0.],
    [0., 0., 2.]
])

q   = matrix([[0., 0., 0.]])

z_k = matrix([
    [1.],
    [2.],
    [3.]
])

l_k = matrix([4.])

from cvxopt import solvers

sol = solvers.qp(P, q, -z_k, l_k)

print(sol['x'])                 # argmin ξ
print(sol['primal objective'])  # min ξ^2

Check this.

If you need min ||ξ||, the norm:

import math
print(math.sqrt(sol['primal objective']))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...