L1-Norm minimization

匆匆过客 提交于 2021-01-29 07:46:16

问题


I am trying to minimize the following function using Linear programming. I am unable to include the image of my objective function. Click this Objective Function to view what I am trying to optimize. My question is there any library or function in python which can do this optimization for me or should I be writing the code?


回答1:


import cvxpy as cp
import numpy as np

N=10
M=100

U = np.random.random((M,N))
m = np.random.random(M)
t = cp.Variable(M)
x = cp.Variable(N)

prob = cp.Problem(cp.Minimize(cp.sum(t)), [-t<=U@x-m, U@x-m<=t])
optimal_value = prob.solve()
print("t=",t.value)
print("x=",x.value)
print("val=",optimal_value)



回答2:


There is the minimization method for the scipy library's optimization method. I am unsure how you would go about finding the L1-Norm but perhaps this will help with the minimization.

Each word listed in the () after minimize is a parameter. The "fun" parameter is the for a function and is where you'd put the L1-Norm after you've found it using another method.

scipy.optimize.minimize(
fun, x0, args=(), method='BFGS',
jac=None, hess=None, hessp=None, bounds=None, 
constraints=(), tol=None, callback=None, options=None
)


来源:https://stackoverflow.com/questions/58584127/l1-norm-minimization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!