Pylint report from report.jinja2

Score

7.15 / 10 (previous score: 7.15 / 10)

Messages

Module agentlib_flexquant (agentlib_flexquant/__init__.py)

Line Col. Type Symbol ID Obj Message
3 0 error import-error E0401
Unable to import 'agentlib.utils.plugin_import'
4 0 error import-error E0401
Unable to import 'agentlib_mpc.optimization_backends'

Module agentlib_flexquant.data_structures.flex_kpis (agentlib_flexquant/data_structures/flex_kpis.py)

Line Col. Type Symbol ID Obj Message
8 0 error import-error E0401
Unable to import 'numpy'
9 0 error import-error E0401
Unable to import 'pandas'
10 0 error import-error E0401
Unable to import 'pydantic'
11 0 error import-error E0401
Unable to import 'agentlib_mpc.utils'
19 0 warning unused-import W0611
Unused strip_multi_index imported from agentlib_flexquant.utils.data_handling
22 0 refactor too-few-public-methods R0903 KPI
Too few public methods (1/2)
41 4 refactor too-few-public-methods R0903 KPI.Config
Too few public methods (0/2)
72 8 convention invalid-name C0103 KPISeries._get_dt
Variable name "dt" doesn't conform to snake_case naming style
76 8 convention invalid-name C0103 KPISeries._get_dt
Attribute name "dt" doesn't conform to snake_case naming style
95 4 refactor inconsistent-return-statements R1710 KPISeries.integrate
Either all return statements in a function should return an expression, or none of them should.
189 4 refactor too-many-arguments R0913 FlexibilityKPIs.calculate
Too many arguments (12/5)
250 4 refactor too-many-arguments R0913 FlexibilityKPIs._calculate_power_flex
Too many arguments (6/5)
318 39 convention unnecessary-dunder-call C2801 FlexibilityKPIs._calculate_power_flex_stats
Unnecessarily calls dunder method __deepcopy__. Use copy.deepcopy function.
343 8 refactor no-else-return R1705 FlexibilityKPIs._get_series_for_integration
Unnecessary "else" after "return", remove the "else" and de-indent the code inside it
356 39 convention unnecessary-dunder-call C2801 FlexibilityKPIs._calculate_energy_flex
Unnecessarily calls dunder method __deepcopy__. Use copy.deepcopy function.
366 4 refactor too-many-arguments R0913 FlexibilityKPIs._calculate_costs
Too many arguments (6/5)
394 38 convention unnecessary-dunder-call C2801 FlexibilityKPIs._calculate_costs
Unnecessarily calls dunder method __deepcopy__. Use copy.deepcopy function.
457 0 refactor too-many-instance-attributes R0902 FlexibilityData
Too many instance attributes (11/7)
514 4 refactor too-few-public-methods R0903 FlexibilityData.Config
Too few public methods (0/2)
520 4 refactor too-many-arguments R0913 FlexibilityData.__init__
Too many arguments (6/5)
548 12 warning self-assigning-variable W0127 FlexibilityData.unify_inputs
Assigning the same variable 'series' to itself

Module agentlib_flexquant.data_structures.flex_offer (agentlib_flexquant/data_structures/flex_offer.py)

Line Col. Type Symbol ID Obj Message
12 0 error import-error E0401
Unable to import 'pandas'
13 0 error import-error E0401
Unable to import 'pydantic'
14 0 error import-error E0401
Unable to import 'agentlib.core.datamodels'
15 0 error import-error E0401
Unable to import 'pydantic'
26 0 refactor too-few-public-methods R0903 FlexOffer
Too few public methods (1/2)
65 4 refactor too-few-public-methods R0903 FlexOffer.Config
Too few public methods (0/2)
90 8 convention invalid-name C0103 FlexOffer.as_dataframe
Variable name "df" doesn't conform to snake_case naming style

Module agentlib_flexquant.data_structures.flex_results (agentlib_flexquant/data_structures/flex_results.py)

Line Col. Type Symbol ID Obj Message
11 0 error import-error E0401
Unable to import 'pandas'
12 0 error import-error E0401
Unable to import 'pydantic'
13 0 error import-error E0401
Unable to import 'agentlib.core.agent'
14 0 error import-error E0401
Unable to import 'agentlib.modules.simulation.simulator'
15 0 error import-error E0401
Unable to import 'agentlib.utils'
16 0 error import-error E0401
Unable to import 'agentlib_mpc.modules.mpc'
17 0 error import-error E0401
Unable to import 'agentlib_mpc.utils'
18 0 error import-error E0401
Unable to import 'agentlib_mpc.utils.analysis'
47 4 convention invalid-name C0103 load_indicator
Variable name "df" doesn't conform to snake_case naming style
61 4 convention invalid-name C0103 load_market
Variable name "df" doesn't conform to snake_case naming style
65 0 refactor too-many-instance-attributes R0902 Results
Too many instance attributes (29/7)
111 4 refactor too-many-arguments R0913 Results.__init__
Too many arguments (6/5)
163 65 convention invalid-name C0103 Results._load_flex_config
Variable name "f" doesn't conform to snake_case naming style
258 72 convention invalid-name C0103 Results._load_simulator_config
Variable name "f" doesn't conform to snake_case naming style
483 12 convention invalid-name C0103 Results.convert_timescale_of_dataframe_index
Variable name "df" doesn't conform to snake_case naming style

Module agentlib_flexquant.data_structures.flexquant (agentlib_flexquant/data_structures/flexquant.py)

Line Col. Type Symbol ID Obj Message
8 0 error import-error E0401
Unable to import 'pydantic'
8 0 warning unused-import W0611
Unused import pydantic
9 0 error import-error E0401
Unable to import 'pydantic'
10 0 error import-error E0401
Unable to import 'agentlib.core.agent'
11 0 error import-error E0401
Unable to import 'agentlib.core.errors'
12 0 error import-error E0401
Unable to import 'agentlib_mpc.data_structures.mpc_datamodels'
26 0 refactor too-few-public-methods R0903 ShadowMPCConfigGeneratorConfig
Too few public methods (1/2)
55 0 refactor too-few-public-methods R0903 FlexibilityMarketConfig
Too few public methods (0/2)
66 0 refactor too-few-public-methods R0903 FlexibilityIndicatorConfig
Too few public methods (1/2)
176 4 convention missing-function-docstring C0116 FlexQuantConfig.is_none_negative_integer
Missing function or method docstring

Module agentlib_flexquant.data_structures.globals (agentlib_flexquant/data_structures/globals.py)

Line Col. Type Symbol ID Obj Message
17 0 convention invalid-name C0103
Class name "INTEGRATION_METHOD" doesn't conform to PascalCase naming style

Module agentlib_flexquant.data_structures.market (agentlib_flexquant/data_structures/market.py)

Line Col. Type Symbol ID Obj Message
10 0 error import-error E0401
Unable to import 'pydantic'
15 0 refactor too-few-public-methods R0903 RandomOptions
Too few public methods (0/2)
43 0 refactor too-few-public-methods R0903 SingleOptions
Too few public methods (0/2)
55 0 refactor too-few-public-methods R0903 CustomOptions
Too few public methods (0/2)
63 0 refactor too-few-public-methods R0903 MarketSpecifications
Too few public methods (1/2)
114 0 refactor too-few-public-methods R0903 RandomMarket
Too few public methods (1/2)

Module agentlib_flexquant.data_structures.mpcs (agentlib_flexquant/data_structures/mpcs.py)

Line Col. Type Symbol ID Obj Message
9 0 error import-error E0401
Unable to import 'pydantic'
10 0 error import-error E0401
Unable to import 'agentlib_mpc.data_structures.mpc_datamodels'
11 0 error import-error E0401
Unable to import 'pydantic'
17 0 refactor too-few-public-methods R0903 BaseMPCData
Too few public methods (0/2)
39 0 refactor too-few-public-methods R0903 BaselineMPCData
Too few public methods (1/2)
118 0 refactor too-few-public-methods R0903 PFMPCData
Too few public methods (0/2)
149 0 refactor too-few-public-methods R0903 NFMPCData
Too few public methods (0/2)

Module agentlib_flexquant.generate_flex_agents (agentlib_flexquant/generate_flex_agents.py)

Line Col. Type Symbol ID Obj Message
18 0 error import-error E0401
Unable to import 'astor'
19 0 error import-error E0401
Unable to import 'black'
20 0 warning reimported W0404
Reimport 'json' (imported line 11)
20 0 convention wrong-import-order C0411
standard import "import json" should be placed before "import astor"
20 0 convention ungrouped-imports C0412
Imports from package json are not grouped
21 0 error import-error E0401
Unable to import 'numpy'
22 0 warning reimported W0404
Reimport 'deepcopy' (imported line 14)
22 0 convention wrong-import-order C0411
standard import "from copy import deepcopy" should be placed before "import astor"
22 0 convention ungrouped-imports C0412
Imports from package copy are not grouped
23 0 warning reimported W0404
Reimport 'Path' (imported line 15)
23 0 convention wrong-import-order C0411
standard import "from pathlib import Path" should be placed before "import astor"
23 0 convention ungrouped-imports C0412
Imports from package pathlib are not grouped
24 0 warning reimported W0404
Reimport 'Union' (imported line 16)
24 0 convention wrong-import-order C0411
standard import "from typing import List, Union" should be placed before "import astor"
24 0 convention ungrouped-imports C0412
Imports from package typing are not grouped
24 0 warning unused-import W0611
Unused List imported from typing
25 0 error import-error E0401
Unable to import 'pydantic'
26 0 error import-error E0401
Unable to import 'agentlib.core.agent'
27 0 error import-error E0401
Unable to import 'agentlib.core.datamodels'
28 0 error import-error E0401
Unable to import 'agentlib.core.errors'
29 0 error import-error E0401
Unable to import 'agentlib.core.module'
30 0 error import-error E0401
Unable to import 'agentlib.utils'
31 0 error import-error E0401
Unable to import 'agentlib_mpc.data_structures.mpc_datamodels'
32 0 error import-error E0401
Unable to import 'agentlib_mpc.models.casadi_model'
33 0 error import-error E0401
Unable to import 'agentlib_mpc.modules.mpc_full'
35 0 error import-error E0401
Unable to import 'agentlib_mpc.optimization_backends.casadi_.basic'
36 0 error import-error E0401
Unable to import 'agentlib_mpc.data_structures.casadi_utils'
52 0 refactor too-many-instance-attributes R0902 FlexAgentGenerator
Too many instance attributes (17/7)
199 0 convention line-too-long C0301
Line too long (104/100)
205 0 convention line-too-long C0301
Line too long (104/100)
228 13 convention invalid-name C0103 FlexAgentGenerator.generate_flex_agents
Variable name "f" doesn't conform to snake_case naming style
234 28 warning unnecessary-lambda W0108 FlexAgentGenerator.generate_flex_agents.<lambda>
Lambda may not be necessary
277 17 convention invalid-name C0103 FlexAgentGenerator.append_module_and_dump_agent
Variable name "f" doesn't conform to snake_case naming style
327 4 refactor too-many-branches R0912 FlexAgentGenerator.adapt_mpc_module_config
Too many branches (18/12)
538 16 convention unnecessary-dunder-call C2801 FlexAgentGenerator.adapt_market_config
Unnecessarily calls dunder method __setattr__. Set attribute directly or use setattr built-in function.
567 29 warning protected-access W0212 FlexAgentGenerator.get_collocation_time_grid
Access to a protected member _collocation_polynomial of a client class
579 4 refactor too-many-locals R0914 FlexAgentGenerator._generate_flex_model_definition
Too many local variables (17/15)
601 65 convention invalid-name C0103 FlexAgentGenerator._generate_flex_model_definition
Variable name "f" doesn't conform to snake_case naming style
651 57 convention invalid-name C0103 FlexAgentGenerator._generate_flex_model_definition
Variable name "f" doesn't conform to snake_case naming style
677 4 refactor too-many-branches R0912 FlexAgentGenerator.run_config_validations
Too many branches (19/12)
741 8 refactor no-else-raise R1720 FlexAgentGenerator.run_config_validations
Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it
835 68 convention invalid-name C0103 FlexAgentGenerator.adapt_sim_results_path
Variable name "f" doesn't conform to snake_case naming style

Module agentlib_flexquant.modules.baseline_mpc (agentlib_flexquant/modules/baseline_mpc.py)

Line Col. Type Symbol ID Obj Message
4 0 error import-error E0401
Unable to import 'agentlib_mpc.modules'
5 0 convention wrong-import-order C0411
standard import "import os" should be placed before "from agentlib_mpc.modules import minlp_mpc, mpc_full"
6 0 convention wrong-import-order C0411
standard import "import math" should be placed before "from agentlib_mpc.modules import minlp_mpc, mpc_full"
7 0 error import-error E0401
Unable to import 'numpy'
8 0 error import-error E0401
Unable to import 'pandas'
9 0 convention wrong-import-order C0411
standard import "from typing import Optional, Dict" should be placed before "from agentlib_mpc.modules import minlp_mpc, mpc_full"
10 0 error import-error E0401
Unable to import 'pydantic'
11 0 convention wrong-import-order C0411
standard import "from collections.abc import Iterable" should be placed before "from agentlib_mpc.modules import minlp_mpc, mpc_full"
12 0 warning unused-import W0611
Unused agentlib_flexquant.data_structures.globals imported as glbs
13 0 error import-error E0401
Unable to import 'agentlib'
13 0 convention wrong-import-order C0411
third party import "from agentlib import AgentVariable" should be placed before "import agentlib_flexquant.data_structures.globals as glbs"
14 0 error import-error E0401
Unable to import 'agentlib_mpc.modules'
14 0 warning reimported W0404
Reimport 'mpc_full' (imported line 4)
14 0 warning reimported W0404
Reimport 'minlp_mpc' (imported line 4)
14 0 convention wrong-import-order C0411
third party import "from agentlib_mpc.modules import mpc_full, minlp_mpc" should be placed before "import agentlib_flexquant.data_structures.globals as glbs"
14 0 convention ungrouped-imports C0412
Imports from package agentlib_mpc are not grouped
15 0 error import-error E0401
Unable to import 'agentlib_mpc.data_structures.mpc_datamodels'
15 0 convention wrong-import-order C0411
third party import "from agentlib_mpc.data_structures.mpc_datamodels import Results" should be placed before "import agentlib_flexquant.data_structures.globals as glbs"
19 0 convention missing-class-docstring C0115 FlexibilityBaselineMPCConfig
Missing class docstring
19 0 refactor too-few-public-methods R0903 FlexibilityBaselineMPCConfig
Too few public methods (0/2)
72 12 warning bare-except W0702 FlexibilityBaselineMPC.__init__
No exception type(s) specified
88 4 convention missing-function-docstring C0116 FlexibilityBaselineMPC.set_actuation
Missing function or method docstring
107 8 convention invalid-name C0103 FlexibilityBaselineMPC.set_output
Variable name "df" doesn't conform to snake_case naming style
229 4 refactor too-many-arguments R0913 FlexibilityBaselineMPC._run_simulation
Too many arguments (6/5)
229 4 refactor too-many-locals R0914 FlexibilityBaselineMPC._run_simulation
Too many local variables (18/15)
230 49 warning unused-argument W0613 FlexibilityBaselineMPC._run_simulation
Unused argument 'mpc_time_step'
258 30 warning eval-used W0123 FlexibilityBaselineMPC._run_simulation
Use of eval
277 0 convention missing-class-docstring C0115 FlexibilityBaselineMINLPMPCConfig
Missing class docstring
277 0 refactor too-few-public-methods R0903 FlexibilityBaselineMINLPMPCConfig
Too few public methods (0/2)
330 12 warning bare-except W0702 FlexibilityBaselineMINLPMPC.__init__
No exception type(s) specified
352 4 convention missing-function-docstring C0116 FlexibilityBaselineMINLPMPC.set_actuation
Missing function or method docstring
370 8 convention invalid-name C0103 FlexibilityBaselineMINLPMPC.set_output
Variable name "df" doesn't conform to snake_case naming style
489 4 refactor too-many-arguments R0913 FlexibilityBaselineMINLPMPC._run_simulation
Too many arguments (6/5)
489 4 refactor too-many-locals R0914 FlexibilityBaselineMINLPMPC._run_simulation
Too many local variables (19/15)
490 49 warning unused-argument W0613 FlexibilityBaselineMINLPMPC._run_simulation
Unused argument 'mpc_time_step'
527 30 warning eval-used W0123 FlexibilityBaselineMINLPMPC._run_simulation
Use of eval

Module agentlib_flexquant.modules.flexibility_indicator (agentlib_flexquant/modules/flexibility_indicator.py)

Line Col. Type Symbol ID Obj Message
14 0 error import-error E0401
Unable to import 'agentlib'
15 0 error import-error E0401
Unable to import 'numpy'
16 0 error import-error E0401
Unable to import 'pandas'
17 0 error import-error E0401
Unable to import 'pydantic'
28 0 refactor too-few-public-methods R0903 InputsForCorrectFlexCosts
Too few public methods (0/2)
55 0 refactor too-few-public-methods R0903 InputsForCalculateFlexCosts
Too few public methods (1/2)
92 0 refactor too-few-public-methods R0903 FlexibilityIndicatorModuleConfig
Too few public methods (1/2)
357 8 convention invalid-name C0103 FlexibilityIndicatorModule.__init__
Attribute name "df" doesn't conform to snake_case naming style
359 4 convention missing-function-docstring C0116 FlexibilityIndicatorModule.register_callbacks
Missing function or method docstring
373 4 refactor too-many-branches R0912 FlexibilityIndicatorModule.callback
Too many branches (17/12)
406 16 convention invalid-name C0103 FlexibilityIndicatorModule.callback
Variable name "n" doesn't conform to snake_case naming style
407 16 convention invalid-name C0103 FlexibilityIndicatorModule.callback
Variable name "ts" doesn't conform to snake_case naming style
462 28 convention invalid-name C0103 FlexibilityIndicatorModule.write_results
Argument name "df" doesn't conform to snake_case naming style
462 46 convention invalid-name C0103 FlexibilityIndicatorModule.write_results
Argument name "ts" doesn't conform to snake_case naming style
462 57 convention invalid-name C0103 FlexibilityIndicatorModule.write_results
Argument name "n" doesn't conform to snake_case naming style
462 4 refactor too-many-locals R0914 FlexibilityIndicatorModule.write_results
Too many local variables (18/15)
462 4 refactor too-many-branches R0912 FlexibilityIndicatorModule.write_results
Too many branches (15/12)
520 12 warning unused-variable W0612 FlexibilityIndicatorModule.write_results
Unused variable 'i'
618 4 refactor too-many-arguments R0913 FlexibilityIndicatorModule.send_flex_offer
Too many arguments (8/5)

Module agentlib_flexquant.modules.flexibility_market (agentlib_flexquant/modules/flexibility_market.py)

Line Col. Type Symbol ID Obj Message
1 0 convention missing-module-docstring C0114
Missing module docstring
5 0 error import-error E0401
Unable to import 'agentlib'
6 0 error import-error E0401
Unable to import 'numpy'
7 0 error import-error E0401
Unable to import 'pandas'
9 0 error import-error E0401
Unable to import 'agentlib.core.datamodels'
9 0 convention wrong-import-order C0411
third party import "from agentlib.core.datamodels import AgentVariable" should be placed before "import agentlib_flexquant.data_structures.globals as glbs"
10 0 error import-error E0401
Unable to import 'pydantic'
10 0 convention wrong-import-order C0411
third party import "from pydantic import ConfigDict, Field, model_validator" should be placed before "import agentlib_flexquant.data_structures.globals as glbs"
16 0 convention missing-class-docstring C0115 FlexibilityMarketModuleConfig
Missing class docstring
16 0 refactor too-few-public-methods R0903 FlexibilityMarketModuleConfig
Too few public methods (1/2)
61 4 convention missing-function-docstring C0116 FlexibilityMarketModuleConfig.check_results_file_extension
Missing function or method docstring
84 8 warning attribute-defined-outside-init W0201 FlexibilityMarketModule.set_random_seed
Attribute 'random_generator' defined outside __init__
96 4 convention missing-function-docstring C0116 FlexibilityMarketModule.register_callbacks
Missing function or method docstring
118 8 warning attribute-defined-outside-init W0201 FlexibilityMarketModule.register_callbacks
Attribute 'cooldown_ticker' defined outside __init__
124 8 convention invalid-name C0103 FlexibilityMarketModule.write_results
Variable name "df" doesn't conform to snake_case naming style
136 62 warning unused-argument W0613 FlexibilityMarketModule.random_flexibility_callback
Unused argument 'name'
180 0 convention line-too-long C0301
Line too long (102/100)
195 20 warning attribute-defined-outside-init W0201 FlexibilityMarketModule.random_flexibility_callback
Attribute 'cooldown_ticker' defined outside __init__
202 62 warning unused-argument W0613 FlexibilityMarketModule.single_flexibility_callback
Unused argument 'name'
256 8 warning unnecessary-pass W0107 FlexibilityMarketModule.custom_flexibility_callback
Unnecessary pass statement
258 29 warning unused-argument W0613 FlexibilityMarketModule.dummy_callback
Unused argument 'inp'
258 49 warning unused-argument W0613 FlexibilityMarketModule.dummy_callback
Unused argument 'name'
269 4 convention missing-function-docstring C0116 FlexibilityMarketModule.process
Missing function or method docstring

Module agentlib_flexquant.modules.shadow_mpc (agentlib_flexquant/modules/shadow_mpc.py)

Line Col. Type Symbol ID Obj Message
8 0 error import-error E0401
Unable to import 'numpy'
9 0 error import-error E0401
Unable to import 'pandas'
10 0 error import-error E0401
Unable to import 'pydantic'
11 0 warning reimported W0404
Reimport 'Dict' (imported line 4)
11 0 warning reimported W0404
Reimport 'Union' (imported line 4)
11 0 convention wrong-import-order C0411
standard import "from typing import Dict, Union, Optional" should be placed before "import numpy as np"
11 0 convention ungrouped-imports C0412
Imports from package typing are not grouped
12 0 convention wrong-import-order C0411
standard import "from collections.abc import Iterable" should be placed before "import numpy as np"
13 0 error import-error E0401
Unable to import 'agentlib.core.datamodels'
14 0 error import-error E0401
Unable to import 'agentlib_mpc.modules'
16 0 warning unused-import W0611
Unused full_trajectory_prefix imported from agentlib_flexquant.data_structures.globals
16 0 warning unused-import W0611
Unused STORED_ENERGY_ALIAS_NEG imported from agentlib_flexquant.data_structures.globals
16 0 warning unused-import W0611
Unused STORED_ENERGY_ALIAS_POS imported from agentlib_flexquant.data_structures.globals
24 0 convention missing-class-docstring C0115 FlexibilityShadowMPCConfig
Missing class docstring
24 0 refactor too-few-public-methods R0903 FlexibilityShadowMPCConfig
Too few public methods (0/2)
62 12 warning bare-except W0702 FlexibilityShadowMPC.__init__
No exception type(s) specified
71 8 convention invalid-name C0103 FlexibilityShadowMPC.set_output
Variable name "df" doesn't conform to snake_case naming style
137 4 convention missing-function-docstring C0116 FlexibilityShadowMPC.register_callbacks
Missing function or method docstring
180 4 convention missing-function-docstring C0116 FlexibilityShadowMPC.process
Missing function or method docstring
238 4 refactor too-many-arguments R0913 FlexibilityShadowMPC._run_simulation
Too many arguments (6/5)
238 4 refactor too-many-locals R0914 FlexibilityShadowMPC._run_simulation
Too many local variables (18/15)
239 49 warning unused-argument W0613 FlexibilityShadowMPC._run_simulation
Unused argument 'mpc_time_step'
267 30 warning eval-used W0123 FlexibilityShadowMPC._run_simulation
Use of eval
286 0 convention missing-class-docstring C0115 FlexibilityShadowMINLPMPCConfig
Missing class docstring
286 0 refactor too-few-public-methods R0903 FlexibilityShadowMINLPMPCConfig
Too few public methods (0/2)
324 12 warning bare-except W0702 FlexibilityShadowMINLPMPC.__init__
No exception type(s) specified
327 4 convention missing-function-docstring C0116 FlexibilityShadowMINLPMPC.register_callbacks
Missing function or method docstring
376 4 convention missing-function-docstring C0116 FlexibilityShadowMINLPMPC.process
Missing function or method docstring
390 8 convention invalid-name C0103 FlexibilityShadowMINLPMPC.set_output
Variable name "df" doesn't conform to snake_case naming style
509 4 refactor too-many-arguments R0913 FlexibilityShadowMINLPMPC._run_simulation
Too many arguments (6/5)
509 4 refactor too-many-locals R0914 FlexibilityShadowMINLPMPC._run_simulation
Too many local variables (19/15)
510 49 warning unused-argument W0613 FlexibilityShadowMINLPMPC._run_simulation
Unused argument 'mpc_time_step'
547 30 warning eval-used W0123 FlexibilityShadowMINLPMPC._run_simulation
Use of eval

Module agentlib_flexquant.optimization_backends.constrained_cia (agentlib_flexquant/optimization_backends/constrained_cia.py)

Line Col. Type Symbol ID Obj Message
1 0 convention missing-module-docstring C0114
Missing module docstring
1 0 error import-error E0401
Unable to import 'pydantic'
1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.baseline_mpc:[362:543]
==agentlib_flexquant.modules.shadow_mpc:[382:563]
        if not self.config.set_outputs:
            return
        self.logger.info("Sending optimal output values to data_broker.")

        # simulate with the casadi simulator
        self.sim_flex_model(solution)

        df = solution.df
        if self.flex_results is not None:
            for output in self.var_ref.outputs:
                if output not in [
                    self.config.power_variable_name,
                    self.config.storage_variable_name,
                ]:
                    series = df.variable[output]
                    self.set(output, series)
            # send the power and storage variable value from simulation results
            upsampled_output_power = self.flex_results[self.config.power_variable_name]
            self.set(self.config.power_variable_name, upsampled_output_power)
            if self.config.storage_variable_name is not None:
                upsampled_output_storage = self.flex_results[self.config.storage_variable_name]
                self.set(self.config.storage_variable_name, upsampled_output_storage.dropna())
        else:
            for output in self.var_ref.outputs:
                series = df.variable[output]
                self.set(output, series)

    def sim_flex_model(self, solution):
        """simulate the flex model over the preditcion horizon and save results"""

        # return if sim_time_step is not a positive integer and system is in provision
        if not (self.config.casadi_sim_time_step > 0 and not self.get("in_provision").value):
            return

        # read the defined simulation time step
        sim_time_step = self.config.casadi_sim_time_step
        mpc_time_step = self.config.time_step

        # set the horizon length and the number of simulation steps
        total_horizon_time = int(self.config.prediction_horizon * self.config.time_step)
        n_simulation_steps = math.ceil(total_horizon_time / sim_time_step)

        # read the current optimization result
        result_df = solution.df

        # initialize the flex sim results Dataframe
        self._initialize_flex_results(
            n_simulation_steps, total_horizon_time, sim_time_step, result_df
        )

        # Update model parameters and initial states
        self._update_model_parameters()
        self._update_initial_states(result_df)

        # Run simulation
        self._run_simulation(
            n_simulation_steps, sim_time_step, mpc_time_step, result_df, total_horizon_time
        )

        # set index of flex results to the same as mpc result
        store_results_df = self.flex_results.copy(deep=True)
        store_results_df.index = self.flex_results.index.tolist()

        # save results
        if not os.path.exists(self.res_file_flex):
            store_results_df.to_csv(self.res_file_flex)
        else:
            store_results_df.to_csv(self.res_file_flex, mode="a", header=False)

        # set the flex results format same as mpc result while updating Agentvariable
        self.flex_results.index = self.flex_results.index.get_level_values(1)

    def _initialize_flex_results(
        self, n_simulation_steps, horizon_length, sim_time_step, result_df
    ):
        """Initialize the flex results dataframe with the correct dimension and index and fill with
         existing results from optimization"""

        # create MultiIndex for collocation points
        index_coll = pd.MultiIndex.from_arrays(
            [[self.env.now] * len(result_df.index), result_df.index],
            names=["time_step", "time"]
            # Match the names with multi_index but note they're reversed
        )
        # create Multiindex for full simulation sample times
        index_full_sample = pd.MultiIndex.from_tuples(
            zip(
                [self.env.now] * (n_simulation_steps + 1),
                range(0, horizon_length + sim_time_step, sim_time_step),
            ),
            names=["time_step", "time"],
        )
        # merge indexes
        new_index = index_coll.union(index_full_sample).sort_values()
        # initialize the flex results with correct dimension
        self.flex_results = pd.DataFrame(np.nan, index=new_index, columns=self.var_ref.outputs)

        # Get the optimization outputs and create a series for fixed optimization outputs with the
        # correct MultiIndex format
        opti_outputs = result_df.variable[self.config.power_variable_name]
        fixed_opti_output = pd.Series(
            opti_outputs.values,
            index=index_coll,
        )
        # fill the output value at the time step where it already exists in optimization output
        for idx in fixed_opti_output.index:
            if idx in self.flex_results.index:
                self.flex_results.loc[idx, self.config.power_variable_name] = fixed_opti_output[idx]

    def _update_model_parameters(self):
        """update the value of module parameters with value from config,
        since creating a model just reads the value in the model class but not the config
        """

        for par in self.config.parameters:
            self.flex_model.set(par.name, par.value)

    def _update_initial_states(self, result_df):
        """set the initial value of states"""

        # get state values from the mpc optimization result
        state_values = result_df.variable[self.var_ref.states]
        # update state values with last measurement
        for state, value in zip(self.var_ref.states, state_values.iloc[0]):
            self.flex_model.set(state, value)

    def _run_simulation(
        self, n_simulation_steps, sim_time_step, mpc_time_step, result_df, total_horizon_time
    ):
        """simulate with flex model over the prediction horizon"""

        # get control and input values from the mpc optimization result
        control_values = result_df.variable[
            [*self.var_ref.controls, *self.var_ref.binary_controls]
        ].dropna()
        input_values = result_df.parameter[self.var_ref.inputs].dropna()

        # Get the simulation time step index
        sim_time_index = np.arange(0, (n_simulation_steps + 1) * sim_time_step, sim_time_step)

        # Reindex the controls and inputs to sim_time_index
        control_values_full = control_values.copy().reindex(sim_time_index, method="ffill")
        input_values_full = input_values.copy().reindex(sim_time_index, method="nearest")

        for i in range(0, n_simulation_steps):
            current_sim_time = i * sim_time_step

            # Apply control and input values from the appropriate MPC step
            for control, value in zip(
                self.var_ref.controls,
                control_values_full.loc[current_sim_time, self.var_ref.controls],
            ):
                self.flex_model.set(control, value)

            for binary_control, value in zip(
                self.var_ref.binary_controls,
                control_values_full.loc[current_sim_time, self.var_ref.binary_controls],
            ):
                self.flex_model.set(binary_control, value)

            for input_var, value in zip(
                self.var_ref.inputs, input_values_full.loc[current_sim_time]
            ):
                # change the type of iterable input, since casadi model can't deal with iterable
                if issubclass(eval(self.flex_model.get(input_var).type), Iterable):
                    self.flex_model.get(input_var).type = type(value).__name__
                self.flex_model.set(input_var, value)

            # do integration
            # reduce the simulation time step so that the total horizon time will not be exceeded
            if current_sim_time + sim_time_step <= total_horizon_time:
                t_sample = sim_time_step
            else:
                t_sample = total_horizon_time - current_sim_time
            self.flex_model.do_step(t_start=0, t_sample=t_sample)

            # save output
            for output in self.var_ref.outputs:
                self.flex_results.loc[
                    (self.env.now, current_sim_time + t_sample), output
                ] = self.flex_model.get_output(output).value
1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.baseline_mpc:[98:234]
==agentlib_flexquant.modules.shadow_mpc:[382:514]
        if not self.config.set_outputs:
            return
        self.logger.info("Sending optimal output values to data_broker.")

        # simulate with the casadi simulator
        self.sim_flex_model(solution)

        # extract solution DataFrama
        df = solution.df

        # send the outputs
        if self.flex_results is not None:
            for output in self.var_ref.outputs:
                if output not in [
                    self.config.power_variable_name,
                    self.config.storage_variable_name,
                ]:
                    series = df.variable[output]
                    self.set(output, series)
            # send the power and storage variable value from simulation results
            upsampled_output_power = self.flex_results[self.config.power_variable_name]
            self.set(self.config.power_variable_name, upsampled_output_power)
            if self.config.storage_variable_name is not None:
                upsampled_output_storage = self.flex_results[self.config.storage_variable_name]
                self.set(self.config.storage_variable_name, upsampled_output_storage.dropna())
        else:
            for output in self.var_ref.outputs:
                series = df.variable[output]
                self.set(output, series)

    def sim_flex_model(self, solution):
        """simulate the flex model over the preditcion horizon and save results"""

        # return if sim_time_step is not a positive integer and system is in provision
        if not (self.config.casadi_sim_time_step > 0 and not self.get("in_provision").value):
            return

        # read the defined simulation time step
        sim_time_step = self.config.casadi_sim_time_step
        mpc_time_step = self.config.time_step

        # set the horizon length and the number of simulation steps
        total_horizon_time = int(self.config.prediction_horizon * self.config.time_step)
        n_simulation_steps = math.ceil(total_horizon_time / sim_time_step)

        # read the current optimization result
        result_df = solution.df

        # initialize the flex sim results Dataframe
        self._initialize_flex_results(
            n_simulation_steps, total_horizon_time, sim_time_step, result_df
        )

        # Update model parameters and initial states
        self._update_model_parameters()
        self._update_initial_states(result_df)

        # Run simulation
        self._run_simulation(
            n_simulation_steps, sim_time_step, mpc_time_step, result_df, total_horizon_time
        )

        # set index of flex results to the same as mpc result
        store_results_df = self.flex_results.copy(deep=True)
        store_results_df.index = self.flex_results.index.tolist()

        # save results
        if not os.path.exists(self.res_file_flex):
            store_results_df.to_csv(self.res_file_flex)
        else:
            store_results_df.to_csv(self.res_file_flex, mode="a", header=False)

        # set the flex results format same as mpc result while updating Agentvariable
        self.flex_results.index = self.flex_results.index.get_level_values(1)

    def _initialize_flex_results(
        self, n_simulation_steps, horizon_length, sim_time_step, result_df
    ):
        """Initialize the flex results dataframe with the correct dimension and index
        and fill with existing results from optimization
        """

        # create MultiIndex for collocation points
        index_coll = pd.MultiIndex.from_arrays(
            [[self.env.now] * len(result_df.index), result_df.index],
            names=["time_step", "time"]
            # Match the names with multi_index but note they're reversed
        )
        # create Multiindex for full simulation sample times
        index_full_sample = pd.MultiIndex.from_tuples(
            zip(
                [self.env.now] * (n_simulation_steps + 1),
                range(0, horizon_length + sim_time_step, sim_time_step),
            ),
            names=["time_step", "time"],
        )
        # merge indexes
        new_index = index_coll.union(index_full_sample).sort_values()
        # initialize the flex results with correct dimension
        self.flex_results = pd.DataFrame(np.nan, index=new_index, columns=self.var_ref.outputs)

        # Get the optimization outputs and create a series for fixed optimization outputs with the
        # correct MultiIndex format
        opti_outputs = result_df.variable[self.config.power_variable_name]
        fixed_opti_output = pd.Series(
            opti_outputs.values,
            index=index_coll,
        )
        # fill the output value at the time step where it already exists in optimization output
        for idx in fixed_opti_output.index:
            if idx in self.flex_results.index:
                self.flex_results.loc[idx, self.config.power_variable_name] = fixed_opti_output[idx]

    def _update_model_parameters(self):
        """update the value of module parameters with value from config,
        since creating a model just reads the value in the model class but not the config
        """

        for par in self.config.parameters:
            self.flex_model.set(par.name, par.value)

    def _update_initial_states(self, result_df):
        """set the initial value of states"""

        # get state values from the mpc optimization result
        state_values = result_df.variable[self.var_ref.states]
        # update state values with last measurement
        for state, value in zip(self.var_ref.states, state_values.iloc[0]):
            self.flex_model.set(state, value)

    def _run_simulation(
        self, n_simulation_steps, sim_time_step, mpc_time_step, result_df, total_horizon_time
    ):
        """simulate with flex model over the prediction horizon"""

        # get control and input values from the mpc optimization result
1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.baseline_mpc:[181:276]
==agentlib_flexquant.modules.shadow_mpc:[190:285]
        index_coll = pd.MultiIndex.from_arrays(
            [[self.env.now] * len(result_df.index), result_df.index],
            names=["time_step", "time"]
            # Match the names with multi_index but note they're reversed
        )
        # create Multiindex for full simulation sample times
        index_full_sample = pd.MultiIndex.from_tuples(
            zip(
                [self.env.now] * (n_simulation_steps + 1),
                range(0, horizon_length + sim_time_step, sim_time_step),
            ),
            names=["time_step", "time"],
        )
        # merge indexes
        new_index = index_coll.union(index_full_sample).sort_values()
        # initialize the flex results with correct dimension
        self.flex_results = pd.DataFrame(np.nan, index=new_index, columns=self.var_ref.outputs)

        # Get the optimization outputs and create a series for fixed optimization outputs with the
        # correct MultiIndex format
        opti_outputs = result_df.variable[self.config.power_variable_name]
        fixed_opti_output = pd.Series(
            opti_outputs.values,
            index=index_coll,
        )
        # fill the output value at the time step where it already exists in optimization output
        for idx in fixed_opti_output.index:
            if idx in self.flex_results.index:
                self.flex_results.loc[idx, self.config.power_variable_name] = fixed_opti_output[idx]

    def _update_model_parameters(self):
        """update the value of module parameters with value from config,
        since creating a model just reads the value in the model class but not the config
        """

        for par in self.config.parameters:
            self.flex_model.set(par.name, par.value)

    def _update_initial_states(self, result_df):
        """set the initial value of states"""

        # get state values from the mpc optimization result
        state_values = result_df.variable[self.var_ref.states]
        # update state values with last measurement
        for state, value in zip(self.var_ref.states, state_values.iloc[0]):
            self.flex_model.set(state, value)

    def _run_simulation(
        self, n_simulation_steps, sim_time_step, mpc_time_step, result_df, total_horizon_time
    ):
        """simulate with flex model over the prediction horizon"""

        # get control and input values from the mpc optimization result
        control_values = result_df.variable[self.var_ref.controls].dropna()
        input_values = result_df.parameter[self.var_ref.inputs].dropna()

        # Get the simulation time step index
        sim_time_index = np.arange(0, (n_simulation_steps + 1) * sim_time_step, sim_time_step)

        # Reindex the controls and inputs to sim_time_index
        control_values_full = control_values.copy().reindex(sim_time_index, method="ffill")
        input_values_full = input_values.copy().reindex(sim_time_index, method="nearest")

        for i in range(0, n_simulation_steps):
            current_sim_time = i * sim_time_step

            # Apply control and input values from the appropriate MPC step
            for control, value in zip(
                self.var_ref.controls, control_values_full.loc[current_sim_time]
            ):
                self.flex_model.set(control, value)

            for input_var, value in zip(
                self.var_ref.inputs, input_values_full.loc[current_sim_time]
            ):
                # change the type of iterable input, since casadi model can't deal with iterable
                if issubclass(eval(self.flex_model.get(input_var).type), Iterable):
                    self.flex_model.get(input_var).type = type(value).__name__
                self.flex_model.set(input_var, value)

            # do integration
            # reduce the simulation time step so that the total horizon time will not be exceeded
            if current_sim_time + sim_time_step <= total_horizon_time:
                t_sample = sim_time_step
            else:
                t_sample = total_horizon_time - current_sim_time
            self.flex_model.do_step(t_start=0, t_sample=t_sample)

            # save output
            for output in self.var_ref.outputs:
                self.flex_results.loc[
                    (self.env.now, current_sim_time + t_sample), output
                ] = self.flex_model.get_output(output).value

1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.baseline_mpc:[109:181]
==agentlib_flexquant.modules.shadow_mpc:[72:137]
        if self.flex_results is not None:
            for output in self.var_ref.outputs:
                if output not in [
                    self.config.power_variable_name,
                    self.config.storage_variable_name,
                ]:
                    series = df.variable[output]
                    self.set(output, series)
            # send the power and storage variable value from simulation results
            upsampled_output_power = self.flex_results[self.config.power_variable_name]
            self.set(self.config.power_variable_name, upsampled_output_power)
            if self.config.storage_variable_name is not None:
                upsampled_output_storage = self.flex_results[self.config.storage_variable_name]
                self.set(self.config.storage_variable_name, upsampled_output_storage.dropna())
        else:
            for output in self.var_ref.outputs:
                series = df.variable[output]
                self.set(output, series)

    def sim_flex_model(self, solution):
        """simulate the flex model over the preditcion horizon and save results"""

        # return if sim_time_step is not a positive integer and system is in provision
        if not (self.config.casadi_sim_time_step > 0 and not self.get("in_provision").value):
            return

        # read the defined simulation time step
        sim_time_step = self.config.casadi_sim_time_step
        mpc_time_step = self.config.time_step

        # set the horizon length and the number of simulation steps
        total_horizon_time = int(self.config.prediction_horizon * self.config.time_step)
        n_simulation_steps = math.ceil(total_horizon_time / sim_time_step)

        # read the current optimization result
        result_df = solution.df

        # initialize the flex sim results Dataframe
        self._initialize_flex_results(
            n_simulation_steps, total_horizon_time, sim_time_step, result_df
        )

        # Update model parameters and initial states
        self._update_model_parameters()
        self._update_initial_states(result_df)

        # Run simulation
        self._run_simulation(
            n_simulation_steps, sim_time_step, mpc_time_step, result_df, total_horizon_time
        )

        # set index of flex results to the same as mpc result
        store_results_df = self.flex_results.copy(deep=True)
        store_results_df.index = self.flex_results.index.tolist()

        # save results
        if not os.path.exists(self.res_file_flex):
            store_results_df.to_csv(self.res_file_flex)
        else:
            store_results_df.to_csv(self.res_file_flex, mode="a", header=False)

        # set the flex results format same as mpc result while updating Agentvariable
        self.flex_results.index = self.flex_results.index.get_level_values(1)

    def register_callbacks(self):
1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.baseline_mpc:[441:494]
==agentlib_flexquant.modules.shadow_mpc:[190:243]
        index_coll = pd.MultiIndex.from_arrays(
            [[self.env.now] * len(result_df.index), result_df.index],
            names=["time_step", "time"]
            # Match the names with multi_index but note they're reversed
        )
        # create Multiindex for full simulation sample times
        index_full_sample = pd.MultiIndex.from_tuples(
            zip(
                [self.env.now] * (n_simulation_steps + 1),
                range(0, horizon_length + sim_time_step, sim_time_step),
            ),
            names=["time_step", "time"],
        )
        # merge indexes
        new_index = index_coll.union(index_full_sample).sort_values()
        # initialize the flex results with correct dimension
        self.flex_results = pd.DataFrame(np.nan, index=new_index, columns=self.var_ref.outputs)

        # Get the optimization outputs and create a series for fixed optimization outputs with
        # the correct MultiIndex format
        opti_outputs = result_df.variable[self.config.power_variable_name]
        fixed_opti_output = pd.Series(
            opti_outputs.values,
            index=index_coll,
        )
        # fill the output value at the time step where it already exists in optimization output
        for idx in fixed_opti_output.index:
            if idx in self.flex_results.index:
                self.flex_results.loc[idx, self.config.power_variable_name] = fixed_opti_output[idx]

    def _update_model_parameters(self):
        """update the value of module parameters with value from config,
        since creating a model just reads the value in the model class but not the config
        """

        for par in self.config.parameters:
            self.flex_model.set(par.name, par.value)

    def _update_initial_states(self, result_df):
        """set the initial value of states"""

        # get state values from the mpc optimization result
        state_values = result_df.variable[self.var_ref.states]
        # update state values with last measurement
        for state, value in zip(self.var_ref.states, state_values.iloc[0]):
            self.flex_model.set(state, value)

    def _run_simulation(
        self, n_simulation_steps, sim_time_step, mpc_time_step, result_df, total_horizon_time
    ):
        """simulate with flex model over the prediction horizon"""

        # get control and input values from the mpc optimization result
1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.baseline_mpc:[253:276]
==agentlib_flexquant.modules.shadow_mpc:[542:563]
            for input_var, value in zip(
                self.var_ref.inputs, input_values_full.loc[current_sim_time]
            ):
                # change the type of iterable input, since casadi model can't deal with iterable
                if issubclass(eval(self.flex_model.get(input_var).type), Iterable):
                    self.flex_model.get(input_var).type = type(value).__name__
                self.flex_model.set(input_var, value)

            # do integration
            # reduce the simulation time step so that the total horizon time will not be exceeded
            if current_sim_time + sim_time_step <= total_horizon_time:
                t_sample = sim_time_step
            else:
                t_sample = total_horizon_time - current_sim_time
            self.flex_model.do_step(t_start=0, t_sample=t_sample)

            # save output
            for output in self.var_ref.outputs:
                self.flex_results.loc[
                    (self.env.now, current_sim_time + t_sample), output
                ] = self.flex_model.get_output(output).value
1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.baseline_mpc:[522:543]
==agentlib_flexquant.modules.shadow_mpc:[262:285]
            for input_var, value in zip(
                self.var_ref.inputs, input_values_full.loc[current_sim_time]
            ):
                # change the type of iterable input, since casadi model can't deal with iterable
                if issubclass(eval(self.flex_model.get(input_var).type), Iterable):
                    self.flex_model.get(input_var).type = type(value).__name__
                self.flex_model.set(input_var, value)

            # do integration
            # reduce the simulation time step so that the total horizon time will not be exceeded
            if current_sim_time + sim_time_step <= total_horizon_time:
                t_sample = sim_time_step
            else:
                t_sample = total_horizon_time - current_sim_time
            self.flex_model.do_step(t_start=0, t_sample=t_sample)

            # save output
            for output in self.var_ref.outputs:
                self.flex_results.loc[
                    (self.env.now, current_sim_time + t_sample), output
                ] = self.flex_model.get_output(output).value
1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.baseline_mpc:[318:339]
==agentlib_flexquant.modules.shadow_mpc:[312:327]
        if self.config.casadi_sim_time_step > 0:
            # generate a separate flex_model for integration to ensure the model used in MPC
            # optimization remains unaffected
            self.flex_model = type(self.model)(dt=self.config.casadi_sim_time_step)
            # generate the filename for the simulation results
            self.res_file_flex = self.config.optimization_backend["results_file"].replace(
                "mpc", "mpc_sim"
            )
            # clear the casadi simulator result at the first time step if already exists
            try:
                os.remove(self.res_file_flex)
            except:
                pass

    def register_callbacks(self):
1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.baseline_mpc:[60:81]
==agentlib_flexquant.modules.shadow_mpc:[50:67]
        if self.config.casadi_sim_time_step > 0:
            # generate a separate flex_model for integration to ensure
            # the model used in MPC optimization remains unaffected
            self.flex_model = type(self.model)(dt=self.config.casadi_sim_time_step)
            # generate the filename for the simulation results
            self.res_file_flex = self.config.optimization_backend["results_file"].replace(
                "mpc", "mpc_sim"
            )
            # clear the casadi simulator result at the first time step if already exists
            try:
                os.remove(self.res_file_flex)
            except:
                pass

    def pre_computation_hook(self):
        """Calculate relative start and end times for flexibility provision.

        When in provision mode, computes the relative timing for flexibility
        events based on the external power profile timestamps and current
        environment time.
        """
1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.baseline_mpc:[235:249]
==agentlib_flexquant.modules.shadow_mpc:[517:531]
        input_values = result_df.parameter[self.var_ref.inputs].dropna()

        # Get the simulation time step index
        sim_time_index = np.arange(0, (n_simulation_steps + 1) * sim_time_step, sim_time_step)

        # Reindex the controls and inputs to sim_time_index
        control_values_full = control_values.copy().reindex(sim_time_index, method="ffill")
        input_values_full = input_values.copy().reindex(sim_time_index, method="nearest")

        for i in range(0, n_simulation_steps):
            current_sim_time = i * sim_time_step

            # Apply control and input values from the appropriate MPC step
            for control, value in zip(
1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.baseline_mpc:[497:511]
==agentlib_flexquant.modules.shadow_mpc:[244:258]
        input_values = result_df.parameter[self.var_ref.inputs].dropna()

        # Get the simulation time step index
        sim_time_index = np.arange(0, (n_simulation_steps + 1) * sim_time_step, sim_time_step)

        # Reindex the controls and inputs to sim_time_index
        control_values_full = control_values.copy().reindex(sim_time_index, method="ffill")
        input_values_full = input_values.copy().reindex(sim_time_index, method="nearest")

        for i in range(0, n_simulation_steps):
            current_sim_time = i * sim_time_step

            # Apply control and input values from the appropriate MPC step
            for control, value in zip(
1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.flexibility_indicator:[453:476]
==agentlib_flexquant.modules.flexibility_market:[87:96]
        results_file = self.config.results_file
        try:
            results = pd.read_csv(results_file, header=[0], index_col=[0, 1])
            return results
        except FileNotFoundError:
            self.logger.error("Results file %s was not found.", results_file)
            return None

    def register_callbacks(self):
1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.baseline_mpc:[282:288]
==agentlib_flexquant.modules.shadow_mpc:[25:31]
    casadi_sim_time_step: int = Field(
        default=0,
        description="Time step for simulation with Casadi simulator. Value is read from "
                    "FlexQuantConfig",
    )
    power_variable_name: str = Field(
1 0 refactor duplicate-code R0801
Similar lines in 2 files
==agentlib_flexquant.modules.flexibility_indicator:[324:332]
==agentlib_flexquant.modules.flexibility_market:[61:69]
        if self.results_file and self.results_file.suffix != ".csv":
            raise ValueError(
                f"Invalid file extension for 'results_file': '{self.results_file}'. "
                f"Expected a '.csv' file."
            )
        return self

2 0 error import-error E0401
Unable to import 'numpy'
3 0 error import-error E0401
Unable to import 'agentlib.core.errors'
4 0 error import-error E0401
Unable to import 'agentlib_mpc.optimization_backends.casadi_.minlp_cia'
5 0 error import-error E0401
Unable to import 'agentlib_mpc.optimization_backends.casadi_.core.casadi_backend'
6 0 error import-error E0401
Unable to import 'agentlib_mpc.data_structures.mpc_datamodels'
12 4 warning raise-missing-from W0707
Consider explicitly re-raising using 'except ImportError as exc' and 'raise OptionalDependencyError(used_object='Pycombina', dependency_install='.\\ after cloning pycombina. Instructions: https://pycombina.readthedocs.io/en/latest/install.html#') from exc'
14 29 warning anomalous-backslash-in-string W1401
Anomalous backslash in string: '\ '. String constant might be missing an r prefix.
19 0 convention missing-class-docstring C0115 ConstrainedCIABackendConfig
Missing class docstring
19 0 refactor too-few-public-methods R0903 ConstrainedCIABackendConfig
Too few public methods (0/2)
27 4 convention missing-class-docstring C0115 ConstrainedCIABackendConfig.Config
Missing class docstring
27 4 refactor too-few-public-methods R0903 ConstrainedCIABackendConfig.Config
Too few public methods (0/2)
32 0 convention missing-class-docstring C0115 ConstrainedCasADiCIABackend
Missing class docstring
32 0 refactor too-few-public-methods R0903 ConstrainedCasADiCIABackend
Too few public methods (1/2)
36 4 warning useless-parent-delegation W0246 ConstrainedCasADiCIABackend.__init__
Useless parent or super() delegation in method '__init__'
39 4 convention missing-function-docstring C0116 ConstrainedCasADiCIABackend.do_pycombina
Missing function or method docstring
52 12 refactor no-else-continue R1724 ConstrainedCasADiCIABackend.do_pycombina
Unnecessary "elif" after "continue", remove the leading "el" from "elif"
64 0 warning bad-indentation W0311
Bad indentation. Found 20 spaces, expected 16
67 0 convention line-too-long C0301
Line too long (149/100)
68 0 warning bad-indentation W0311
Bad indentation. Found 20 spaces, expected 16
70 0 warning bad-indentation W0311
Bad indentation. Found 20 spaces, expected 16
71 0 warning bad-indentation W0311
Bad indentation. Found 20 spaces, expected 16
72 0 warning bad-indentation W0311
Bad indentation. Found 20 spaces, expected 16
74 0 warning bad-indentation W0311
Bad indentation. Found 24 spaces, expected 20
77 0 warning bad-indentation W0311
Bad indentation. Found 24 spaces, expected 20

Module agentlib_flexquant.utils.config_management (agentlib_flexquant/utils/config_management.py)

Line Col. Type Symbol ID Obj Message
1 0 convention missing-module-docstring C0114
Missing module docstring
9 0 error import-error E0401
Unable to import 'agentlib.core.agent'
10 0 error import-error E0401
Unable to import 'agentlib.core.module'
11 0 error import-error E0401
Unable to import 'agentlib.modules'
52 11 convention invalid-name C0103 get_module_type_matching_dict
Variable name "v" doesn't conform to snake_case naming style
59 12 convention consider-using-dict-items C0206 get_module_type_matching_dict
Consider iterating with .items()
59 16 convention invalid-name C0103 get_module_type_matching_dict
Variable name "vv" doesn't conform to snake_case naming style
68 8 convention invalid-name C0103 get_module_type_matching_dict
Variable name "v" doesn't conform to snake_case naming style
85 0 refactor inconsistent-return-statements R1710 get_orig_module_type
Either all return statements in a function should return an expression, or none of them should.
102 4 warning useless-else-on-loop W0120 get_module
Else clause on loop without a break statement, remove the else and de-indent all the code inside it
166 24 convention unnecessary-direct-lambda-call C3002 to_dict_and_remove_unnecessary_fields
Lambda expression called directly. Execute the expression inline instead.
174 0 convention missing-function-docstring C0116 get_class_from_file
Missing function or method docstring

Module agentlib_flexquant.utils.data_handling (agentlib_flexquant/utils/data_handling.py)

Line Col. Type Symbol ID Obj Message
1 0 convention missing-module-docstring C0114
Missing module docstring
3 0 error import-error E0401
Unable to import 'pandas'
4 0 error import-error E0401
Unable to import 'agentlib_mpc.utils'
42 32 convention invalid-name C0103 _set_mean_values._get_intervals_for_mean
Argument name "s" doesn't conform to snake_case naming style
74 0 convention missing-function-docstring C0116 strip_multi_index
Missing function or method docstring
77 40 warning unnecessary-lambda W0108 strip_multi_index.<lambda>
Lambda may not be necessary
77 50 warning eval-used W0123 strip_multi_index.<lambda>
Use of eval
85 4 convention invalid-name C0103 convert_timescale_of_index
Argument name "df" doesn't conform to snake_case naming style

Module agentlib_flexquant.utils.interactive (agentlib_flexquant/utils/interactive.py)

Line Col. Type Symbol ID Obj Message
1 0 convention missing-module-docstring C0114
Missing module docstring
4 0 error import-error E0401
Unable to import 'pandas'
5 0 error import-error E0401
Unable to import 'agentlib.core.agent'
6 0 error import-error E0401
Unable to import 'agentlib_mpc.utils'
7 0 error import-error E0401
Unable to import 'agentlib_mpc.utils.analysis'
8 0 error import-error E0401
Unable to import 'agentlib_mpc.utils.plotting.interactive'
9 0 error import-error E0401
Unable to import 'dash'
10 0 error import-error E0401
Unable to import 'plotly'
11 0 error import-error E0401
Unable to import 'pydantic'
13 0 refactor consider-using-from-import R0402
Use 'from agentlib_flexquant.data_structures import flex_results' instead
20 0 refactor too-few-public-methods R0903 CustomBound
Too few public methods (0/2)
46 0 refactor too-many-instance-attributes R0902 Dashboard
Too many instance attributes (8/7)
64 4 refactor too-many-arguments R0913 Dashboard.__init__
Too many arguments (7/5)
88 8 convention invalid-name C0103 Dashboard.__init__
Attribute name "LINE_PROPERTIES" doesn't conform to snake_case naming style
110 12 refactor unnecessary-comprehension R1721 Dashboard.__init__
Unnecessary use of a comprehension, use list(self.intersection_mpcs_sim.keys()) instead.
110 28 convention consider-iterating-dictionary C0201 Dashboard.__init__
Consider iterating the dictionary directly instead of calling .keys()
119 4 refactor too-many-statements R0915 Dashboard.show
Too many statements (135/50)
218 34 convention invalid-name C0103 Dashboard.show.plot_one_mpc_variable._add_step_to_data
Argument name "s" doesn't conform to snake_case naming style
343 8 refactor inconsistent-return-statements R1710 Dashboard.show.plot_flexibility_kpi
Either all return statements in a function should return an expression, or none of them should.
499 8 refactor inconsistent-return-statements R1710 Dashboard.show.mark_characteristic_times_of_accepted_offers
Either all return statements in a function should return an expression, or none of them should.
527 8 refactor too-many-arguments R0913 Dashboard.show.create_plot
Too many arguments (6/5)
561 29 convention consider-iterating-dictionary C0201 Dashboard.show.create_plot
Consider iterating the dictionary directly instead of calling .keys()
581 16 convention invalid-name C0103 Dashboard.show.create_plot
Variable name "ts" doesn't conform to snake_case naming style
608 23 refactor use-dict-literal R1735 Dashboard.show.create_plot
Consider using '{"t": 20, "b": 20}' instead of a call to 'dict'.
698 41 warning f-string-without-interpolation W1309 Dashboard.show
Using an f-string that does not have any interpolated variables

Module agentlib_flexquant.utils.parsing (agentlib_flexquant/utils/parsing.py)

Line Col. Type Symbol ID Obj Message
1 0 convention missing-module-docstring C0114
Missing module docstring
5 0 error import-error E0401
Unable to import 'agentlib_mpc.data_structures.mpc_datamodels'
7 0 warning unused-import W0611
Unused full_trajectory_prefix imported from agentlib_flexquant.data_structures.globals
56 74 warning redefined-builtin W0622 add_input
Redefining built-in 'type'
111 26 warning redefined-builtin W0622 add_output
Redefining built-in 'type'
166 4 convention invalid-name C0103 SetupSystemModifier.visit_Module
Method name "visit_Module" doesn't conform to snake_case naming style
189 4 convention invalid-name C0103 SetupSystemModifier.visit_ClassDef
Method name "visit_ClassDef" doesn't conform to snake_case naming style
241 8 refactor no-else-return R1705 SetupSystemModifier.get_leftmost_list
Unnecessary "elif" after "return", remove the leading "el" from "elif"
319 21 refactor consider-merging-isinstance R1701 SetupSystemModifier.modify_config_class_baseline
Consider merging these isinstance calls to isinstance(body.value, (ast.BinOp, ast.Tuple))
330 21 refactor consider-merging-isinstance R1701 SetupSystemModifier.modify_config_class_baseline
Consider merging these isinstance calls to isinstance(body.value, (ast.BinOp, ast.Tuple))
397 24 warning unused-variable W0612 SetupSystemModifier.modify_setup_system_shadow
Unused variable 'ind'
521 0 convention missing-function-docstring C0116 remove_all_imports_from_tree
Missing function or method docstring

Metrics

Count per types

Name Count
error 82
convention 97
warning 57
refactor 83

Count per messages

Name Count
import-error 82
line-too-long 4
reimported 8
too-many-instance-attributes 4
invalid-name 35
unnecessary-lambda 2
too-many-branches 4
unnecessary-dunder-call 4
protected-access 1
too-many-locals 6
no-else-raise 1
wrong-import-order 15
ungrouped-imports 6
unused-import 8
missing-module-docstring 6
missing-class-docstring 8
missing-function-docstring 15
too-few-public-methods 29
unused-argument 8
unnecessary-pass 1
attribute-defined-outside-init 3
bare-except 4
too-many-arguments 12
eval-used 5
unused-variable 2
consider-using-from-import 1
unnecessary-comprehension 1
consider-iterating-dictionary 2
inconsistent-return-statements 4
use-dict-literal 1
f-string-without-interpolation 1
too-many-statements 1
consider-using-dict-items 1
useless-else-on-loop 1
unnecessary-direct-lambda-call 1
redefined-builtin 2
no-else-return 2
consider-merging-isinstance 2
self-assigning-variable 1
bad-indentation 7
anomalous-backslash-in-string 1
raise-missing-from 1
useless-parent-delegation 1
no-else-continue 1
duplicate-code 14

Count per modules

Name Count
agentlib_flexquant 2
agentlib_flexquant.generate_flex_agents 42
agentlib_flexquant.modules.flexibility_market 23
agentlib_flexquant.modules.shadow_mpc 33
agentlib_flexquant.modules.baseline_mpc 36
agentlib_flexquant.modules.flexibility_indicator 19
agentlib_flexquant.utils.data_handling 8
agentlib_flexquant.utils.interactive 25
agentlib_flexquant.utils.config_management 12
agentlib_flexquant.utils.parsing 12
agentlib_flexquant.data_structures.flex_offer 7
agentlib_flexquant.data_structures.flex_results 15
agentlib_flexquant.data_structures.globals 1
agentlib_flexquant.data_structures.market 6
agentlib_flexquant.data_structures.mpcs 7
agentlib_flexquant.data_structures.flex_kpis 21
agentlib_flexquant.data_structures.flexquant 10
agentlib_flexquant.optimization_backends.constrained_cia 40

Count per path

Name Count
agentlib_flexquant/__init__.py 2
agentlib_flexquant/generate_flex_agents.py 42
agentlib_flexquant/modules/flexibility_market.py 23
agentlib_flexquant/modules/shadow_mpc.py 33
agentlib_flexquant/modules/baseline_mpc.py 36
agentlib_flexquant/modules/flexibility_indicator.py 19
agentlib_flexquant/utils/data_handling.py 8
agentlib_flexquant/utils/interactive.py 25
agentlib_flexquant/utils/config_management.py 12
agentlib_flexquant/utils/parsing.py 12
agentlib_flexquant/data_structures/flex_offer.py 7
agentlib_flexquant/data_structures/flex_results.py 15
agentlib_flexquant/data_structures/globals.py 1
agentlib_flexquant/data_structures/market.py 6
agentlib_flexquant/data_structures/mpcs.py 7
agentlib_flexquant/data_structures/flex_kpis.py 21
agentlib_flexquant/data_structures/flexquant.py 10
agentlib_flexquant/optimization_backends/constrained_cia.py 40