'Cutting stock problem using pyomo/ python

I am trying to build a simple cutting stock model through pyomo.

I have written it but getting some errors

My try:

    model = ConcreteModel(name="CutStock Problem")
    n = 10  # maximum number of bars
    L = 250  # bar length
    m = 4  # number of requests
    w = [187, 119, 74, 90]  # size of each item
    b = [1, 2, 2, 1]  # demand for each item
    N = range(n)    
    M = range(m)
    model.x = Var(M, N, within=NonNegativeReals)
    model.y = Var(N, within=Binary)
    
    model.obj = Objective(expr = sum(model.y[j] for j in range(n)), sense = minimize)        
    model.con1 = Constraint(expr = sum(model.x[i, j] for j in range(n)) >= b[i] for i in range(m))

I am getting syntax error for model.con1.

I would like to write it in a single constraint expression, not using a function



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source