Skip to content

Commit

Permalink
update edge weight adjustment to make sure weights arent zero
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbybp committed Nov 16, 2024
1 parent 9b6dc92 commit dbf710c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pyomo/contrib/incidence_analysis/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,14 +676,17 @@ def minimum_weight_maximum_matching(self, variables=None, constraints=None):
g_wc = self._extract_subgraph(v_wc, c_wc)
g_oc = self._extract_subgraph(v_oc, c_oc)

# NOTE: I believe this modifies the weights in the original graph.
# This is to work around the fact that scipy doesn't like zero-valued weights...
# Note that an appropriate adjustment depends on the choice of weight. For
# abs(log(abs(coef))), we want to add 1. For -abs(coef), we want to subtract
# 1.
eadjust = -1
for e, einfo in g_uc.edges.items():
# This is to work around the fact that scipy doesn't like zero-valued weights...
einfo["weight"] += 1
einfo["weight"] += eadjust
for e, einfo in g_wc.edges.items():
einfo["weight"] += 1
einfo["weight"] += eadjust
for e, einfo in g_oc.edges.items():
einfo["weight"] += 1
einfo["weight"] += eadjust

# Graph node convention comes into play here.
# Note that we are constructing matrices from relabeled nodes, so we know
Expand Down

0 comments on commit dbf710c

Please sign in to comment.