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

tupledict.select() does not work as expected

回答済み

コメント

2件のコメント

  • 正式なコメント
    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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • Eli Towle
    • Gurobi Staff

    The keys of a tupledict should be a tuple of scalar values, not tuple values. From the tupledict documentation:

    Note that a \( \texttt{tupledict} \) key must be a tuple of scalar values (\(\texttt{int}\), \(\texttt{float}\), \(\texttt{string}\), ...). Thus, you can use \( \texttt{(1, 2.0, 'abc')}\) as a key, but you can't use \(\texttt{((1, 2.0), 'abc')}\).

    You get the desired result if you use four strings as the tupledict keys instead of two tuples:

    d = gp.tupledict([
        (('AT', 'CH', 'BE', 'AT'), 1),
        (('AT', 'CH', 'BE', 'DE'), 2),
        (('AT', 'DE', 'BE', 'DE'), 3),
        ])

    print(d.select('AT','CH', '*', '*'))
    0

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