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

TypeError: unsupported operand type(s) for *: 'float' and 'tupledict'

回答済み

コメント

2件のコメント

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

    The error message is not being produced by the code you have pasted.  The culprit should be a line containing the * symbol, as per the error message.

    The following code, for example, runs without problem:

    m = gp.Model()
    ramda = m.addMVar((2, 6, 6, 6), name='ramda')
    v = [1]*6
    for j in range(1,5):
        m.addConstr(ramda[:, j, 0:j, :].sum() + ramda[:, j, j + 1:, :].sum() - v[j] <= 0)

    Note you will need to handle j = 0 and j = 5 separately since

    ramda[:, j, 0:0, :].sum()

    and

    ramda[:, 5, 6:, :].sum()

    will raise an error (the MVar slice contains no variables).

    - Riley

    0

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