安装:
[1] https://blog.csdn.net/YEN_CSDN/article/details/80658452?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522159902495019724843458563%2522%252C%2522scm%2522%253A%252220140713.130102334…%2522%257D&request_id=159902495019724843458563&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_ecpm_v3~pc_rank_v2-2-80658452.first_rank_ecpm_v3_pc_rank_v2&utm_term=python%E4%BC%98%E5%8C%96%E5%8C%85&spm=1018.2118.3001.4187
[2] https://blog.csdn.net/wiiliam_/article/details/90447029
使用:
[1] https://oomake.com/question/8652620
[2] https://vimsky.com/examples/detail/python-module-cvxpy.html
# 一个简单示例 minimize (5/x +3/y + 2/z),其中约束 x + y + z <=20,并且x,y,z均大于0.5
bandwidth = 20
temp = [5 ,3, 2]
count = 3
import cvxpy as cvx
x = cvx.Variable(count)
obj = cvx.sum(temp*cvx.inv_pos(x))
constr = [0.5 <= x,
cvx.sum(x) <= bandwidth]
prob = cvx.Problem(cvx.Minimize(obj), constr)
print(prob.solve())
print(x.value)
输出:
1.4484750749617623
[8.30899371 6.43597218 5.25503411]