美文网首页大数据
Coal Bank 纸厂的线性规划

Coal Bank 纸厂的线性规划

作者: 不连续小姐 | 来源:发表于2019-02-01 04:40 被阅读1次

    Python Day 6:

    Linear Optimization with Paper Company

    Last time we did a Pirelli Glass Linear Optimization, it considered a simple problem, because it has only 2 variables.What should we do if there are more variables and with much more complexed constrain systems?

    [caption id="attachment_1573" align="alignnone" width="750"] image

    diwou / Pixabay[/caption]

    Problem:

    Nancy Grant is the owner of Coal Bank Hollow Recycling company, there is two Recycling Process.

    Recyle Process

    Material

    • 70 tons of newspaper
    • 50 tons of mixed paper
    • 30 tons of white office paper
    • 40 tons of cardboard

    Production:

    • 60 newsprint pulp
    • 40 packaging paper pulp
    • 50 print stock pulp

    Let's use the linear optimation method to minimize the recycle uses and find the most efficient way for recycling.

    Process Flow Chart

    Process Flow Chart

    Solution

    Linear Model

    MInmize total Cost

    f(x)= 13x15+12x16+11x25+13x26+9x35+10x36+13x45+14x46+5x57+6x58+8x59+6x67+8x68+7x69

    General Constraints:

    all xij>=0

    Raw Material constraints :

    • newspaper : x_{15}+ x_{16} <= 70
    • mixed paper x_{25}+ x_{26} <= 50
    • White office paper x_{35}+ x_{36} <= 30
    • cardboard x_{45}+ x_{46} <= 40

    Recycling Processes Constraints:

    • Recycle Method 1:
      0.9x_{15}+ 0.8x_{25}+ 0.95x_{35}+ 0.75x_{45}- x_{57} -x_{58} - x_{59} >= 0

    • Recycle Method 2:
      0.85x_{16}+ 0.85x_{26}+ 0.9x_{36}+ 0.85x_{46}- x_{67} -x_{68} - x_{69} >= 0

    Production Paper Constraints:

    • newsprint : 0.95x_{57} +0.9x_{67} >=60
    • packaging paper 0.9x_{58} +0.95x_{68} >=40
    • stock paper 0.9x_{59} +0.95x_{69} >=50

    Python Code:

    import numpy as np
    from scipy.optimize import linprog
    from numpy.linalg import solve
    
    # Note we need to multiply "-1" in order to change the ">=" sign
    A_ub= np.array([
        [1,1,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,1,1,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,1,1,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,1,1,0,0,0,0,0,0],
        [-0.95,0,-0.8,0,-0.95,0,-0.75,0,1,1,1,0,0,0],
        [0,-0.85,0,-85,0,-0.9,0,-0.85,0,0,0,1,1,1],
        [0,0,0,0,0,0,0,0,-0.95,0,0,-0.9,0,0],
        [0,0,0,0,0,0,0,0,0,-0.9,0,0,-0.95,0],
        [0,0,0,0,0,0,0,0,0,0,-0.9,0,0,-0.95]
    ])
    
    b_ub=np.array([70,50,30,40,0,0,-60,-40,-0])
    c=np.array([13, 12, 11,13, 9, 10, 13, 14, 5, 6, 8, 6, 8,7])
    
    best = linprog(c,  A_ub= A_ub, b_ub=b_ub,
                  bounds=(0, None))
    best.fun
    best.x
    

    Output:

    From the result, we can see minimal cost is 1129.94 Dollars, with 1.89 Mixed paper goes to Recycle process 2 and print 66.67 ton newsprint plus 42.1 ton Packing paper and 52.6 ton Stock Paper

    1129.94
    array([  0\.        ,   0\.        ,   0\.        ,   1.89886481,
             0\.        ,   0\.        ,   0\.        ,   0\.        ,
             0\.        ,   0\.        ,   0\.        ,  66.66666667,
            42.10526316,  52.63157895])
    

    Note: since this is more than 3 dimensions, so we could not visualize it.

    **Happy studying! **😇

    相关文章

      网友评论

        本文标题:Coal Bank 纸厂的线性规划

        本文链接:https://www.haomeiwen.com/subject/wkipjqtx.html