Skip to content

Commit

Permalink
fix edge weight calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloguarda committed Feb 22, 2024
1 parent 8845313 commit f6bd5c5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/isuelogit/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,21 +783,22 @@ def generate_C(M):
def generate_edges_weights(self, V: Matrix) -> Dict:

'''
Edge weights are all non-negative and have the opposite sign that the utilities.
To avoid problems with link with positive utilities, namely, a negative weight,
the weights are shifted by a constant corresponding to the absolute value of the
most negative value. This will not affect the shortest path calculation.
arguments:
V (Matrix): Utility Matrix
returns:
edge weights in utility units
edge weights that are all non-negative and have the opposite sign of the edge utilities
'''

# edges_weights_dict = dict(zip(dict(G.links).keys(), np.random.randint(0, 20, len(list(G.links)))))

# To avoid problems with link with negative utilities, we deviates them by the link with the most negative values such that all have utilities greater or equal than 0.

V = -V
V = V+abs(np.min(V))


edges_weights_dict = {}

for index, vx in np.ndenumerate(V):
Expand Down

0 comments on commit f6bd5c5

Please sign in to comment.