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

Gurobi Python code to print non-binding constraints?

回答済み

コメント

4件のコメント

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

    If there are no Gurobi variables in your expression, then it is not really a constraint (nothing is being constrained).

    Are you perhaps just wanting to calculate the maximum of the numbers stored in the Distance dictionary?  If so you can define DistanceMax like so

    DistanceMax = max(Distance.values())

    and then use it in your model.


    - Riley

    0
  • Tanmoy Das
    • Gurobi-versary
    • Investigator
    • Collaborator

    Well, actually Distance[s, o] is more of a Pairing of index between s & o. Just like Pairing(i,j) example in the following example https://gurobi.github.io/modeling-examples/customer_assignment/customer_assignment.html

    But, I want to use it as constraint so that this constraint would be violates sometimes based on certain conditions. So, I used all values as pair index.  

    0
  • Riley Clement
    • Gurobi Staff

    Hi Tanmoy,

    If you want a list of pairings (s,o) where Distance[s,o] is less than DistanceMax then you can create this like so

    [index for index,distance in Distance.items() if distance <= DistanceMax]

    - Riley

    0

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