Skip to main content

An error with the copy model

Answered

Comments

1 comment

  • Riley Clement
    Gurobi Staff Gurobi Staff

    Hi Nazmi,

    The error message:

    TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

    is telling you that you are trying to divide ( "/" ) None by a float, and it shows you the line that it is happening:

    obj_lagrangian1 = gp.LinExpr(sum(xlambda[i, t] * (-p[i,t,s] + Cg_hat[i, t] + sum(subprob1.getVarByName(f"q_in[{b}, {i}, {t}]") / dist for b in range(B)) - sum(subprob1.getVarByName(f"q_out[{b}, {i}, {t}]") / dist for b in range(B)) + L * prod1[i,t] - sum(subprob1.getVarByName(f"f{j}.{i}.{t}")for j in range(n) if i != j) + subprob1.getVarByName(f"Pg{i}.{t}")+ subprob1.getVarByName(f"delta{i}.{t}")+ sum(subprob1.getVarByName(f"f{i}.{j}.{t}") for j in range(n) if i != j)) for i in range(n) for t in range(1, T)))
    

    In this line you are using division here:

    subprob1.getVarByName(f"q_in[{b}, {i}, {t}]") / dist

    and here

    subprob1.getVarByName(f"q_out[{b}, {i}, {t}]") / dist

    If a variable doesn't exist with the name given as an argument to Model.getVarByName then this function returns none.  To debug try and discover which names are returning None, and why.

    - Riley

     

    0

Please sign in to leave a comment.