Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaced max and min operations for puma function (improves speed) #5

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
yoyolicoris marked this conversation as resolved.
Show resolved Hide resolved
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
Loading