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

Can we not solve 2 models in a single python file with Gurobipy?

回答済み

コメント

5件のコメント

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

    Hi,

    Could you provide a minimal working example to reproduce the issue? In this case, one would at least need the definition of \(\texttt{P, N, M, TN}\).

    Best regards,
    Jaromił

    0
  • BISWAJIT KAR
    • Gurobi-versary
    • Curious
    • Conversationalist

    Hi @Jaromil.... Here P, N , M, TN are the list consists of natural integer numbers
    For example
    P=[i for i in range(5)]...
    Like wise all the lists...

    0
  • Eli Towle
    • Gurobi Staff

    It's hard to help without a working code example that reproduces the issue. There is something else in your code that is contributing to the error. My best guess is that you assigned a list object to a Python variable named \( \texttt{list} \) or \( \texttt{product} \), which would overwrite the \( \texttt{list} \) built-in or \( \texttt{itertools.product} \). The following code runs fine:

    import gurobipy as gp
    from gurobipy import GRB
    from itertools import product

    M = [i for i in range(5)]
    TN = [i for i in range(10)]

    m1 = gp.Model()
    xmtn = m1.addVars(list(product(M, TN)), vtype=GRB.INTEGER, name='xmtn')

    By the way, the above code can be simplified (and made more efficient) as follows:

    import gurobipy as gp
    from gurobipy import GRB

    m1 = gp.Model()
    xmtn = m1.addVars(5, 10, vtype=GRB.INTEGER, name='xmtn')
    0
  • BISWAJIT KAR
    • Gurobi-versary
    • Curious
    • Conversationalist

    Thank You so much Eli Towle. The alternative method has resolved my problem. Thanks again.

    0

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