Download modules/deap/doc/code/benchmarks/shekel.py from Johnny5b/portable-ai-runner: direct link, hf CLI and curl.
- Browser
- Download file 876 Bytes
-
https://huggingface.co/datasets/Johnny5b/portable-ai-runner/resolve/main/modules/deap/doc/code/benchmarks/shekel.py
- Command line
-
hf download hf://datasets/Johnny5b/portable-ai-runner/modules/deap/doc/code/benchmarks/shekel.py
-
curl -L -o shekel.py https://huggingface.co/datasets/Johnny5b/portable-ai-runner/resolve/main/modules/deap/doc/code/benchmarks/shekel.py
876 Bytes
| from mpl_toolkits.mplot3d import Axes3D | |
| from matplotlib import cm | |
| from matplotlib.colors import LogNorm | |
| import matplotlib.pyplot as plt | |
| try: | |
| import numpy as np | |
| except: | |
| exit() | |
| from deap import benchmarks | |
| #NUMMAX = 5 | |
| #A = 10 * np.random.rand(NUMMAX, 2) | |
| #C = np.random.rand(NUMMAX) | |
| A = [[0.5, 0.5], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]] | |
| C = [0.002, 0.005, 0.005, 0.005, 0.005] | |
| def shekel_arg0(sol): | |
| return benchmarks.shekel(sol, A, C)[0] | |
| fig = plt.figure() | |
| # ax = Axes3D(fig, azim = -29, elev = 50) | |
| ax = Axes3D(fig) | |
| X = np.arange(0, 1, 0.01) | |
| Y = np.arange(0, 1, 0.01) | |
| X, Y = np.meshgrid(X, Y) | |
| Z = np.fromiter(map(shekel_arg0, zip(X.flat,Y.flat)), dtype=float, count=X.shape[0]*X.shape[1]).reshape(X.shape) | |
| ax.plot_surface(X, Y, Z, rstride=1, cstride=1, norm=LogNorm(), cmap=cm.jet, linewidth=0.2) | |
| plt.xlabel("x") | |
| plt.ylabel("y") | |
| plt.show() |