python优化包cvxpy

安装:
[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]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值