Skip to content

Instantly share code, notes, and snippets.

@LewisGet
Last active June 22, 2022 12:36
Show Gist options
  • Save LewisGet/0150cc9817203d567b8586ceda6df0ec to your computer and use it in GitHub Desktop.
Save LewisGet/0150cc9817203d567b8586ceda6df0ec to your computer and use it in GitHub Desktop.
import numpy as np
# f(x, y) return this array
data = np.array([
[3, 6, 4, 2],
[1.1, 0.5, 0.1, 0.9],
[4, 0.3, 2.3, 8.9]
])
x = {"1.1": data[0], "4.2": data[1], "-3": data[2]}
y = {"10": data[:, 0], "2.8": data[:, 1], "38": data[:, 2], "41": data[:, 3]}
# max f (x, y)
# y
# 數學公式
for i in x:
m = max(x[i].tolist())
mi = x[i].tolist().index(m)
yi = list(y.keys())[mi]
print("y=%s value=%s" % (yi, str(mi)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment