x = np.linspace(-2.5, 2.5, 1000) # The parametrized function to be plotted def f(x, beta, c): return 1 / 4 * x**4 - x**2 - c * x # Define initial parameters u_bounds = np.array([[-2, 2]]) x_bounds = np.array([[-1.5, 1.5]]) #bounds_u = np.array([u_bounds]) u_boxes = np.array([20]) x_boxes = np.array([15]) Omega_u = domain.discretization(u_bounds, u_boxes) Omega_x = domain.discretization(x_bounds, x_boxes) # I think X and U need to be generated in a different way X = Omega_x.randPerBox(100) # U = np.random.uniform(u_bounds[0], u_bounds[1], (1, X.shape[1])) U = Omega_u.randPerBox(100) dim_x = X.shape[0] dim_u = U.shape[0] Y = s.b(X[:, 0]) Z = s.sigma(X[:, 0]) #%% Define observables order = 6 phi = observables.monomials(order) psi = observables.monomials(order) #lambda u: np.array([1])
sys.path.append('../../') import klus_algos as algorithms import domain as domain import observables as observables import systems as systems from tools import printVector, printMatrix plt.ion() #%% Simple deterministic system ------------------------------------------------------------------- # define domain bounds = np.array([[-2, 2], [-2, 2]]) boxes = np.array([50, 50]) Omega = domain.discretization(bounds, boxes) # define system gamma = -0.8 delta = -0.7 def b(x): return np.array([gamma * x[0, :], delta * (x[1, :] - x[0, :]**2)]) # define observables psi = observables.monomials(8) # generate data X = Omega.rand(1000) # generate test points
import matplotlib import matplotlib.pyplot as plt from matplotlib.widgets import Slider import sys sys.path.append('../../') import domain import estimate_L import observables import utilities #%% Define domains x_bounds = np.array([[-2, 2], [-1.5, 1.5]]) x_boxes = np.array([20, 15]) x_omega = domain.discretization(x_bounds, x_boxes) u_bounds = np.array([[-2, 2]]) u_boxes = np.array([300]) u_omega = domain.discretization(u_bounds, u_boxes) #%% Define system def b(x, u): return np.vstack([-4 * x[0, :]**3 + 4 * x[0, :], -2 * x[1, :]]) + u def sigma(x): n = x.shape[1] y = np.zeros((2, 2, n)) y[0, 0, :] = 0.7