Example #1
0
def main():
    """ Variable-sized Bin Packing Example """

    """
    'solvers.mvbp' the method proposed in:
    Brandao, F. and Pedroso, J. P. (2013). Multiple-choice Vector Bin Packing:
    Arc-flow Formulation with Graph Compression. Technical Report DCC-2013-13,
    Faculdade de Ciencias da Universidade do Porto, Universidade do Porto, Portugal.
    """

    inf = float("inf")

    # Capacities:
    Ws = [[100], [120], [150]]

    # Cots:
    Cs = [100, 120, 150]

    # Number of bins available of each type:
    Qs = [inf, inf, inf]

    # Item weights:
    ws = [[[10]], [[14]], [[17]], [[19]], [[24]], [[29]], [[32]], [[33]], [[36]],
          [[38]], [[40]], [[50]], [[54]], [[55]], [[63]], [[66]], [[71]], [[77]],
          [[79]], [[83]], [[92]], [[95]], [[99]]]

    # Item demands:
    b = [1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1]

    # Solve the variable-sized bin packing instance:
    obj, sol = mvbpsolver.solve(
        Ws, Cs, Qs, ws, b,
        svg_file="tmp/graph_vsbpp.svg",
        script="vpsolver_glpk.sh",
        verbose=True
    )
    print("obj:", obj)
    print("sol:", sol)
    mvbpsolver.print_solution(obj, sol)

    assert obj == 1280  # check the solution objective value
Example #2
0
def main():
    """Examples: Multiple-choice Vector Bin Packing"""

    """
    'solvers.mvbp' uses the method proposed in:
    Brandao, F. and Pedroso, J. P. (2013). Multiple-choice Vector Bin Packing:
    Arc-flow Formulation with Graph Compression. Technical Report DCC-2013-13,
    Faculdade de Ciencias da Universidade do Porto, Universidade do Porto, Portugal.
    """

    inf = float("inf")

    # Example 1:
    # Bins:
    W1 = (100, 100)
    W2 = (50, 120)
    W3 = (150, 25)
    Ws = [W1, W2, W3]    # Capacities
    Cs = [3, 7, 2]       # Costs
    Qs = [inf, inf, inf] # Number of available bins
    # Items:
    ws1, b1 = [(50, 25), (25, 50), (0, 75)], 1
    ws2, b2 = [(40, 40), (60, 25), (25, 60)], 1
    ws3, b3 = [(30, 10), (20, 40), (10, 50)], 1
    b = [b1, b2, b3]
    ws = [ws1, ws2, ws3]

    # Solve Example 1:
    obj, sol = mvbpsolver.solve(
        Ws, Cs, Qs, ws, b,
        svg_file="tmp/graphA_mvbp.svg",
        verbose=True, script="vpsolver_glpk.sh"
    )
    print("obj:", obj)
    print("sol:", sol)
    mvbpsolver.print_solution(obj, sol)

    ## Example 2
    # Bins:
    W1 = (100, 75)
    W2 = (75, 50)
    Ws = [W1, W2]
    Cs = [3, 2]
    Qs = [inf, inf]
    # Items
    ws1, b1 = [(75, 50)], 2
    ws2, b2 = [(40, 15), (25, 25)], 1
    b = [b1, b2]
    ws = [ws1, ws2]

    # Solve Example 2:
    obj, sol = mvbpsolver.solve(
        Ws, Cs, Qs, ws, b,
        svg_file="tmp/graphB_mvbp.svg",
        script="vpsolver_glpk.sh",
        verbose=True
    )
    print("obj:", obj)
    print("sol:", sol)
    mvbpsolver.print_solution(obj, sol)

    assert obj == 5  # check the solution objective value