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

GurobiError: Unsupported type (<class 'str'>) for LinExpr addition argument

ユーザーの入力を待っています。

コメント

2件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff 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?.
  • Eli Towle
    • Gurobi Staff Gurobi Staff

    Can you please post a full working code example that reproduces this issue? I.e., one that includes the definitions of \( \texttt{r} \), \( \texttt{df} \), \( \texttt{H} \), etc.

    The error message states you are trying to add a \( \texttt{str} \) object to a linear expression object. I suspect that for some (or all) \( \texttt{j} \) in \( \texttt{CT} \), \( \texttt{r[j]} \) or \( \texttt{df.D[j]} \) is a \( \texttt{str} \) instead of a number. Here is an easy way to double-check the types of the elements in \( \texttt{r} \) and \( \texttt{df.D} \):

    for j in CT:
    print(f'r[{j}] = {r[j]}, {type(r[j])}')
    print(f'df.D[{j}] = {df.D[j]}, {type(df.D[j])}')
    0

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