问题
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