メインコンテンツへスキップ

Unable to convert argument to an expression

回答済み

コメント

6件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three 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 why not try our AI Gurobot?.
  • Jaromił Najman
    • Gurobi Staff

    The quicksum function requires a data set and not just single elements. Thus, you get the error that a single LinExpr object \(\texttt{x[i]*30000}\) is not iterable.

    One way to write the objective function would be

    m.setObjective((gp.quicksum(x[i]*300000 for i in Launchstationpoint)
    +gp.quicksum(y[j]*100000 for j in Rechargestationpoint)
    +gp.quicksum(disDL[k,i]*100*Di[k,i] for k in demandpoint for i in Launchstationpoint)
    +gp.quicksum(disDR[k,j]*100*Dj[k,j] for k in demandpoint for j in Rechargestationpoint)
    +gp.quicksum(disRL[j,i]*100*Dj[k,j] for i in Launchstationpoint for j in Rechargestationpoint for k in demandpoint)
    +S*15000),GRB.MINIMIZE)

    This way, you provide a list in each call of the quicksum function.

    0
  • Jaromił Najman
    • Gurobi Staff

    This is a duplicate of this stackoverflow post.

    0
  • chaung yun chi
    • Gurobi-versary
    • Curious
    • Conversationalist
    thanks for your help!

    but after I got my answer, I found something weird, my d variable should be {0 or 1}
    but why are there so many -0s? Or are they just 0?

    0
  • Jaromił Najman
    • Gurobi Staff

    The \(-0\) are actually just \(0\). You will see a \(-0\) often in computer codes and software. This is due to floating point operations and precision. For more information, see Signed zero.

    0
  • chaung yun chi
    • Gurobi-versary
    • Curious
    • Conversationalist

    Thanks for your help!

    0

投稿コメントは受け付けていません。