python求线性规划

    xiaoxiao2021-03-25  76

    """#需要安装pip install numpy-1.12.1rc1+mkl-cp35-cp35m-win32.whl,numpy_mkl地址

    不然提示

       from numpy._distributor_init import NUMPY_MKL  # requires numpy+mkl ImportError: cannot import name 'NUMPY_MKL'

    """

    import numpy

    from scipy.optimize import linprog from numpy._distributor_init import NUMPY_MKL c=[1,-2,1,0] A=[[2,-1,4,0],[-1,2,-4,0]] b=[8,4] Aeq=[[1,1,-2,1]] beq=[10] x0_bounds=(0,None) x1_bounds=(0,None) x2_bounds=(0,None) x3_bounds=(0,None) res=linprog(c,A_ub=A,b_ub=b,A_eq=Aeq,b_eq=beq,\             bounds=(x0_bounds,x1_bounds,x2_bounds,x3_bounds),\             options={'disp':True})
    转载请注明原文地址: https://ju.6miu.com/read-40122.html

    最新回复(0)