From 2b20440735546bd801dcb946a8a29d4f9fc77cd1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 16:31:29 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.3.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.3.0...v5.0.0) - [github.com/psf/black: 22.10.0 → 24.10.0](https://github.com/psf/black/compare/22.10.0...24.10.0) - [github.com/nbQA-dev/nbQA: 1.5.2 → 1.9.1](https://github.com/nbQA-dev/nbQA/compare/1.5.2...1.9.1) - [github.com/PyCQA/isort: 5.10.1 → 5.13.2](https://github.com/PyCQA/isort/compare/5.10.1...5.13.2) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 322ac19..561a66c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,22 +1,22 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v5.0.0 hooks: - id: check-yaml - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 24.10.0 hooks: - id: black - repo: https://github.com/nbQA-dev/nbQA - rev: 1.5.2 + rev: 1.9.1 hooks: - id: nbqa-black - id: nbqa-isort # - id: nbqa-flake8 - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.13.2 hooks: - id: isort # - repo: https://github.com/pycqa/flake8 From 90cbbfbd9e6cd93e148b1157437e14641c53f670 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 16:31:58 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- experiments/plot/plot_gifs.py | 2 +- moderl/controllers/base.py | 4 +--- moderl/objectives.py | 6 +++--- subtrees/mosvgpe/mosvgpe/mixture_of_experts.py | 1 + subtrees/simenvs/simenvs/point_mass/generate_dataset.py | 5 ++++- .../simenvs/quadcopter/scenario-1/configs/env_config.toml | 2 +- .../quadcopter/scenario-1/generate_const_action_dataset.py | 5 ++++- .../simenvs/quadcopter/scenario-1/generate_dataset.py | 5 ++++- .../velocity_controlled_point_mass/generate_dataset.py | 5 ++++- .../scenario-10/env_config.toml | 2 +- .../scenario-2/env_config.toml | 2 +- .../scenario-3/env_config.toml | 2 +- .../scenario-4/env_config.toml | 2 +- .../scenario-5/env_config.toml | 2 +- .../scenario-6/env_config.toml | 2 +- .../scenario-7/env_config.toml | 2 +- .../scenario-8/env_config.toml | 2 +- .../scenario-9/env_config.toml | 2 +- 18 files changed, 32 insertions(+), 21 deletions(-) diff --git a/experiments/plot/plot_gifs.py b/experiments/plot/plot_gifs.py index 98fac74..5612ffd 100644 --- a/experiments/plot/plot_gifs.py +++ b/experiments/plot/plot_gifs.py @@ -121,7 +121,7 @@ def plot_gif( fig=fig, func=update_custom, frames=num_episodes, - interval=250 + interval=250, # interval=150 ) pathlib.Path(save_name).parents[0].mkdir(parents=True, exist_ok=True) diff --git a/moderl/controllers/base.py b/moderl/controllers/base.py index 86350d8..fc66de5 100644 --- a/moderl/controllers/base.py +++ b/moderl/controllers/base.py @@ -34,9 +34,7 @@ def control_dim(self) -> int: class TrajectoryOptimisationController(ControllerInterface): trajectory_optimiser: TrajectoryOptimiser - def __call__( - self, timestep: Optional[int] = None, dist: bool = False - ) -> Union[ + def __call__(self, timestep: Optional[int] = None, dist: bool = False) -> Union[ tfd.Distribution, Union[ttf.Tensor1[ControlDim], ttf.Tensor2[Horizon, ControlDim]], ]: diff --git a/moderl/objectives.py b/moderl/objectives.py index ecfd8f4..10c1b7c 100644 --- a/moderl/objectives.py +++ b/moderl/objectives.py @@ -117,7 +117,7 @@ def bernoulli_entropy( mode_probs = dynamics.mosvgpe.gating_network.gp.likelihood.predict_mean_and_var( input_dists.mean(), Fmu=h_means, - Fvar=h_covs + Fvar=h_covs, # input_means, Fmu=h_means, Fvar=h_vars )[0] print("mode_probs.shape") @@ -224,7 +224,7 @@ def bald_objective_sampling(input_dists): h_samples = dynamics.mosvgpe.gating_network.gp.predict_f_samples( input_dists.mean(), num_samples=10, - full_cov=False + full_cov=False, # input_dists.mean(), num_samples=10, full_cov=True ) print("h_samples") @@ -339,7 +339,7 @@ def entropy_approx(h_means, h_vars, mode_probs): def bald_objective_closed_form(): h_means, h_vars = dynamics.mosvgpe.gating_network.gp.predict_f( input_dists.mean(), - full_cov=True + full_cov=True, # full_cov=False # input_dists.mean(), full_cov=True ) diff --git a/subtrees/mosvgpe/mosvgpe/mixture_of_experts.py b/subtrees/mosvgpe/mosvgpe/mixture_of_experts.py index c8d576a..4594d3f 100644 --- a/subtrees/mosvgpe/mosvgpe/mixture_of_experts.py +++ b/subtrees/mosvgpe/mosvgpe/mixture_of_experts.py @@ -22,6 +22,7 @@ logger = logging.getLogger(__name__) + # class MixtureOfExpertsBase(gpf.models.BayesianModel, abc.ABC): # class MixtureOfExpertsBase(tf.keras.Model, abc.ABC): class MixtureOfExpertsBase(tf.keras.Model, BayesianModel, abc.ABC): diff --git a/subtrees/simenvs/simenvs/point_mass/generate_dataset.py b/subtrees/simenvs/simenvs/point_mass/generate_dataset.py index 7a72020..f21cea8 100644 --- a/subtrees/simenvs/simenvs/point_mass/generate_dataset.py +++ b/subtrees/simenvs/simenvs/point_mass/generate_dataset.py @@ -49,7 +49,10 @@ def generate_point_mass_dataset( toml_env_config_file, gating_bitmap_filename=gating_bitmap_file ) - (state_action_inputs, delta_state_outputs,) = generate_transitions_dataset( + ( + state_action_inputs, + delta_state_outputs, + ) = generate_transitions_dataset( num_states=num_states, num_actions=num_actions, env=env, diff --git a/subtrees/simenvs/simenvs/quadcopter/scenario-1/configs/env_config.toml b/subtrees/simenvs/simenvs/quadcopter/scenario-1/configs/env_config.toml index 16c2ebd..578e9c5 100644 --- a/subtrees/simenvs/simenvs/quadcopter/scenario-1/configs/env_config.toml +++ b/subtrees/simenvs/simenvs/quadcopter/scenario-1/configs/env_config.toml @@ -3,7 +3,7 @@ gating_bitmap = "./bitmaps/gating_mask.bmp" # filename for gating bitmap # gating_bitmap = "../scenario-1/gating_mask.bmp" # filename for gating bitmap # lists are converted to 1D np.arrays and floats/ints are broadcast -# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) +# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) # state constraints min_state = [-3.0, -2.0] max_state = [3.0, 3.0] diff --git a/subtrees/simenvs/simenvs/quadcopter/scenario-1/generate_const_action_dataset.py b/subtrees/simenvs/simenvs/quadcopter/scenario-1/generate_const_action_dataset.py index ba7a082..fd2f60b 100644 --- a/subtrees/simenvs/simenvs/quadcopter/scenario-1/generate_const_action_dataset.py +++ b/subtrees/simenvs/simenvs/quadcopter/scenario-1/generate_const_action_dataset.py @@ -21,7 +21,10 @@ # configure environment from toml config file env = parse_toml_config_to_VelocityControlledQuadcopter2DEnv(toml_env_config_file) -(state_action_inputs, delta_state_outputs,) = generate_transitions_dataset_const_action( +( + state_action_inputs, + delta_state_outputs, +) = generate_transitions_dataset_const_action( action, num_states=num_states, env=env, omit_data_mask=omit_data_mask ) diff --git a/subtrees/simenvs/simenvs/quadcopter/scenario-1/generate_dataset.py b/subtrees/simenvs/simenvs/quadcopter/scenario-1/generate_dataset.py index a196abe..af91298 100644 --- a/subtrees/simenvs/simenvs/quadcopter/scenario-1/generate_dataset.py +++ b/subtrees/simenvs/simenvs/quadcopter/scenario-1/generate_dataset.py @@ -16,7 +16,10 @@ # configure environment from toml config file env = parse_toml_config_to_VelocityControlledQuadcopter2DEnv(toml_env_config_file) -(state_action_inputs, delta_state_outputs,) = generate_transitions_dataset( +( + state_action_inputs, + delta_state_outputs, +) = generate_transitions_dataset( num_states=num_states, num_actions=num_actions, env=env, diff --git a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/generate_dataset.py b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/generate_dataset.py index 2d00263..c39b2b8 100644 --- a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/generate_dataset.py +++ b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/generate_dataset.py @@ -50,7 +50,10 @@ def generate_point_mass_dataset( toml_env_config_file, gating_bitmap_filename=gating_bitmap_file ) - (state_action_inputs, delta_state_outputs,) = generate_transitions_dataset( + ( + state_action_inputs, + delta_state_outputs, + ) = generate_transitions_dataset( num_states=num_states, num_actions=num_actions, env=env, diff --git a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-10/env_config.toml b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-10/env_config.toml index df9e841..0d9e2d2 100644 --- a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-10/env_config.toml +++ b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-10/env_config.toml @@ -3,7 +3,7 @@ gating_bitmap = "./bitmaps/gating_mask.bmp" # filename for gating bitmap # gating_bitmap = "../scenario-1/gating_mask.bmp" # filename for gating bitmap # lists are converted to 1D np.arrays and floats/ints are broadcast -# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) +# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) # state constraints min_state = [-3.0, -3.0] # min_state = [-3.0, -3.0] diff --git a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-2/env_config.toml b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-2/env_config.toml index 9bfefcf..30af5b5 100644 --- a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-2/env_config.toml +++ b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-2/env_config.toml @@ -3,7 +3,7 @@ gating_bitmap = "./bitmaps/gating_mask.bmp" # filename for gating bitmap # gating_bitmap = "../scenario-1/gating_mask.bmp" # filename for gating bitmap # lists are converted to 1D np.arrays and floats/ints are broadcast -# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) +# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) # state constraints min_state = [-3.0, -2.0] max_state = [3.0, 3.0] diff --git a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-3/env_config.toml b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-3/env_config.toml index d69237d..acf030b 100644 --- a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-3/env_config.toml +++ b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-3/env_config.toml @@ -3,7 +3,7 @@ gating_bitmap = "./bitmaps/gating_mask.bmp" # filename for gating bitmap # gating_bitmap = "../scenario-1/gating_mask.bmp" # filename for gating bitmap # lists are converted to 1D np.arrays and floats/ints are broadcast -# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) +# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) # state constraints min_state = [-3.0, -2.0] max_state = [3.0, 3.0] diff --git a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-4/env_config.toml b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-4/env_config.toml index 5e2ab57..ad522d0 100644 --- a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-4/env_config.toml +++ b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-4/env_config.toml @@ -3,7 +3,7 @@ gating_bitmap = "./bitmaps/gating_mask.bmp" # filename for gating bitmap # gating_bitmap = "../scenario-1/gating_mask.bmp" # filename for gating bitmap # lists are converted to 1D np.arrays and floats/ints are broadcast -# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) +# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) # state constraints min_state = [-3.0, -2.0] max_state = [3.0, 3.0] diff --git a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-5/env_config.toml b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-5/env_config.toml index c0c2621..5f8beb0 100644 --- a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-5/env_config.toml +++ b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-5/env_config.toml @@ -3,7 +3,7 @@ gating_bitmap = "./bitmaps/gating_mask.bmp" # filename for gating bitmap # gating_bitmap = "../scenario-1/gating_mask.bmp" # filename for gating bitmap # lists are converted to 1D np.arrays and floats/ints are broadcast -# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) +# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) # state constraints min_state = [-3.1, -3.0] # min_state = [-3.0, -3.0] diff --git a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-6/env_config.toml b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-6/env_config.toml index c1cce75..165a9f4 100644 --- a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-6/env_config.toml +++ b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-6/env_config.toml @@ -3,7 +3,7 @@ gating_bitmap = "./bitmaps/gating_mask.bmp" # filename for gating bitmap # gating_bitmap = "../scenario-1/gating_mask.bmp" # filename for gating bitmap # lists are converted to 1D np.arrays and floats/ints are broadcast -# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) +# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) # state constraints min_state = [-3.0, -2.0] max_state = [3.0, 3.0] diff --git a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-7/env_config.toml b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-7/env_config.toml index 3231649..d1487eb 100644 --- a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-7/env_config.toml +++ b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-7/env_config.toml @@ -3,7 +3,7 @@ gating_bitmap = "./bitmaps/gating_mask.bmp" # filename for gating bitmap # gating_bitmap = "../scenario-1/gating_mask.bmp" # filename for gating bitmap # lists are converted to 1D np.arrays and floats/ints are broadcast -# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) +# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) # state constraints min_state = [-3.0, -3.0] max_state = [3.0, 3.0] diff --git a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-8/env_config.toml b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-8/env_config.toml index 6a49fd4..a574693 100644 --- a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-8/env_config.toml +++ b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-8/env_config.toml @@ -3,7 +3,7 @@ gating_bitmap = "./bitmaps/gating_mask.bmp" # filename for gating bitmap # gating_bitmap = "../scenario-1/gating_mask.bmp" # filename for gating bitmap # lists are converted to 1D np.arrays and floats/ints are broadcast -# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) +# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) # state constraints min_state = [-3.0, -3.0] max_state = [3.0, 3.0] diff --git a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-9/env_config.toml b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-9/env_config.toml index e031303..661e354 100644 --- a/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-9/env_config.toml +++ b/subtrees/simenvs/simenvs/velocity_controlled_point_mass/scenario-9/env_config.toml @@ -3,7 +3,7 @@ gating_bitmap = "./bitmaps/gating_mask.bmp" # filename for gating bitmap # gating_bitmap = "../scenario-1/gating_mask.bmp" # filename for gating bitmap # lists are converted to 1D np.arrays and floats/ints are broadcast -# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) +# e.g min_state = [-3.0, -2.0] is converted with np.array(min_state) # state constraints min_state = [-3.0, -3.0] max_state = [3.0, 3.0]