This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
from forward_autodiff import DualFloat | |
trip_distance = DualFloat(6.0) # km | |
trip_duration = DualFloat(12.0) # minutes | |
trip_avg_speed = DualFloat(30.0) # km/h | |
# trip duration in minutes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce | |
import numpy as np | |
import jax.numpy as jnp | |
class LagrangianPolynome: | |
def __init__(self, Ts, Xs): | |
self.Ts = Ts | |
self.Xs = Xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from lagrangian_polynomial import LagrangianPolynome | |
Ts = [0.0, 1.0, 2.0, 3.0] | |
Xs = [0.0, 1.0, 1.0, 0.0] | |
poly = LagrangianPolynome(Ts, Xs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jax import jacfwd | |
def local_state(f, t): | |
traj_pos = f(t) | |
traj_speed_f = jacrev(f) | |
traj_speed = traj_speed_f(t) | |
traj_acc = jacfwd(traj_speed_f)(t) | |
return t, traj_pos, traj_speed, traj_acc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from jax import jacfwd, jacrev | |
from lagrangian_polynomial import LagrangianPolynome | |
def candidate_trajectory(Ts, Xs, t): | |
poly = LagrangianPolynome(Ts, Xs) | |
return poly.eval(t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scipy.integrate as integrate | |
import numpy as np | |
import jax.numpy as jnp | |
from jax import jacfwd, jacrev, jit | |
from lagrangian_polynomial import LagrangianPolynome | |
def local_state(f, t): | |
traj_pos = f(t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import jax.numpy as jnp | |
import numpy as np | |
import jax | |
from jax import grad, jacfwd, jacrev, jit | |
from scipy.optimize import minimize, root | |
from lagrangian_polynomial import LagrangianPolynome | |
from integration import integrate, integrate_num |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import jax.numpy as jnp | |
import numpy as np | |
from jax import grad, jacfwd, jacrev, jit | |
from lagrangian_polynomial import LagrangianPolynome | |
from integration import integrate | |
from scipy.optimize import minimize, root | |
A = -9.81 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from xgboost import XGBRegressor | |
import numpy as np | |
import pandas as pd | |
# Create an XGBoost model | |
model = XGBRegressor(n_estimators=250) | |
# Create time serie timestamp indices | |
ts = np.linspace(0, 10, 100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DecisionNode: | |
""" | |
Node decision class. | |
This is a simple binary node, with potentially two children: left and right | |
Left node is returned when condition is true | |
False node is returned when condition is false | |
""" | |
def __init__(self, name, condition, value=None): | |
self.name = name |