当前位置:   article > 正文

数值计算·第十集:混合-整数二次规划(CVXPY版)_cvxpy求解混合整数规划

cvxpy求解混合整数规划

 

Mixed-integer quadratic program(混合-整数二次规划

标准形式:-A mixed-integer quadratic program (MIQP) is an optimization problem of the form:

  1. #example -mixed-integer quadratic program
  2. import cvxpy as cp
  3. import numpy as np
  4. #problem data
  5. m,n = 40,25
  6. np.random.randn(1)
  7. A = np.random.randn(m,n)
  8. b = np.random.randn(m)
  9. #problem variable
  10. x = cp.Variable(n,integer = True)
  11. #constraints
  12. #object
  13. objective = cp.Minimize(cp.sum_squares(A@x-b))
  14. #problem
  15. prob = cp.Problem(objective)
  16. #solve
  17. prob.solve()

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/477156
推荐阅读
相关标签
  

闽ICP备14008679号