From 67510c6a0fdaa829542284565b7963f651c71d57 Mon Sep 17 00:00:00 2001 From: Jessica Huntley <79837359+jess-farmer@users.noreply.github.com> Date: Mon, 18 Nov 2024 14:35:08 +0000 Subject: [PATCH] Measure energy usage instead of emissions (#1377) * switch from emissions to energy usage * remove local changes * Discard changes to .gitignore * Update fitbenchmarking/core/results_output.py Co-authored-by: RabiyaF <47083562+RabiyaF@users.noreply.github.com> * Update fitbenchmarking/utils/fitbm_result.py Co-authored-by: RabiyaF <47083562+RabiyaF@users.noreply.github.com> * Add units Co-authored-by: RabiyaF <47083562+RabiyaF@users.noreply.github.com> * rename docs page * line length fix * Reduce interval for measuring power usage Co-authored-by: RabiyaF <47083562+RabiyaF@users.noreply.github.com> * ruff format fix --------- Co-authored-by: RabiyaF <47083562+RabiyaF@users.noreply.github.com> --- docs/source/users/options/output_option.rst | 6 +- docs/source/users/output/emissions.rst | 9 -- docs/source/users/output/energy_usage.rst | 9 ++ docs/source/users/output/index.rst | 4 +- fitbenchmarking/cli/checkpoint_handler.py | 6 +- .../cli/tests/test_checkpoint_handler.py | 2 +- fitbenchmarking/cli/tests/test_files/A.json | 12 +- fitbenchmarking/cli/tests/test_files/AB.json | 20 ++-- fitbenchmarking/cli/tests/test_files/B.json | 12 +- fitbenchmarking/cli/tests/test_files/C.json | 12 +- fitbenchmarking/cli/tests/test_files/D.json | 4 +- fitbenchmarking/core/fitting_benchmarking.py | 22 ++-- fitbenchmarking/core/results_output.py | 12 +- .../core/tests/test_fitting_benchmarking.py | 22 ++-- ...issions_table.py => energy_usage_table.py} | 20 ++-- .../results_processing/fitting_report.py | 9 +- .../performance_profiler.py | 8 +- fitbenchmarking/results_processing/tables.py | 2 +- .../{emissions.csv => energy_usage.csv} | 0 .../{emissions.html => energy_usage.html} | 0 .../tests/test_base_table.py | 6 +- .../tests/test_performance_profiler.py | 22 ++-- .../results_processing/tests/test_tables.py | 6 +- .../templates/fitting_report_template.html | 2 +- .../templates/table_descriptions.rst | 6 +- fitbenchmarking/test_files/checkpoint.json | 30 ++--- .../test_files/regression_checkpoint.json | 108 +++++++++--------- fitbenchmarking/utils/checkpoint.py | 4 +- fitbenchmarking/utils/fitbm_result.py | 40 +++---- fitbenchmarking/utils/options.py | 16 ++- .../utils/tests/test_fitbm_result.py | 6 +- .../utils/tests/test_options_output.py | 2 +- 32 files changed, 225 insertions(+), 214 deletions(-) delete mode 100644 docs/source/users/output/emissions.rst create mode 100644 docs/source/users/output/energy_usage.rst rename fitbenchmarking/results_processing/{emissions_table.py => energy_usage_table.py} (65%) rename fitbenchmarking/results_processing/tests/expected_results/{emissions.csv => energy_usage.csv} (100%) rename fitbenchmarking/results_processing/tests/expected_results/{emissions.html => energy_usage.html} (100%) diff --git a/docs/source/users/options/output_option.rst b/docs/source/users/options/output_option.rst index d8c00ad33..c02e9eb3c 100644 --- a/docs/source/users/options/output_option.rst +++ b/docs/source/users/options/output_option.rst @@ -130,9 +130,9 @@ Options are: The value of :math:`\frac{|| J^T r||}{||r||}` for those parameters is also returned. The output looks like ``{bool} (norm_value)``, and the colouring is red for false and cream for true. This option is only meaningful for least-squares cost functions. -* ``emissions`` indicates that the resulting table should contain the CO\ :sub:`2` \ emissions for each of the minimizers. +* ``energy_usage`` indicates that the resulting table should contain energy consumption (kWh) for each of the minimizers. -Default is ``acc``, ``runtime``, ``compare``, ``local_min``, and ``emissions``. +Default is ``acc``, ``runtime``, ``compare``, ``local_min``, and ``energy_usage``. .. code-block:: rst @@ -141,7 +141,7 @@ Default is ``acc``, ``runtime``, ``compare``, ``local_min``, and ``emissions``. runtime compare local_min - emissions + energy_usage Run Dash (:code:`run_dash`) ------------------------------- diff --git a/docs/source/users/output/emissions.rst b/docs/source/users/output/emissions.rst deleted file mode 100644 index 9a0a67998..000000000 --- a/docs/source/users/output/emissions.rst +++ /dev/null @@ -1,9 +0,0 @@ -.. _emissions: - -############### -Emissions Table -############### - -.. currentmodule:: fitbenchmarking.results_processing.emissions_table -.. autoclass:: fitbenchmarking.results_processing.emissions_table.EmissionsTable - :noindex: \ No newline at end of file diff --git a/docs/source/users/output/energy_usage.rst b/docs/source/users/output/energy_usage.rst new file mode 100644 index 000000000..a340a2791 --- /dev/null +++ b/docs/source/users/output/energy_usage.rst @@ -0,0 +1,9 @@ +.. _energy_usage: + +################## +Energy Usage Table +################## + +.. currentmodule:: fitbenchmarking.results_processing.energy_usage_table +.. autoclass:: fitbenchmarking.results_processing.energy_usage_table.EnergyUsageTable + :noindex: \ No newline at end of file diff --git a/docs/source/users/output/index.rst b/docs/source/users/output/index.rst index 09679912c..c85f1d525 100644 --- a/docs/source/users/output/index.rst +++ b/docs/source/users/output/index.rst @@ -18,12 +18,12 @@ Tables acc runtime local_min - emissions + energy_usage Display modes ------------- -The tables for ``accuracy``, ``runtime``, ``emissions``, and ``compare`` have three display +The tables for ``accuracy``, ``runtime``, ``energy_usage``, and ``compare`` have three display modes: .. prettyprintmodulevalue:: diff --git a/fitbenchmarking/cli/checkpoint_handler.py b/fitbenchmarking/cli/checkpoint_handler.py index d93c5255e..1fb9cf4f4 100644 --- a/fitbenchmarking/cli/checkpoint_handler.py +++ b/fitbenchmarking/cli/checkpoint_handler.py @@ -123,10 +123,10 @@ def get_parser() -> ArgumentParser: "--strategy", metavar="STRATEGY", default="first", - choices=["first", "last", "accuracy", "runtime", "emissions"], + choices=["first", "last", "accuracy", "runtime", "energy"], help=( "The merge strategy to use when dealing with conflicts. " - "Selecting accuracy, emissions, or runtime will select for the " + "Selecting accuracy, energy, or runtime will select for the " "lowest from conflicting runs." ), ) @@ -381,7 +381,7 @@ def key_gen(k: dict): key = key_gen(res) if key in A_key: if ( - strategy in ["accuracy", "emissions", "runtime"] + strategy in ["accuracy", "energy", "runtime"] and A[A_key[key]][strategy] > res[strategy] ): A[A_key[key]] = res diff --git a/fitbenchmarking/cli/tests/test_checkpoint_handler.py b/fitbenchmarking/cli/tests/test_checkpoint_handler.py index 3e6ec51b0..923c02703 100644 --- a/fitbenchmarking/cli/tests/test_checkpoint_handler.py +++ b/fitbenchmarking/cli/tests/test_checkpoint_handler.py @@ -179,7 +179,7 @@ def test_strategy(self): "result": 0.1, }, { - "strategy": "emissions", + "strategy": "energy", "result": 12.0, }, ] diff --git a/fitbenchmarking/cli/tests/test_files/A.json b/fitbenchmarking/cli/tests/test_files/A.json index 72198e3da..6e294266a 100644 --- a/fitbenchmarking/cli/tests/test_files/A.json +++ b/fitbenchmarking/cli/tests/test_files/A.json @@ -56,7 +56,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.1, - "emissions": 1.9, + "energy": 1.9, "runtime": 0.2, "flag": 0, "software": "common1", @@ -78,7 +78,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.1, - "emissions": 1.8, + "energy": 1.8, "runtime": 0.2, "flag": 0, "software": "common1", @@ -100,7 +100,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 1.7, + "energy": 1.7, "runtime": 0.0, "flag": 0, "software": "common1", @@ -122,7 +122,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 1.6, + "energy": 1.6, "runtime": 0.0, "flag": 0, "software": "A1", @@ -144,7 +144,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 1.5, + "energy": 1.5, "runtime": 0.0, "flag": 0, "software": "A1", @@ -166,7 +166,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 1.4, + "energy": 1.4, "runtime": 0.0, "flag": 0, "software": "A1", diff --git a/fitbenchmarking/cli/tests/test_files/AB.json b/fitbenchmarking/cli/tests/test_files/AB.json index 2036a6a5d..2a38f8abb 100644 --- a/fitbenchmarking/cli/tests/test_files/AB.json +++ b/fitbenchmarking/cli/tests/test_files/AB.json @@ -72,7 +72,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.1, - "emissions": 1.9, + "energy": 1.9, "runtime": 0.2, "flag": 0, "software": "common1", @@ -94,7 +94,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.1, - "emissions": 1.8, + "energy": 1.8, "runtime": 0.2, "flag": 0, "software": "common1", @@ -116,7 +116,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 1.7, + "energy": 1.7, "runtime": 0.0, "flag": 0, "software": "common1", @@ -138,7 +138,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 1.6, + "energy": 1.6, "runtime": 0.0, "flag": 0, "software": "A1", @@ -160,7 +160,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 1.5, + "energy": 1.5, "runtime": 0.0, "flag": 0, "software": "A1", @@ -182,7 +182,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 1.4, + "energy": 1.4, "runtime": 0.0, "flag": 0, "software": "A1", @@ -204,7 +204,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 0.7, + "energy": 0.7, "runtime": 0.0, "flag": 0, "software": "common1", @@ -226,7 +226,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 0.6, + "energy": 0.6, "runtime": 0.0, "flag": 0, "software": "B1", @@ -248,7 +248,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 0.5, + "energy": 0.5, "runtime": 0.0, "flag": 0, "software": "B1", @@ -270,7 +270,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 0.4, + "energy": 0.4, "runtime": 0.0, "flag": 0, "software": "B1", diff --git a/fitbenchmarking/cli/tests/test_files/B.json b/fitbenchmarking/cli/tests/test_files/B.json index 019812645..58172c75a 100644 --- a/fitbenchmarking/cli/tests/test_files/B.json +++ b/fitbenchmarking/cli/tests/test_files/B.json @@ -56,7 +56,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 12.0, - "emissions": 0.9, + "energy": 0.9, "runtime": 30.0, "flag": 0, "software": "common1", @@ -78,7 +78,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 12.0, - "emissions": 0.8, + "energy": 0.8, "runtime": 30.0, "flag": 0, "software": "common1", @@ -100,7 +100,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 0.7, + "energy": 0.7, "runtime": 0.0, "flag": 0, "software": "common1", @@ -122,7 +122,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 0.6, + "energy": 0.6, "runtime": 0.0, "flag": 0, "software": "B1", @@ -144,7 +144,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 0.5, + "energy": 0.5, "runtime": 0.0, "flag": 0, "software": "B1", @@ -166,7 +166,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 0.4, + "energy": 0.4, "runtime": 0.0, "flag": 0, "software": "B1", diff --git a/fitbenchmarking/cli/tests/test_files/C.json b/fitbenchmarking/cli/tests/test_files/C.json index 75d33a2d2..bcad5518a 100644 --- a/fitbenchmarking/cli/tests/test_files/C.json +++ b/fitbenchmarking/cli/tests/test_files/C.json @@ -56,7 +56,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 2.9, + "energy": 2.9, "runtime": 0.0, "flag": 0, "software": "common1", @@ -78,7 +78,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 2.9, + "energy": 2.9, "runtime": 0.0, "flag": 0, "software": "common1", @@ -100,7 +100,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 2.9, + "energy": 2.9, "runtime": 0.0, "flag": 0, "software": "common1", @@ -122,7 +122,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 2.9, + "energy": 2.9, "runtime": 0.0, "flag": 0, "software": "A1", @@ -144,7 +144,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 2.9, + "energy": 2.9, "runtime": 0.0, "flag": 0, "software": "A1", @@ -166,7 +166,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 2.9, + "energy": 2.9, "runtime": 0.0, "flag": 0, "software": "A1", diff --git a/fitbenchmarking/cli/tests/test_files/D.json b/fitbenchmarking/cli/tests/test_files/D.json index b9f56db98..a4b9627ea 100644 --- a/fitbenchmarking/cli/tests/test_files/D.json +++ b/fitbenchmarking/cli/tests/test_files/D.json @@ -24,7 +24,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 2.9, + "energy": 2.9, "runtime": 0.0, "flag": 0, "software": "common1", @@ -46,7 +46,7 @@ "fin_params": "", "fin_params_str": "", "accuracy": 0.0, - "emissions": 2.9, + "energy": 2.9, "runtime": 0.0, "flag": 0, "software": "A1", diff --git a/fitbenchmarking/core/fitting_benchmarking.py b/fitbenchmarking/core/fitting_benchmarking.py index eed35917d..40b038cff 100644 --- a/fitbenchmarking/core/fitting_benchmarking.py +++ b/fitbenchmarking/core/fitting_benchmarking.py @@ -69,8 +69,8 @@ def __init__(self, options, data_dir, checkpointer, label="benchmark"): self.__grabbed_output = output_grabber.OutputGrabber(self._options) self.__emissions_tracker = None self.__logger_prefix = " " - if "emissions" in options.table_type: - self.__emissions_tracker = EmissionsTracker() + if "energy_usage" in options.table_type: + self.__emissions_tracker = EmissionsTracker(measure_power_secs=1) def benchmark(self): """ @@ -477,12 +477,12 @@ def __loop_over_hessians(self, controller): ) # Perform the fit a number of times specified by num_runs - accuracy, runtimes, emissions = self.__perform_fit(controller) + accuracy, runtimes, energy = self.__perform_fit(controller) result_args = { "controller": controller, "accuracy": accuracy, "runtimes": runtimes, - "emissions": emissions, + "energy": energy, "runtime_metric": self._options.runtime_metric, } if problem.multifit: @@ -514,11 +514,11 @@ def __perform_fit(self, controller): :param controller: The software controller for the fitting :type controller: Object derived from BaseSoftwareController - :return: The chi squared, runtimes and emissions of the fit. + :return: The chi squared, runtimes and energy usage of the fit. :rtype: tuple(float, list[float], float) """ num_runs = self._options.num_runs - emissions = np.nan + energy = np.nan tracker = self.__emissions_tracker try: @@ -530,7 +530,7 @@ def __perform_fit(self, controller): runtimes = timeit.Timer(stmt=controller.execute).repeat( num_runs, 1 ) - emissions = tracker.stop_task().emissions / num_runs + energy = tracker.stop_task().energy_consumed / num_runs else: runtimes = timeit.Timer(stmt=controller.execute).repeat( num_runs, 1 @@ -601,14 +601,14 @@ def __perform_fit(self, controller): # Reset the controller timer once exceptions have been handled controller.timer.reset() - # ensure emissions tracker has been stopped if emissions not set - if emissions == np.nan and self.__emissions_tracker: + # ensure emissions tracker has been stopped if energy not set + if energy == np.nan and self.__emissions_tracker: _ = self.__emissions_tracker.stop_task() if controller.flag in [3, 6, 7]: # If there was an exception, set the runtimes and # cost function value to be infinite - emissions = np.inf + energy = np.inf multi_fit = controller.problem.multifit runtimes = [np.inf] * num_runs controller.final_params = ( @@ -624,4 +624,4 @@ def __perform_fit(self, controller): # flag if not controller.check_bounds_respected() - return accuracy, runtimes, emissions + return accuracy, runtimes, energy diff --git a/fitbenchmarking/core/results_output.py b/fitbenchmarking/core/results_output.py index b0f954bec..a9f6532e8 100644 --- a/fitbenchmarking/core/results_output.py +++ b/fitbenchmarking/core/results_output.py @@ -286,7 +286,7 @@ def _process_best_results(results: list[FittingResult]) -> FittingResult: - Setting the `is_best_fit` flag, - Setting the `min_accuracy` value, - Setting the `min_runtime` value, and - - Setting the `min_emissions` value + - Setting the `min_energy` value :param results: The results to compare and update :type results: list[FittingResult] @@ -302,7 +302,7 @@ def _process_best_results(results: list[FittingResult]) -> FittingResult: best = result if fastest.runtime > result.runtime: fastest = result - if lowest.emissions > result.emissions: + if lowest.energy > result.energy: lowest = result best.is_best_fit = True @@ -310,7 +310,7 @@ def _process_best_results(results: list[FittingResult]) -> FittingResult: for result in results: result.min_accuracy = best.accuracy result.min_runtime = fastest.runtime - result.min_emissions = lowest.emissions + result.min_energy = lowest.energy return best @@ -790,9 +790,9 @@ def run_dash_app(options, pp_dfs_all_prob_sets) -> None: pp_df=pp_dfs["runtime"], group_label=group, ), - "emissions": DashPerfProfile( - profile_name="Emissions", - pp_df=pp_dfs["emissions"], + "energy": DashPerfProfile( + profile_name="Energy Usage", + pp_df=pp_dfs["energy_usage"], group_label=group, ), } diff --git a/fitbenchmarking/core/tests/test_fitting_benchmarking.py b/fitbenchmarking/core/tests/test_fitting_benchmarking.py index 3a03ed5c8..502a1eaf8 100644 --- a/fitbenchmarking/core/tests/test_fitting_benchmarking.py +++ b/fitbenchmarking/core/tests/test_fitting_benchmarking.py @@ -55,7 +55,7 @@ def mock_loop_over_hessians_func_call(controller): "controller": controller, "accuracy": 1, "runtimes": [2], - "emissions": 3, + "energy": 3, "runtime_metric": "mean", } result = FittingResult(**result_args) @@ -109,7 +109,7 @@ def mock_loop_over_cost_func_call_all_fail(problem): """ Mock function for the __loop_over_cost_func method when an exception is raised and accuracy, runtime and - emissions are all np.inf. + energy are all np.inf. """ cost_func = WeightedNLLSCostFunc(problem) controller = ScipyController(cost_func) @@ -119,7 +119,7 @@ def mock_loop_over_cost_func_call_all_fail(problem): controller=controller, accuracy=np.inf, runtimes=[np.inf], - emissions=np.inf, + energy=np.inf, runtime_metric="mean", ) return [result] @@ -202,13 +202,13 @@ def test_perform_fit_method(self): ["Nelder-Mead", "Powell"], case["results"] ): controller.minimizer = minimizer - accuracy, runtimes, emissions = fit._Fit__perform_fit( + accuracy, runtimes, energy = fit._Fit__perform_fit( controller ) self.assertAlmostEqual(accuracy, acc, 6) assert len(runtimes) == self.options.num_runs - assert emissions != np.inf + assert energy != np.inf @patch( "fitbenchmarking.controllers.base_controller.Controller.eval_confidence" @@ -246,9 +246,9 @@ def test_perform_fit_error_handling(self, mock): for exp in [ValidationException, FitBenchmarkException]: mock.side_effect = exp - accuracy, runtimes, emissions = fit._Fit__perform_fit(controller) + accuracy, runtimes, energy = fit._Fit__perform_fit(controller) assert accuracy == np.inf - assert emissions == np.inf + assert energy == np.inf assert runtimes == [np.inf] * 5 @patch("timeit.Timer.repeat") @@ -299,10 +299,10 @@ def test_perform_fit_max_runtime_error(self, mock): fit = Fit(options=self.options, data_dir="test5", checkpointer=self.cp) mock.side_effect = MaxRuntimeError - accuracy, runtimes, emissions = fit._Fit__perform_fit(controller) + accuracy, runtimes, energy = fit._Fit__perform_fit(controller) assert controller.flag == 6 assert accuracy == np.inf - assert emissions == np.inf + assert energy == np.inf assert runtimes == [np.inf] * 5 @patch( @@ -403,7 +403,7 @@ def test_loop_over_hessians_multifit(self, perform_fit, mock): controller=self.controller, accuracy=1, runtimes=[2], - emissions=3, + energy=3, runtime_metric="mean", ) self.controller.problem.multifit = True @@ -869,7 +869,7 @@ def setUp(self): "runtime", "compare", "local_min", - "emissions", + "energy_usage", ], } ) diff --git a/fitbenchmarking/results_processing/emissions_table.py b/fitbenchmarking/results_processing/energy_usage_table.py similarity index 65% rename from fitbenchmarking/results_processing/emissions_table.py rename to fitbenchmarking/results_processing/energy_usage_table.py index f59c6858e..c2287059e 100644 --- a/fitbenchmarking/results_processing/emissions_table.py +++ b/fitbenchmarking/results_processing/energy_usage_table.py @@ -1,14 +1,14 @@ """ -Emissions table +Energy Usage table """ from fitbenchmarking.results_processing.base_table import Table -class EmissionsTable(Table): +class EnergyUsageTable(Table): r""" - The emissions (kg CO\ :sub:`2`\ eq) results are calculated + The energy usage (kWh) results are calculated from an average (over num_runs) using the `codecarbon `_ module. num_runs is set in :ref:`options`. @@ -22,23 +22,23 @@ class EmissionsTable(Table): """ - name = "emissions" - cbar_title = "Problem-Specific Cell Shading: Relative Emissions" + name = "energy_usage" + cbar_title = "Problem-Specific Cell Shading: Relative Energy Usage" def get_value(self, result): """ Gets the main value to be reported in the tables for a given result - Note that the first value (relative emissions) will be used in the + Note that the first value (relative energy usage) will be used in the default colour handling. :param result: The result to generate the values for. :type result: FittingResult - :return: The normalised emissions with respect to the smallest - emissions value and absolute emissions for the result. + :return: The normalised energy usage with respect to the smallest + energy value and absolute energy for the result. :rtype: tuple(float, float) """ - rel_value = result.norm_emissions - abs_value = result.emissions + rel_value = result.norm_energy + abs_value = result.energy return rel_value, abs_value diff --git a/fitbenchmarking/results_processing/fitting_report.py b/fitbenchmarking/results_processing/fitting_report.py index 5e873aefc..28cc5aae3 100644 --- a/fitbenchmarking/results_processing/fitting_report.py +++ b/fitbenchmarking/results_processing/fitting_report.py @@ -94,10 +94,9 @@ def create_prob_group(result, support_pages_dir, options): str(result.func_evals) if result.func_evals else "not available" ) - if np.isnan(result.emissions): - emission_disp = "N/A" - else: - emission_disp = f"{result.emissions:.4g} kg CO\u2082 eq" + energy_disp = ( + "N/A" if np.isnan(result.energy) else f"{result.energy:.4g} kWh" + ) with open(file_path, "w", encoding="utf-8") as fh: fh.write( @@ -113,7 +112,7 @@ def create_prob_group(result, support_pages_dir, options): minimizer=result.modified_minimizer_name(), accuracy=f"{result.accuracy:.4g}", runtime=f"{result.runtime:.4g}", - emissions=emission_disp, + energy=energy_disp, is_best_fit=result.is_best_fit, initial_plot_available=init_success, initial_plot=fig_start, diff --git a/fitbenchmarking/results_processing/performance_profiler.py b/fitbenchmarking/results_processing/performance_profiler.py index 4f3136705..516f21f29 100644 --- a/fitbenchmarking/results_processing/performance_profiler.py +++ b/fitbenchmarking/results_processing/performance_profiler.py @@ -51,7 +51,7 @@ def prepare_profile_data(results): :return: dictionary containing number of occurrences :rtype: dict[str, dict[str, list[float]]] """ - pp_data = {"acc": {}, "runtime": {}, "emissions": {}} + pp_data = {"acc": {}, "runtime": {}, "energy_usage": {}} minimizers = [] to_remove = set() @@ -70,8 +70,8 @@ def prepare_profile_data(results): minimizers[i] = key pp_data["acc"][minimizers[i]].append(result.norm_acc) pp_data["runtime"][minimizers[i]].append(result.norm_runtime) - pp_data["emissions"][minimizers[i]].append( - result.norm_emissions + pp_data["energy_usage"][minimizers[i]].append( + result.norm_energy ) for key in to_remove: @@ -88,7 +88,7 @@ def compute_step_values(profile_plot): :param profile_plot: data related to the metric being profiled :type profile_plot: dict[str, list[float]] - :return: acc or runtime or emissions values to plot, + :return: acc or runtime or energy usage values to plot, maximum x value :rtype: list[np.arrays(float)], float """ diff --git a/fitbenchmarking/results_processing/tables.py b/fitbenchmarking/results_processing/tables.py index 1a5c01611..7f0b5ef7b 100644 --- a/fitbenchmarking/results_processing/tables.py +++ b/fitbenchmarking/results_processing/tables.py @@ -31,7 +31,7 @@ 8: "Confidence in fit could not be calculated", } -SORTED_TABLE_NAMES = ["compare", "acc", "runtime", "local_min", "emissions"] +SORTED_TABLE_NAMES = ["compare", "acc", "runtime", "local_min", "energy_usage"] def create_results_tables( diff --git a/fitbenchmarking/results_processing/tests/expected_results/emissions.csv b/fitbenchmarking/results_processing/tests/expected_results/energy_usage.csv similarity index 100% rename from fitbenchmarking/results_processing/tests/expected_results/emissions.csv rename to fitbenchmarking/results_processing/tests/expected_results/energy_usage.csv diff --git a/fitbenchmarking/results_processing/tests/expected_results/emissions.html b/fitbenchmarking/results_processing/tests/expected_results/energy_usage.html similarity index 100% rename from fitbenchmarking/results_processing/tests/expected_results/emissions.html rename to fitbenchmarking/results_processing/tests/expected_results/energy_usage.html diff --git a/fitbenchmarking/results_processing/tests/test_base_table.py b/fitbenchmarking/results_processing/tests/test_base_table.py index e60d89efc..379e2ae93 100644 --- a/fitbenchmarking/results_processing/tests/test_base_table.py +++ b/fitbenchmarking/results_processing/tests/test_base_table.py @@ -82,7 +82,7 @@ def test_create_results_dict_correct_dict(self): pp_locations={ "acc": "no", "runtime": "pp", - "emissions": "available", + "energy_usage": "available", }, table_name="A table!", ) @@ -128,7 +128,7 @@ def setUp(self): pp_locations={ "acc": "no", "runtime": "pp", - "emissions": "available", + "energy_usage": "available", }, table_name="A table!", ) @@ -176,7 +176,7 @@ def setUp(self): pp_locations={ "acc": "no", "runtime": "pp", - "emissions": "available", + "energy_usage": "available", }, table_name="A table!", ) diff --git a/fitbenchmarking/results_processing/tests/test_performance_profiler.py b/fitbenchmarking/results_processing/tests/test_performance_profiler.py index 8863fef0f..d4e8965ca 100644 --- a/fitbenchmarking/results_processing/tests/test_performance_profiler.py +++ b/fitbenchmarking/results_processing/tests/test_performance_profiler.py @@ -151,8 +151,8 @@ def setUp(self): v / min_runtime for v in self.runtime_expected[k] ] - min_emissions = 1.0 - self.emissions_expected = { + min_energy = 1.0 + self.energy_expected = { "m00 [s0]: j:j0": [np.inf, np.inf], "m00 [s0]: j:j1": [np.inf, np.inf], "m01 [s0]: j:j0": [1e4, 10.0], @@ -162,9 +162,9 @@ def setUp(self): "m11 [s1]: j:j0": [1e3, 1.0], "m11 [s1]: j:j1": [1e2, 1e2], } - for k in self.emissions_expected: - self.emissions_expected[k] = [ - v / min_emissions for v in self.emissions_expected[k] + for k in self.energy_expected: + self.energy_expected[k] = [ + v / min_energy for v in self.energy_expected[k] ] self.fig_dir = "" @@ -240,7 +240,7 @@ def tearDown(self): """ Removes expected plots """ - for metric in ["acc", "runtime", "emissions"]: + for metric in ["acc", "runtime", "energy_usage"]: if os.path.isfile(f"{metric}_profile.html"): os.remove(f"{metric}_profile.html") @@ -254,8 +254,8 @@ def test_correct_prepare_profile_data(self): assert np.allclose(v, bounds["acc"][k]) for k, v in self.runtime_expected.items(): assert np.allclose(v, bounds["runtime"][k]) - for k, v in self.emissions_expected.items(): - assert np.allclose(v, bounds["emissions"][k]) + for k, v in self.energy_expected.items(): + assert np.allclose(v, bounds["energy_usage"][k]) def test_correct_profile_output_paths(self): """ @@ -266,7 +266,7 @@ def test_correct_profile_output_paths(self): ) assert pp_locations["acc"] == "acc_profile.html" assert pp_locations["runtime"] == "runtime_profile.html" - assert pp_locations["emissions"] == "emissions_profile.html" + assert pp_locations["energy_usage"] == "energy_usage_profile.html" def test_profile_returns_dict(self): """ @@ -333,7 +333,7 @@ def test_create_plots_and_get_paths(self): """ Test that create_plots_and_get_paths returns the correct paths. """ - bounds = {"acc": {}, "runtime": {}, "emissions": {}} + bounds = {"acc": {}, "runtime": {}, "energy_usage": {}} paths = performance_profiler.create_plots_and_get_paths( bounds, self.fig_dir, self.options ) @@ -341,7 +341,7 @@ def test_create_plots_and_get_paths(self): expec_paths = { "acc": "acc_profile.html", "runtime": "runtime_profile.html", - "emissions": "emissions_profile.html", + "energy_usage": "energy_usage_profile.html", } assert paths == expec_paths diff --git a/fitbenchmarking/results_processing/tests/test_tables.py b/fitbenchmarking/results_processing/tests/test_tables.py index c079e553c..0a0c41627 100644 --- a/fitbenchmarking/results_processing/tests/test_tables.py +++ b/fitbenchmarking/results_processing/tests/test_tables.py @@ -88,7 +88,7 @@ def test_tables_correct(self): fig_dir=self.fig_dir, pp_locations={ "acc": "pp_1", - "emissions": "pp_3", + "energy_usage": "pp_3", "runtime": "pp_2", }, table_name="table_name", @@ -119,7 +119,7 @@ def test_dropdown_html_correct(self): fig_dir=self.fig_dir, pp_locations={ "acc": "pp_1", - "emissions": "pp_3", + "energy_usage": "pp_3", "runtime": "pp_2", }, table_name="table_name", @@ -236,7 +236,7 @@ def test_generate_table_page(self): fig_dir=self.fig_dir, pp_locations={ "acc": "pp_1", - "emissions": "pp_3", + "energy_usage": "pp_3", "runtime": "pp_2", }, failed_problems=[], diff --git a/fitbenchmarking/templates/fitting_report_template.html b/fitbenchmarking/templates/fitting_report_template.html index 29ea2c136..b7a668a39 100644 --- a/fitbenchmarking/templates/fitting_report_template.html +++ b/fitbenchmarking/templates/fitting_report_template.html @@ -69,7 +69,7 @@

Minimizer: {{ minimizer }}

Accuracy: {{ accuracy }}

Runtime: {{ runtime }} seconds

-

Emissions: {{ emissions }}

+

Energy Usage: {{ energy }}

Number of iterations: {{ iteration_count }}

Number of function evaluations: {{ func_evals }}

Functions:

diff --git a/fitbenchmarking/templates/table_descriptions.rst b/fitbenchmarking/templates/table_descriptions.rst index 9f2a5de58..f57f82ab2 100644 --- a/fitbenchmarking/templates/table_descriptions.rst +++ b/fitbenchmarking/templates/table_descriptions.rst @@ -33,16 +33,16 @@ The runtime results are calculated from an average using the `timeit `_ module. The number of runs can be set in :ref:`options`. +The energy usage (kWh) results are calculated from an average using the `codecarbon `_ module. The number of runs can be set in :ref:`options`. Configuration for codecarbon is set in ``.codecarbon.config``. Please note that for tracking CPU power usage on Windows or Mac, ``Intel Power Gadget`` shoud also be installed. For more information, see the Methodology section of the `codecarbon docs `_. -emissions: End +energy_usage: End abs: Start diff --git a/fitbenchmarking/test_files/checkpoint.json b/fitbenchmarking/test_files/checkpoint.json index 545769b24..b5ecfac7c 100644 --- a/fitbenchmarking/test_files/checkpoint.json +++ b/fitbenchmarking/test_files/checkpoint.json @@ -46,7 +46,7 @@ 15.0, 16.0 ], - "emissions": 0.001, + "energy": 0.001, "iteration_count": 10, "func_evals": 20, "flag": 0, @@ -76,7 +76,7 @@ 14.0, 15.0 ], - "emissions": 0.0001, + "energy": 0.0001, "iteration_count": 5, "func_evals": 15, "flag": 0, @@ -106,7 +106,7 @@ 13.0, 14.0 ], - "emissions": 0.001, + "energy": 0.001, "iteration_count": 10, "func_evals": 20, "flag": 0, @@ -134,7 +134,7 @@ "runtimes": [ Infinity ], - "emissions": Infinity, + "energy": Infinity, "iteration_count": null, "func_evals": null, "flag": 4, @@ -164,7 +164,7 @@ 11.0, 12.0 ], - "emissions": 1e-05, + "energy": 1e-05, "iteration_count": 4, "func_evals": 20, "flag": 0, @@ -194,7 +194,7 @@ 10.0, 11.0 ], - "emissions": 1e-05, + "energy": 1e-05, "iteration_count": 5, "func_evals": 20, "flag": 0, @@ -222,7 +222,7 @@ "runtimes": [ 1.0 ], - "emissions": 1e-07, + "energy": 1e-07, "iteration_count": 3, "func_evals": 20, "flag": 0, @@ -250,7 +250,7 @@ "runtimes": [ 1.0 ], - "emissions": 1e-07, + "energy": 1e-07, "iteration_count": 10, "func_evals": 15, "flag": 0, @@ -278,7 +278,7 @@ "runtimes": [ 1.0 ], - "emissions": 1e-07, + "energy": 1e-07, "iteration_count": 7, "func_evals": 20, "flag": 0, @@ -307,7 +307,7 @@ 1.0, 3.0 ], - "emissions": 1e-06, + "energy": 1e-06, "iteration_count": 5, "func_evals": 20, "flag": 0, @@ -335,7 +335,7 @@ "runtimes": [ Infinity ], - "emissions": Infinity, + "energy": Infinity, "iteration_count": null, "func_evals": null, "flag": 0, @@ -365,7 +365,7 @@ 1.5, 1.5 ], - "emissions": 1e-05, + "energy": 1e-05, "iteration_count": 7, "func_evals": 20, "flag": 0, @@ -395,7 +395,7 @@ 3.0, 1.0 ], - "emissions": 1e-05, + "energy": 1e-05, "iteration_count": 10, "func_evals": 20, "flag": 0, @@ -425,7 +425,7 @@ 15.0, 20.0 ], - "emissions": 0.001, + "energy": 0.001, "iteration_count": 10, "func_evals": 15, "flag": 0, @@ -453,7 +453,7 @@ "runtimes": [ Infinity ], - "emissions": Infinity, + "energy": Infinity, "iteration_count": null, "func_evals": null, "flag": 0, diff --git a/fitbenchmarking/test_files/regression_checkpoint.json b/fitbenchmarking/test_files/regression_checkpoint.json index b38371f78..ab50b57e3 100644 --- a/fitbenchmarking/test_files/regression_checkpoint.json +++ b/fitbenchmarking/test_files/regression_checkpoint.json @@ -304,7 +304,7 @@ 0.0023708750086370856, 0.0022464170033345 ], - "emissions": 1.3810022468213092e-08, + "energy": 1.3810022468213092e-08, "iteration_count": null, "func_evals": 23, "flag": 0, @@ -336,7 +336,7 @@ 0.0031050420075189322, 0.002993957998114638 ], - "emissions": 1.849952823293049e-08, + "energy": 1.849952823293049e-08, "iteration_count": null, "func_evals": 22, "flag": 0, @@ -368,7 +368,7 @@ 0.0054976249957690015, 0.005278666998492554 ], - "emissions": 1.0605073449939896e-08, + "energy": 1.0605073449939896e-08, "iteration_count": null, "func_evals": 22, "flag": 0, @@ -400,7 +400,7 @@ 0.0034340839920332655, 0.002982749996590428 ], - "emissions": 7.33967736034619e-10, + "energy": 7.33967736034619e-10, "iteration_count": null, "func_evals": 22, "flag": 0, @@ -432,7 +432,7 @@ 0.004883790999883786, 0.003975915999035351 ], - "emissions": 4.0616884467871645e-09, + "energy": 4.0616884467871645e-09, "iteration_count": null, "func_evals": 20, "flag": 0, @@ -464,7 +464,7 @@ 0.004795875007403083, 0.004808792000403628 ], - "emissions": 3.4336781125879947e-09, + "energy": 3.4336781125879947e-09, "iteration_count": null, "func_evals": 20, "flag": 0, @@ -496,7 +496,7 @@ 0.0009763749985722825, 0.0009662919910624623 ], - "emissions": 4.667983729585149e-09, + "energy": 4.667983729585149e-09, "iteration_count": null, "func_evals": 7, "flag": 0, @@ -528,7 +528,7 @@ 0.0013146669953130186, 0.0013240830012364313 ], - "emissions": 3.2893796731737767e-09, + "energy": 3.2893796731737767e-09, "iteration_count": null, "func_evals": 7, "flag": 0, @@ -560,7 +560,7 @@ 0.0024756250058999285, 0.00242545799119398 ], - "emissions": 1.7244612498570649e-09, + "energy": 1.7244612498570649e-09, "iteration_count": null, "func_evals": 7, "flag": 0, @@ -592,7 +592,7 @@ 0.001033583001117222, 0.0010147079883608967 ], - "emissions": 3.2916151735287774e-09, + "energy": 3.2916151735287774e-09, "iteration_count": null, "func_evals": 7, "flag": 0, @@ -624,7 +624,7 @@ 0.0014726660010637715, 0.0014085419970797375 ], - "emissions": 8.60251985869134e-10, + "energy": 8.60251985869134e-10, "iteration_count": null, "func_evals": 8, "flag": 0, @@ -656,7 +656,7 @@ 0.0025897919986164197, 0.0025450419925618917 ], - "emissions": 8.280805980016723e-10, + "energy": 8.280805980016723e-10, "iteration_count": null, "func_evals": 8, "flag": 0, @@ -688,7 +688,7 @@ 0.006456917006289586, 0.006186124999658205 ], - "emissions": 6.108970160573692e-10, + "energy": 6.108970160573692e-10, "iteration_count": null, "func_evals": 46, "flag": 0, @@ -720,7 +720,7 @@ 0.008974416996352375, 0.008606709001469426 ], - "emissions": 8.536801429183745e-10, + "energy": 8.536801429183745e-10, "iteration_count": null, "func_evals": 43, "flag": 0, @@ -752,7 +752,7 @@ 0.006901874992763624, 0.006575417006388307 ], - "emissions": 5.646563791513459e-10, + "energy": 5.646563791513459e-10, "iteration_count": null, "func_evals": 19, "flag": 0, @@ -784,7 +784,7 @@ 0.0030413329950533807, 0.0028715410007862374 ], - "emissions": 2.576362191370682e-10, + "energy": 2.576362191370682e-10, "iteration_count": null, "func_evals": 12, "flag": 0, @@ -816,7 +816,7 @@ 0.003361916998983361, 0.003252874987083487 ], - "emissions": 7.589013978479646e-10, + "energy": 7.589013978479646e-10, "iteration_count": null, "func_evals": 12, "flag": 0, @@ -848,7 +848,7 @@ 0.0050317499990342185, 0.004846583993639797 ], - "emissions": 1.7111646722583704e-09, + "energy": 1.7111646722583704e-09, "iteration_count": null, "func_evals": 12, "flag": 0, @@ -880,7 +880,7 @@ 0.0008846660057315603, 0.0008856250060489401 ], - "emissions": 9.8937731040118e-10, + "energy": 9.8937731040118e-10, "iteration_count": null, "func_evals": 7, "flag": 0, @@ -912,7 +912,7 @@ 0.0009365419973619282, 0.0009327089937869459 ], - "emissions": 6.019668704512676e-10, + "energy": 6.019668704512676e-10, "iteration_count": null, "func_evals": 7, "flag": 0, @@ -944,7 +944,7 @@ 0.0014208329957909882, 0.0014115000085439533 ], - "emissions": 4.2332423896896704e-10, + "energy": 4.2332423896896704e-10, "iteration_count": null, "func_evals": 7, "flag": 0, @@ -976,7 +976,7 @@ 0.0006892499950481579, 0.0006329169991659 ], - "emissions": 5.830347392628446e-10, + "energy": 5.830347392628446e-10, "iteration_count": null, "func_evals": 7, "flag": 0, @@ -1008,7 +1008,7 @@ 0.00108637499215547, 0.00108712499786634 ], - "emissions": 9.320429498014685e-09, + "energy": 9.320429498014685e-09, "iteration_count": null, "func_evals": 7, "flag": 0, @@ -1040,7 +1040,7 @@ 0.0014177909906720743, 0.0014014589978614822 ], - "emissions": 4.859474739431073e-10, + "energy": 4.859474739431073e-10, "iteration_count": null, "func_evals": 7, "flag": 0, @@ -1072,7 +1072,7 @@ 0.004348999995272607, 0.004193792003206909 ], - "emissions": 8.126778213804962e-09, + "energy": 8.126778213804962e-09, "iteration_count": null, "func_evals": 109, "flag": 0, @@ -1104,7 +1104,7 @@ 0.00886558300408069, 0.008463791004032828 ], - "emissions": 9.296314279304775e-09, + "energy": 9.296314279304775e-09, "iteration_count": null, "func_evals": 78, "flag": 0, @@ -1136,7 +1136,7 @@ 0.007023375001153909, 0.006706999993184581 ], - "emissions": 2.157564807081693e-09, + "energy": 2.157564807081693e-09, "iteration_count": null, "func_evals": 46, "flag": 0, @@ -1168,7 +1168,7 @@ 0.000581459011300467, 0.0005831250018673018 ], - "emissions": 8.868550403709075e-09, + "energy": 8.868550403709075e-09, "iteration_count": null, "func_evals": 9, "flag": 0, @@ -1200,7 +1200,7 @@ 0.000915749988052994, 0.0008743749931454659 ], - "emissions": 2.8019978532733784e-09, + "energy": 2.8019978532733784e-09, "iteration_count": null, "func_evals": 8, "flag": 0, @@ -1232,7 +1232,7 @@ 0.001157042002887465, 0.0011413749889470637 ], - "emissions": 5.125642598363993e-10, + "energy": 5.125642598363993e-10, "iteration_count": null, "func_evals": 8, "flag": 0, @@ -1264,7 +1264,7 @@ 0.0041636250098235905, 0.003924125005141832 ], - "emissions": 5.521810400144202e-10, + "energy": 5.521810400144202e-10, "iteration_count": null, "func_evals": 104, "flag": 0, @@ -1296,7 +1296,7 @@ 0.009229000002960674, 0.008750916997087188 ], - "emissions": 9.555251962234794e-10, + "energy": 9.555251962234794e-10, "iteration_count": null, "func_evals": 80, "flag": 0, @@ -1328,7 +1328,7 @@ 0.0034837090061046183, 0.0033209169923793525 ], - "emissions": 5.966152397999034e-10, + "energy": 5.966152397999034e-10, "iteration_count": null, "func_evals": 21, "flag": 0, @@ -1360,7 +1360,7 @@ 0.00047241699940059334, 0.0004648750036722049 ], - "emissions": 2.4271862813605345e-10, + "energy": 2.4271862813605345e-10, "iteration_count": null, "func_evals": 8, "flag": 0, @@ -1392,7 +1392,7 @@ 0.0008997499971883371, 0.0008847919962136075 ], - "emissions": 7.860250502830282e-10, + "energy": 7.860250502830282e-10, "iteration_count": null, "func_evals": 8, "flag": 0, @@ -1424,7 +1424,7 @@ 0.001240417012013495, 0.0011484160058898851 ], - "emissions": 5.371983379999833e-10, + "energy": 5.371983379999833e-10, "iteration_count": null, "func_evals": 8, "flag": 0, @@ -1456,7 +1456,7 @@ 0.012521208001999184, 0.011987625010078773 ], - "emissions": 1.2939693758238066e-09, + "energy": 1.2939693758238066e-09, "iteration_count": null, "func_evals": 500, "flag": 1, @@ -1488,7 +1488,7 @@ 0.0359477500023786, 0.03577004199905787 ], - "emissions": 1.7021452360580127e-09, + "energy": 1.7021452360580127e-09, "iteration_count": null, "func_evals": 500, "flag": 1, @@ -1520,7 +1520,7 @@ 0.0021916670084465295, 0.0020567089959513396 ], - "emissions": 1.0569142303526877e-09, + "energy": 1.0569142303526877e-09, "iteration_count": null, "func_evals": 12, "flag": 0, @@ -1552,7 +1552,7 @@ 0.0009503750043222681, 0.0008860000089043751 ], - "emissions": 9.786798992997332e-10, + "energy": 9.786798992997332e-10, "iteration_count": null, "func_evals": 18, "flag": 0, @@ -1584,7 +1584,7 @@ 0.002852624995284714, 0.0026370839914307 ], - "emissions": 1.6698313469441864e-09, + "energy": 1.6698313469441864e-09, "iteration_count": null, "func_evals": 21, "flag": 0, @@ -1616,7 +1616,7 @@ 0.001835208007832989, 0.0016652920021442696 ], - "emissions": 4.6083889278081945e-10, + "energy": 4.6083889278081945e-10, "iteration_count": null, "func_evals": 10, "flag": 0, @@ -1648,7 +1648,7 @@ 0.0004477079928619787, 0.00044249999336898327 ], - "emissions": 6.577768687625899e-10, + "energy": 6.577768687625899e-10, "iteration_count": null, "func_evals": 8, "flag": 0, @@ -1680,7 +1680,7 @@ 0.0008331249991897494, 0.0008222500036936253 ], - "emissions": 1.1968909028076634e-09, + "energy": 1.1968909028076634e-09, "iteration_count": null, "func_evals": 8, "flag": 0, @@ -1712,7 +1712,7 @@ 0.0006905000045662746, 0.0006874999962747097 ], - "emissions": 5.7793424806871905e-09, + "energy": 5.7793424806871905e-09, "iteration_count": null, "func_evals": 8, "flag": 0, @@ -1744,7 +1744,7 @@ 0.00035458301135804504, 0.0003522080078255385 ], - "emissions": 2.351489681001856e-10, + "energy": 2.351489681001856e-10, "iteration_count": null, "func_evals": 5, "flag": 0, @@ -1776,7 +1776,7 @@ 0.000557250008569099, 0.0005341669893823564 ], - "emissions": 1.746530835566806e-10, + "energy": 1.746530835566806e-10, "iteration_count": null, "func_evals": 5, "flag": 0, @@ -1808,7 +1808,7 @@ 0.00042050000047311187, 0.0004164580022916198 ], - "emissions": 2.6862119343104064e-09, + "energy": 2.6862119343104064e-09, "iteration_count": null, "func_evals": 5, "flag": 0, @@ -1840,7 +1840,7 @@ 0.0004228750040056184, 0.00038312500691972673 ], - "emissions": 7.393030620861646e-10, + "energy": 7.393030620861646e-10, "iteration_count": null, "func_evals": 7, "flag": 0, @@ -1872,7 +1872,7 @@ 0.0007786670030327514, 0.0007822089974069968 ], - "emissions": 1.3509679499716e-10, + "energy": 1.3509679499716e-10, "iteration_count": null, "func_evals": 8, "flag": 0, @@ -1904,7 +1904,7 @@ 0.0009373339999001473, 0.0008787080005276948 ], - "emissions": 1.3553344078930256e-10, + "energy": 1.3553344078930256e-10, "iteration_count": null, "func_evals": 8, "flag": 0, @@ -1936,7 +1936,7 @@ 0.00031600000511389226, 0.0003104999923380092 ], - "emissions": 2.676123159413175e-10, + "energy": 2.676123159413175e-10, "iteration_count": null, "func_evals": 4, "flag": 0, @@ -1968,7 +1968,7 @@ 0.0004457500035641715, 0.0004385419888421893 ], - "emissions": 2.0421368350661747e-10, + "energy": 2.0421368350661747e-10, "iteration_count": null, "func_evals": 4, "flag": 0, @@ -2000,7 +2000,7 @@ 0.0006452079978771508, 0.0005689999961759895 ], - "emissions": 6.233541548181548e-09, + "energy": 6.233541548181548e-09, "iteration_count": null, "func_evals": 4, "flag": 0, diff --git a/fitbenchmarking/utils/checkpoint.py b/fitbenchmarking/utils/checkpoint.py index 8f55843a2..486f3d777 100644 --- a/fitbenchmarking/utils/checkpoint.py +++ b/fitbenchmarking/utils/checkpoint.py @@ -104,7 +104,7 @@ def add_result(self, result: FittingResult): "accuracy": result.accuracy, "runtime": result.runtime, "runtimes": result.runtimes, - "emissions": result.emissions, + "energy": result.energy, "iteration_count": result.iteration_count, "func_evals": result.func_evals, "flag": result.error_flag, @@ -326,7 +326,7 @@ def load(self): new_result.accuracy = r["accuracy"] new_result.runtime = r["runtime"] new_result.runtimes = r["runtimes"] - new_result.emissions = r["emissions"] + new_result.energy = r["energy"] new_result.iteration_count = r["iteration_count"] new_result.func_evals = r["func_evals"] new_result.error_flag = r["flag"] diff --git a/fitbenchmarking/utils/fitbm_result.py b/fitbenchmarking/utils/fitbm_result.py index 8b5e98ec7..15042651b 100644 --- a/fitbenchmarking/utils/fitbm_result.py +++ b/fitbenchmarking/utils/fitbm_result.py @@ -31,7 +31,7 @@ def __init__( controller: Controller, accuracy: Union[float, list[float]] = np.inf, runtimes: Union[float, list[float]] = np.inf, - emissions: float = np.inf, + energy: float = np.inf, runtime_metric: Literal[ "mean", "minimum", "maximum", "first", "median", "harmonic", "trim" ] = "mean", @@ -46,8 +46,8 @@ def __init__( :type accuracy: Union[float, list[float]], optional :param runtimes: All runtimes of the fit, defaults to np.inf :type runtimes: Union[float, list[float]], optional - :param emissions: The average emissions for the fit, defaults to np.inf - :type emissions: float, optional + :param energy: The average energy usage for the fit, defaults to np.inf + :type energy: float, optional :param dataset: The index of the dataset (Only used for MultiFit), defaults to None :type dataset: int, optional @@ -85,7 +85,7 @@ def __init__( self.runtimes = runtimes if isinstance(runtimes, list) else [runtimes] self.runtime_metric = runtime_metric - self.emissions = emissions + self.energy = energy self.iteration_count = controller.iteration_count self.func_evals = controller.func_evals @@ -160,10 +160,10 @@ def init_blank(self): # Variable for calculating best result self._norm_acc = None self._norm_runtime = None - self._norm_emissions = None + self._norm_energy = None self.min_accuracy = np.inf self.min_runtime = np.inf - self.min_emissions = np.inf + self.min_energy = np.inf self.is_best_fit = False # Paths to various output files @@ -186,7 +186,7 @@ def __str__(self): "Runtime": self.runtime, "Runtime metric": self.runtime_metric, "Runtimes": self.runtimes, - "Emissions": self.emissions, + "Energy usage": self.energy, } return get_printable_table("FittingResult", info) @@ -408,29 +408,29 @@ def norm_runtime(self, value): self._norm_runtime = value @property - def norm_emissions(self): + def norm_energy(self): """ - Getting function for norm_emissions attribute + Getting function for norm_energy attribute - :return: normalised emissions value + :return: normalised energy value :rtype: float """ - if self._norm_emissions is None: - if self.min_emissions in [np.nan, np.inf]: - self._norm_emissions = np.inf + if self._norm_energy is None: + if self.min_energy in [np.nan, np.inf]: + self._norm_energy = np.inf else: - self._norm_emissions = self.emissions / self.min_emissions - return self._norm_emissions + self._norm_energy = self.energy / self.min_energy + return self._norm_energy - @norm_emissions.setter - def norm_emissions(self, value): + @norm_energy.setter + def norm_energy(self, value): """ - Stores the normalised emissions and updates the value + Stores the normalised energy and updates the value - :param value: New value for norm_emissions + :param value: New value for norm_energy :type value: float """ - self._norm_emissions = value + self._norm_energy = value @property def sanitised_name(self): diff --git a/fitbenchmarking/utils/options.py b/fitbenchmarking/utils/options.py index 021fe7162..1baabcfc2 100644 --- a/fitbenchmarking/utils/options.py +++ b/fitbenchmarking/utils/options.py @@ -281,7 +281,13 @@ class Options: "make_plots": [True, False], "pbar": [True, False], "comparison_mode": ["abs", "rel", "both"], - "table_type": ["acc", "runtime", "compare", "local_min", "emissions"], + "table_type": [ + "acc", + "runtime", + "compare", + "local_min", + "energy_usage", + ], "results_browser": [True, False], "run_dash": [True, False], "colour_map": plt.colormaps(), @@ -460,7 +466,13 @@ class Options: "comparison_mode": "both", "results_browser": True, "run_dash": True, - "table_type": ["acc", "runtime", "compare", "local_min", "emissions"], + "table_type": [ + "acc", + "runtime", + "compare", + "local_min", + "energy_usage", + ], "run_name": "", "checkpoint_filename": "checkpoint.json", } diff --git a/fitbenchmarking/utils/tests/test_fitbm_result.py b/fitbenchmarking/utils/tests/test_fitbm_result.py index 5bde5f70a..c89b44a4a 100644 --- a/fitbenchmarking/utils/tests/test_fitbm_result.py +++ b/fitbenchmarking/utils/tests/test_fitbm_result.py @@ -66,12 +66,12 @@ def setUp(self): self.accuracy = 10 self.runtime = 0.01 self.runtimes = [0.005, 0.015, 0.01] - self.emissions = 0.001 + self.energy = 0.001 self.result = FittingResult( controller=controller, accuracy=self.accuracy, runtimes=self.runtimes, - emissions=self.emissions, + energy=self.energy, ) self.min_accuracy = 0.1 @@ -107,7 +107,7 @@ def test_fitting_result_str(self): +---------------------------------------+ | Runtimes | [0.005, 0.015, 0.01] | +---------------------------------------+ - | Emissions | 0.001 | + | Energy usage | 0.001 | +---------------------------------------+""") for i, (r, e) in enumerate( diff --git a/fitbenchmarking/utils/tests/test_options_output.py b/fitbenchmarking/utils/tests/test_options_output.py index cb8cd90e4..79510631e 100644 --- a/fitbenchmarking/utils/tests/test_options_output.py +++ b/fitbenchmarking/utils/tests/test_options_output.py @@ -76,7 +76,7 @@ def test_table_type_default(self): """ Checks table_type default """ - expected = ["acc", "runtime", "compare", "local_min", "emissions"] + expected = ["acc", "runtime", "compare", "local_min", "energy_usage"] actual = self.options.table_type self.assertEqual(expected, actual)