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

Unsupported Type for LinExpr Argument

進行中

コメント

4件のコメント

  • 正式なコメント
    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

    The quicksum() function is used to add together Var, LinExpr, and/or QuadExpr objects. It's not compatible with matrix-friendly MVarMLinExpr, and MQuadExpr objects, which is what your code constructs when the \( \texttt{x} \) variables are defined as MVar objects.

    To fix these errors, try one of the following:

    1. Use Python's built-in \( \texttt{sum()} \) function instead of \( \texttt{quicksum()} \).

    2. Define \( \texttt{x} \) with Model.addVars() to create Var objects instead of MVar objects. You will have to rewrite the parts of your code that use matrix slicing.

    0
  • Andr
    • Gurobi-versary
    • First Question
    • First Comment

    Thank you so much for your fast response, the timing was perfect!

    0
  • Asrat Mekonnen Gobachew
    • Gurobi-versary
    • First Question
    • First Comment

    Hello;

     

    I am using Gurobi to solve a MILP problem. And got the following error.

    obj= (quicksum((F[j] *Y[j]) forjinJ) +quicksum(C[i,j] *R[i,j] for i in I for j in J) +
            quicksum(c[i,n,j] *f[i,n,j] for i in I for j in J) +quicksum(g[i,j,k]*L[i,j,k] for i in I for j in J for k in K))
     
    --------------------------------------------------------------------------- GurobiError Traceback (most recent call last) Input  obj = (quicksum((F[j] * Y[j]) for j in J) + quicksum(C[i,j] * R[i,j] for i in I for j in J) + 3 quicksum(c[i,n,j] * f[i,n,j] for i in I for j in J) + quicksum(g[i,j,k]*L[i,j,k] for i in I for j in J for k in K)) File src\gurobipy\gurobi.pxi:3632, in gurobipy.quicksum() File src\gurobipy\linexpr.pxi:473, in gurobipy.LinExpr.__iadd__() File src\gurobipy\linexpr.pxi:183, in gurobipy.LinExpr.add() GurobiError: Unsupported type (<class 'pandas.core.series.Series'>) for LinExpr addition argument

    GurobiError: Unsupported type (<class 'pandas.core.series.Series'>) for LinExpr addition argument

    Error is indicated on the bolded part of the model as shown in the screen shoot below. How can I solve this problem please?

    Note: F(j) is a list of continuous value and Y(j) is binary variable.

    0

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