Skip to main content

An error with the copy model

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
  • Riley Clement
    • 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

Post is closed for comments.