In [1]:
%load_ext autoreload
%autoreload 2
%matplotlib inline
import matplotlib.pyplot as plt
import os
import numpy as np
import pandas as pd
import warnings
warnings.filterwarnings('ignore')
In [2]:
import phuzzy
import phuzzy as ph
from phuzzy.mpl import mix_mpl
In [3]:
import phuzzy.contrib.shgo
In [4]:
def f(x):
return (x - 30) * np.sin(x)
def fm(x):
return -1 * f(x)
In [5]:
x_bound = (0, 100)
res = phuzzy.contrib.shgo.shgo(func=fm, bounds=[x_bound], iters=6, n=1)
res
Out[5]:
In [6]:
import matplotlib.pyplot as plt
fig, ax = plt.subplots(nrows=1, ncols=1)
x = np.linspace(x_bound[0], x_bound[1], 1000)
y = f(x)
ax.plot(x, y)
ax.plot(res.x, f(res.x), "o", alpha=.6, ms=10)
ax.plot(res.xl, f(res.xl), "s", alpha=.6, ms=6)
Out[6]:
In [32]:
import shgo.shgo_m.sobol_seq as sobol_seq
sobol = sobol_seq.Sobol()
d=2
n=50
points = pd.DataFrame(sobol.i4_sobol_generate(d, n, skip=0), columns=["x", "y"])
import matplotlib.pyplot as plt
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(5,5))
ax.scatter(points.x, points.y)
ax.set_aspect("equal", "datalim")
ax.set_xlim(0,1)
ax.set_ylim(0,1)
Out[32]:
In [38]:
import shgo.shgo_m.sobol_seq as sobol_seq
sobol = sobol_seq.Sobol()
d=3
n=500
points = pd.DataFrame(sobol.i4_sobol_generate(d, n, skip=0), columns=["x", "y", "z"])
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(points.x, points.y, points.z, alpha=.6)
ax.set_aspect("equal", "datalim")
ax.set_xlim(0,1)
ax.set_ylim(0,1)
Out[38]:
In [ ]: