Skip to content

Commit

Permalink
replaced max and min operations for puma function (improves speed)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChangPaul authored and yoyolicoris committed Apr 4, 2024
1 parent 64fb16d commit 1119bbc
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions kamui/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,8 @@ def cal_Ek(K, psi, i, j):

prev_Ek = cal_Ek(K, psi, edges[:, 0], edges[:, 1])

energy_list = []

for step in jump_steps:
while 1:
energy_list.append(prev_Ek)
G = maxflow.Graph[float]()
G.add_nodes(total_nodes)

Expand All @@ -205,12 +202,14 @@ def cal_Ek(K, psi, i, j):

tmp_st_weight = np.zeros((2, total_nodes))

for i in range(edges.shape[0]):
for i, a in enumerate(e10 - e00):
u, v = edges[i]
tmp_st_weight[0, u] += max(0, e10[i] - e00[i])
tmp_st_weight[0, v] += max(0, e11[i] - e10[i])
tmp_st_weight[1, u] -= min(0, e10[i] - e00[i])
tmp_st_weight[1, v] -= min(0, e11[i] - e10[i])
if a > 0:
tmp_st_weight[0, u] += a
tmp_st_weight[1, v] += a
else:
tmp_st_weight[1, u] -= a
tmp_st_weight[0, v] -= a

for i in range(total_nodes):
G.add_tedge(i, tmp_st_weight[0, i], tmp_st_weight[1, i])
Expand Down

0 comments on commit 1119bbc

Please sign in to comment.