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

Gurobi Python code to print non-binding constraints?

回答済み

コメント

3件のコメント

  • 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

サインインしてコメントを残してください。