diff --git a/Reports/Thesis/sections/appendix.aux b/Reports/Thesis/sections/appendix.aux index 0b25e25..379bb9e 100644 --- a/Reports/Thesis/sections/appendix.aux +++ b/Reports/Thesis/sections/appendix.aux @@ -1,12 +1,12 @@ \relax \providecommand\hyper@newdestlabel[2]{} -\@writefile{toc}{\contentsline {section}{\numberline {A}Appendix}{57}{appendix.A}\protected@file@percent } -\@writefile{lof}{\contentsline {figure}{\numberline {21}{\ignorespaces Comparison of the autoregressive models with the diffusion model\relax }}{57}{figure.caption.35}\protected@file@percent } -\newlabel{fig:ar_linear_gru_comparison}{{21}{57}{Comparison of the autoregressive models with the diffusion model\relax }{figure.caption.35}{}} -\@writefile{lof}{\contentsline {figure}{\numberline {22}{\ignorespaces Comparison of the non-autoregressive models with the diffusion model\relax }}{58}{figure.caption.36}\protected@file@percent } -\newlabel{fig:ar_linear_gru_comparison}{{22}{58}{Comparison of the non-autoregressive models with the diffusion model\relax }{figure.caption.36}{}} +\@writefile{toc}{\contentsline {section}{\numberline {A}Appendix}{56}{appendix.A}\protected@file@percent } +\@writefile{lof}{\contentsline {figure}{\numberline {21}{\ignorespaces Comparison of the autoregressive models with the diffusion model\relax }}{56}{figure.caption.35}\protected@file@percent } +\newlabel{fig:ar_linear_gru_comparison}{{21}{56}{Comparison of the autoregressive models with the diffusion model\relax }{figure.caption.35}{}} +\@writefile{lof}{\contentsline {figure}{\numberline {22}{\ignorespaces Comparison of the non-autoregressive models with the diffusion model\relax }}{57}{figure.caption.36}\protected@file@percent } +\newlabel{fig:ar_linear_gru_comparison}{{22}{57}{Comparison of the non-autoregressive models with the diffusion model\relax }{figure.caption.36}{}} \@setckpt{sections/appendix}{ -\setcounter{page}{59} +\setcounter{page}{58} \setcounter{equation}{8} \setcounter{enumi}{0} \setcounter{enumii}{0} diff --git a/Reports/Thesis/sections/results/policies/nrv_samples_policy.tex b/Reports/Thesis/sections/results/policies/nrv_samples_policy.tex index a7db533..8e73c9b 100644 --- a/Reports/Thesis/sections/results/policies/nrv_samples_policy.tex +++ b/Reports/Thesis/sections/results/policies/nrv_samples_policy.tex @@ -130,11 +130,9 @@ A comparison of the baselines and the best-performing models is shown in Table \ \bottomrule \end{tabular} \end{adjustbox} - \caption{Comparison of the different models using the CRPS, profit, charge cycles and penalty. The best-performing models for a certain type are selected based on the profit.} + \caption{Comparison of the profit achieved by the baselines and the best-performing models. The improvement is calculated compared to the baseline that uses the NRV of yesterday as a prediction.} \label{tab:policy_comparison} \end{table} -\newpage - \section{Conclusion} In this thesis, generative methods are explored to model the NRV data of the Belgian electricity market. These methods are then used to improve the decision-making to charge and discharge a battery to make a profit. diff --git a/Reports/Thesis/verslag.aux b/Reports/Thesis/verslag.aux index af2dc78..cccef2f 100644 --- a/Reports/Thesis/verslag.aux +++ b/Reports/Thesis/verslag.aux @@ -113,9 +113,9 @@ \newlabel{tab:diffusion_policy_comparison}{{13}{49}{Comparison of diffusion models using different hyperparameters. Early stopping is done based on the profit using the validation set.\relax }{table.caption.32}{}} \@writefile{lof}{\contentsline {figure}{\numberline {20}{\ignorespaces Comparison of the two samples from the model with the lowest CRPS and the model with the highest profit. \relax }}{50}{figure.caption.33}\protected@file@percent } \newlabel{fig:diffusion_policy_comparison_high_low_crps}{{20}{50}{Comparison of the two samples from the model with the lowest CRPS and the model with the highest profit. \relax }{figure.caption.33}{}} -\@writefile{lot}{\contentsline {table}{\numberline {14}{\ignorespaces Comparison of the different models using the CRPS, profit, charge cycles and penalty. The best-performing models for a certain type are selected based on the profit.\relax }}{51}{table.caption.34}\protected@file@percent } -\newlabel{tab:policy_comparison}{{14}{51}{Comparison of the different models using the CRPS, profit, charge cycles and penalty. The best-performing models for a certain type are selected based on the profit.\relax }{table.caption.34}{}} -\@writefile{toc}{\contentsline {section}{\numberline {7}Conclusion}{52}{section.7}\protected@file@percent } +\@writefile{lot}{\contentsline {table}{\numberline {14}{\ignorespaces Comparison of the profit achieved by the baselines and the best-performing models. The improvement is calculated compared to the baseline that uses the NRV of yesterday as a prediction.\relax }}{51}{table.caption.34}\protected@file@percent } +\newlabel{tab:policy_comparison}{{14}{51}{Comparison of the profit achieved by the baselines and the best-performing models. The improvement is calculated compared to the baseline that uses the NRV of yesterday as a prediction.\relax }{table.caption.34}{}} +\@writefile{toc}{\contentsline {section}{\numberline {7}Conclusion}{51}{section.7}\protected@file@percent } \bibstyle{unsrtnat} \bibdata{references} \bibcite{commission_for_electricity_and_gas_regulation_creg_study_2023}{{1}{}{{Commission for Electricity and Gas Regulation (CREG)}}{{}}} @@ -189,4 +189,4 @@ \ACRO{pages}{MSE=={44@1@43|45@1@44}} \ACRO{pages}{MAE=={44@1@43|45@1@44}} \ACRO{pages}{NRV=={3@1@2|4@1@3|47@1@46|48@1@47}} -\gdef \@abspage@last{59} +\gdef \@abspage@last{58} diff --git a/Reports/Thesis/verslag.log b/Reports/Thesis/verslag.log index 73608e7..c92e2f3 100644 --- a/Reports/Thesis/verslag.log +++ b/Reports/Thesis/verslag.log @@ -1,4 +1,4 @@ -This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex 2023.9.17) 19 MAY 2024 23:59 +This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex 2023.9.17) 20 MAY 2024 00:35 entering extended mode restricted \write18 enabled. file:line:error style messages enabled. @@ -1571,7 +1571,7 @@ File: images/diffusion/policies/comparison/Testing_7008_High_CRPS.jpeg Graphic f Package pdftex.def Info: images/diffusion/policies/comparison/Testing_7008_High_CRPS.jpeg used on input line 99. (pdftex.def) Requested size: 223.07211pt x 111.11894pt. - [49] [50 <./images/diffusion/policies/comparison/Testing_864_Low_CRPS.jpeg> <./images/diffusion/policies/comparison/Testing_864_High_CRPS.jpeg> <./images/diffusion/policies/comparison/Testing_7008_Low_CRPS.jpeg> <./images/diffusion/policies/comparison/Testing_7008_High_CRPS.jpeg>] [51])) [52] [53] (./verslag.bbl + [49] [50 <./images/diffusion/policies/comparison/Testing_864_Low_CRPS.jpeg> <./images/diffusion/policies/comparison/Testing_864_High_CRPS.jpeg> <./images/diffusion/policies/comparison/Testing_7008_Low_CRPS.jpeg> <./images/diffusion/policies/comparison/Testing_7008_High_CRPS.jpeg>])) [51] [52] (./verslag.bbl LaTeX Font Info: Trying to load font information for T1+LinuxLibertineMonoT-TLF on input line 11. (/usr/local/texlive/2023/texmf-dist/tex/latex/libertine/T1LinuxLibertineMonoT-TLF.fd File: T1LinuxLibertineMonoT-TLF.fd 2019/05/20 (autoinst) Font definitions for T1/LinuxLibertineMonoT-TLF. @@ -1640,7 +1640,7 @@ Underfull \hbox (badness 1635) in paragraph at lines 49--53 | [] | [] | []\T1/LinuxLibertineT-TLF/m/n/12 , vol-ume 37 of | [] | [] | [] | [] | [], [] -[54{/usr/local/texlive/2023/texmf-dist/fonts/enc/dvips/libertine/lbtn_dhi6qf.enc}] +[53{/usr/local/texlive/2023/texmf-dist/fonts/enc/dvips/libertine/lbtn_dhi6qf.enc}] Underfull \hbox (badness 1430) in paragraph at lines 74--80 \T1/LinuxLibertineT-TLF/m/n/12 and es-ti-ma-tion. 102(477):359--378. ISSN 0162-1459, 1537-274X. doi: $10 . 1198 / [] @@ -1650,7 +1650,7 @@ Underfull \hbox (badness 2134) in paragraph at lines 123--129 \T1/LinuxLibertineT-TLF/m/n/12 117871$. URL [][]$\T1/LinuxLibertineMonoT-TLF/regular/n/12 https : / / linkinghub . elsevier . com / retrieve / pii / [] -[55] +[54] Underfull \hbox (badness 10000) in paragraph at lines 152--154 \T1/LinuxLibertineMonoT-TLF/regular/n/12 elia . be / explore / dataset / ods047 / information / ?sort = [] @@ -1685,7 +1685,7 @@ Underfull \hbox (badness 10000) in paragraph at lines 168--170 \T1/LinuxLibertineMonoT-TLF/regular/n/12 elia . be / explore / dataset / ods022 / information / ?sort = [] -) [56] +) [55] \openout2 = `sections/appendix.aux'. (./sections/appendix.tex @@ -1817,10 +1817,10 @@ File: images/diffusion/results/samples/Diffusion_Test_Example_7008.jpeg Graphic Package pdftex.def Info: images/diffusion/results/samples/Diffusion_Test_Example_7008.jpeg used on input line 154. (pdftex.def) Requested size: 172.99498pt x 86.16971pt. - [57 + [56 -] [58]) (./verslag.aux (./sections/introduction.aux) (./sections/background.aux) (./sections/policies.aux) (./sections/literature_study.aux) (./sections/appendix.aux)) +] [57]) (./verslag.aux (./sections/introduction.aux) (./sections/background.aux) (./sections/policies.aux) (./sections/literature_study.aux) (./sections/appendix.aux)) LaTeX Warning: There were undefined references. @@ -1831,18 +1831,18 @@ Package rerunfilecheck Info: File `verslag.out' has not changed. (rerunfilecheck) Checksum: 78A3B45A8B1D632CBDB591FF4FE72E7D;5101. ) Here is how much of TeX's memory you used: - 35786 strings out of 476025 - 784747 string characters out of 5790017 + 35785 strings out of 476025 + 784740 string characters out of 5790017 1883388 words of memory out of 5000000 55362 multiletter control sequences out of 15000+600000 613012 words of font info for 120 fonts, out of 8000000 for 9000 1141 hyphenation exceptions out of 8191 84i,16n,131p,1821b,765s stack positions out of 10000i,1000n,20000p,200000b,200000s -Output written on verslag.pdf (59 pages, 9101254 bytes). +Output written on verslag.pdf (58 pages, 9101037 bytes). PDF statistics: - 857 PDF objects out of 1000 (max. 8388607) - 662 compressed objects within 7 object streams - 168 named destinations out of 1000 (max. 500000) + 853 PDF objects out of 1000 (max. 8388607) + 659 compressed objects within 7 object streams + 167 named destinations out of 1000 (max. 500000) 605 words of extra memory for PDF output out of 10000 (max. 10000000) diff --git a/Reports/Thesis/verslag.pdf b/Reports/Thesis/verslag.pdf index 70a16dc..8318c52 100644 Binary files a/Reports/Thesis/verslag.pdf and b/Reports/Thesis/verslag.pdf differ diff --git a/Reports/Thesis/verslag.synctex(busy) b/Reports/Thesis/verslag.synctex(busy) deleted file mode 100644 index e69de29..0000000 diff --git a/Reports/Thesis/verslag.toc b/Reports/Thesis/verslag.toc index 6ed818b..3052dcb 100644 --- a/Reports/Thesis/verslag.toc +++ b/Reports/Thesis/verslag.toc @@ -32,5 +32,5 @@ \contentsline {subsection}{\numberline {6.5}Policies for battery optimization}{46}{subsection.6.5}% \contentsline {subsubsection}{\numberline {6.5.1}Baselines}{46}{subsubsection.6.5.1}% \contentsline {subsubsection}{\numberline {6.5.2}Policy using generated NRV samples}{47}{subsubsection.6.5.2}% -\contentsline {section}{\numberline {7}Conclusion}{52}{section.7}% -\contentsline {section}{\numberline {A}Appendix}{57}{appendix.A}% +\contentsline {section}{\numberline {7}Conclusion}{51}{section.7}% +\contentsline {section}{\numberline {A}Appendix}{56}{appendix.A}% diff --git a/src/trainers/quantile_trainer.py b/src/trainers/quantile_trainer.py index 50a9110..1caa32f 100644 --- a/src/trainers/quantile_trainer.py +++ b/src/trainers/quantile_trainer.py @@ -637,6 +637,15 @@ class NonAutoRegressiveQuantileRegression(Trainer): task.get_logger().report_single_value( name=metric_name, value=metric_value ) + + if train == False: + crps_from_samples_metric, self.test_set_samples = ( + self.calculate_crps_from_samples(None, dataloader, None) + ) + task.get_logger().report_single_value( + name="test_CRPS_from_samples_transformed", + value=np.mean(crps_from_samples_metric), + ) def debug_plots(self, task, train: bool, data_loader, sample_indices, epoch): for actual_idx, idx in sample_indices.items(): @@ -846,6 +855,7 @@ class NonAutoRegressiveQuantileRegression(Trainer): targets = targets.squeeze(-1) targets = targets[0].unsqueeze(0) targets = self.data_processor.inverse_transform(targets) + targets = targets.to(self.device) samples = samples.to(self.device) @@ -871,8 +881,8 @@ class NonAutoRegressiveQuantileRegression(Trainer): initial_penalty=900, target_charge_cycles=58 * 400 / 356, initial_learning_rate=5, - max_iterations=100, - tolerance=1, + max_iterations=30, + tolerance=2, iteration=epoch, ) ) @@ -907,6 +917,8 @@ class NonAutoRegressiveQuantileRegression(Trainer): generated_samples, ) + return np.mean(crps_from_samples_metric), generated_samples + def plot_quantile_percentages( self, task, diff --git a/src/training_scripts/autoregressive_quantiles.py b/src/training_scripts/autoregressive_quantiles.py index 5a31e04..5648aa6 100644 --- a/src/training_scripts/autoregressive_quantiles.py +++ b/src/training_scripts/autoregressive_quantiles.py @@ -44,7 +44,7 @@ data_config.NOMINAL_NET_POSITION = True data_config = task.connect(data_config, name="data_features") -data_processor = DataProcessor(data_config, path="", lstm=True) +data_processor = DataProcessor(data_config, path="", lstm=False) data_processor.set_batch_size(512) data_processor.set_full_day_skip(False) diff --git a/src/training_scripts/non_autoregressive_quantiles.py b/src/training_scripts/non_autoregressive_quantiles.py index bcb3014..2656d30 100644 --- a/src/training_scripts/non_autoregressive_quantiles.py +++ b/src/training_scripts/non_autoregressive_quantiles.py @@ -2,10 +2,10 @@ from src.utils.clearml import ClearMLHelper #### ClearML #### clearml_helper = ClearMLHelper( - project_name="Thesis/NAQR: Non Linear (4 - 256) + Load + PV + Wind + NP" + project_name="Thesis/NrvForecast" ) task = clearml_helper.get_task( - task_name="NAQR: Non Linear (4 - 256) + Load + PV + Wind + NP" + task_name="NAQR: Non Linear (2 - 512)" ) task.execute_remotely(queue_name="default", exit_process=True) @@ -30,17 +30,17 @@ from src.models.time_embedding_layer import TimeEmbedding #### Data Processor #### data_config = DataConfig() -data_config.NRV_HISTORY = True -data_config.LOAD_HISTORY = True -data_config.LOAD_FORECAST = True +data_config.NRV_HISTORY = False +data_config.LOAD_HISTORY = False +data_config.LOAD_FORECAST = False -data_config.WIND_FORECAST = True -data_config.WIND_HISTORY = True +data_config.WIND_FORECAST = False +data_config.WIND_HISTORY = False -data_config.PV_FORECAST = True -data_config.PV_HISTORY = True +data_config.PV_FORECAST = False +data_config.PV_HISTORY = False -data_config.NOMINAL_NET_POSITION = True +data_config.NOMINAL_NET_POSITION = False data_config = task.connect(data_config, name="data_features") @@ -53,7 +53,7 @@ data_processor.set_full_day_skip(True) #### Hyperparameters #### data_processor.set_output_size(96) inputDim = data_processor.get_input_size() -epochs = 300 +epochs = 5 # add parameters to clearml quantiles = task.get_parameter("general/quantiles", cast=True) @@ -69,7 +69,7 @@ else: model_parameters = { "learning_rate": 0.0001, "hidden_size": 512, - "num_layers": 8, + "num_layers": 2, "dropout": 0.2, } @@ -111,15 +111,15 @@ trainer = NonAutoRegressiveQuantileRegression( data_processor, quantiles, "cuda", - policy_evaluator=None, + policy_evaluator=policy_evaluator, debug=False, ) trainer.add_metrics_to_track( [PinballLoss(quantiles), MSELoss(), L1Loss(), CRPSLoss(quantiles)] ) -trainer.early_stopping(patience=5) -trainer.plot_every(20) +trainer.early_stopping(patience=8) +trainer.plot_every(4) trainer.train(task=task, epochs=epochs, remotely=True) ### Policy Evaluation ### @@ -138,7 +138,7 @@ optimal_penalty, profit, charge_cycles = ( test_loader=test_loader, initial_penalty=1000, target_charge_cycles=283, - learning_rate=15, + initial_learning_rate=15, max_iterations=150, tolerance=1, )