FilippoAiraldi/mpc-reinforcement-learning

View on GitHub

Showing 63 of 63 total issues

File agent.py has 528 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import sys
from collections.abc import Collection, Iterable, Iterator
from itertools import chain
from typing import Any, Generic, Literal, Optional, TypeVar, Union
 
 
Severity: Major
Found in src/mpcrl/agents/common/agent.py - About 1 day to fix

    File exploration.py has 436 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    r"""Exploration is a fundamental concept in Reinforcement Learning. Without it, often
    the learning algorithms converge to very suboptimal solutions, or don't even work.
     
    This submodule contains base classes and implementations for exploration strategies in
    the context of MPC-based RL. These classes allow the agent to draw perturbations to
    Severity: Minor
    Found in src/mpcrl/core/exploration.py - About 6 hrs to fix

      File bayesopt.py has 430 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      r"""
      .. _examples_bayesopt:
       
      Bayesian Optimization for MPC Data-driven Tuning
      ================================================
      Severity: Minor
      Found in examples/gradient-free/bayesopt.py - About 6 hrs to fix

        File lstd_dpg.py has 385 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import sys
        from collections.abc import Collection, Iterator
        from typing import Callable, Generic, Literal, Optional, SupportsFloat, Union
         
        import casadi as cs
        Severity: Minor
        Found in src/mpcrl/agents/lstd_dpg.py - About 5 hrs to fix

          File control.py has 345 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """A collection of basic utility functions for control applications. In particular, it
          contains functions for solving the LQR problems in continuous- and discrete-time,
          discretization methods such as Runge-Kutta 4, and functions to build Control Barrier
          Functions.
           
           
          Severity: Minor
          Found in src/mpcrl/util/control.py - About 4 hrs to fix

            File lstd_q_learning.py has 326 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import sys
            from collections.abc import Collection, Iterable
            from typing import Callable, Generic, Literal, Optional, SupportsFloat, Union
             
            import casadi as cs
            Severity: Minor
            Found in src/mpcrl/agents/lstd_q_learning.py - About 3 hrs to fix

              File learning_agent.py has 304 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              from abc import ABC, abstractmethod
              from collections.abc import Collection, Iterable
              from typing import Any, Callable, Generic, Optional, TypeVar, Union
               
              import numpy as np
              Severity: Minor
              Found in src/mpcrl/agents/common/learning_agent.py - About 3 hrs to fix

                File callbacks.py has 281 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                """As it will be clear from the inheritance diagram in :ref:`module_reference_agents`,
                all agents are derived from mixin classes that define callbacks and manage hooks
                attached to these callbacks. These system allows not only the user to customize the
                behaviour of a derived agent every time a callback is triggered, but also to easily
                implement and manage all those events and quantities that need to be scheduled during
                Severity: Minor
                Found in src/mpcrl/core/callbacks.py - About 2 hrs to fix

                  File parameters.py has 281 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  """Given an MPC controller with several symbolic parameters (some meant to be learned,
                  some other not), we need a way to specify to the agent of choice which of these are
                  indeed learnable. This is done by the use of the two classes introduced in this
                  submodule.
                   
                   
                  Severity: Minor
                  Found in src/mpcrl/core/parameters.py - About 2 hrs to fix

                    Function __init__ has 18 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def __init__(
                    Severity: Major
                    Found in src/mpcrl/agents/lstd_dpg.py - About 2 hrs to fix

                      File math.py has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      """A collection of functions for mathematical operations and utilities. In particular,
                      these functions support the creation of monomial basis functions for approximating the
                      value function, and the modifications of Hessian matrices to positive-definite ones."""
                       
                      from itertools import combinations as _combinations
                      Severity: Minor
                      Found in src/mpcrl/util/math.py - About 2 hrs to fix

                        File q_learning_offpolicy.py has 254 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        r"""
                        .. _examples_qlearning_offpolicy:
                         
                        Off-policy Q-learning
                        =====================
                        Severity: Minor
                        Found in examples/gradient-based-offpolicy/q_learning_offpolicy.py - About 2 hrs to fix

                          Function __init__ has 14 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def __init__(
                          Severity: Major
                          Found in src/mpcrl/agents/lstd_q_learning.py - About 1 hr to fix

                            Function train_one_episode has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def train_one_episode(
                            self,
                            env: Env[ObsType, ActType],
                            episode: int,
                            init_state: ObsType,
                            Severity: Minor
                            Found in src/mpcrl/agents/lstd_dpg.py - About 1 hr to fix

                            Function __init__ has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            def __init__(self, constraint_violation_penalty: float) -> None:
                            """Creates a CSTR environment.
                             
                            Parameters
                            ----------
                            Severity: Minor
                            Found in examples/gradient-free/bayesopt.py - About 1 hr to fix

                              Function __init__ has 12 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              def __init__(
                              Severity: Major
                              Found in src/mpcrl/wrappers/agents/evaluate.py - About 1 hr to fix

                                Function __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                Open

                                def __init__(
                                self,
                                agent: Agent[SymType],
                                log_name: Optional[str] = None,
                                level: int = logging.INFO,
                                Severity: Minor
                                Found in src/mpcrl/wrappers/agents/log.py - About 1 hr to fix

                                Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                def __init__(
                                Severity: Major
                                Found in src/mpcrl/optim/adam.py - About 1 hr to fix

                                  Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  def __init__(
                                  Severity: Major
                                  Found in src/mpcrl/optim/rmsprop.py - About 1 hr to fix

                                    Function _adam has 9 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                    def _adam(
                                    Severity: Major
                                    Found in src/mpcrl/optim/adam.py - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language