This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
generated from latextemplates/scientific-thesis-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main-english.tex
1679 lines (1281 loc) · 112 KB
/
main-english.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% !TeX spellcheck = en-US
% !TeX encoding = utf8
% !TeX program = pdflatex
% !BIB program = biber
% -*- coding:utf-8 mod:LaTeX -*-
% !TEX root = ./main-english.tex
% vv scroll down to line 200 for content vv
\let\ifdeutsch\iffalse
\let\ifenglisch\iftrue
\input{pre-documentclass}
\documentclass[
% fontsize=11pt is the standard
a4paper, % Standard format - only KOMAScript uses paper=a4 - https://tex.stackexchange.com/a/61044/9075
twoside, % we are optimizing for both screen and two-side printing. So the page numbers will jump, but the content is configured to stay in the middle (by using the geometry package)
bibliography=totoc,
% idxtotoc, %Index ins Inhaltsverzeichnis
% liststotoc, %List of X ins Inhaltsverzeichnis, mit liststotocnumbered werden die Abbildungsverzeichnisse nummeriert
headsepline,
cleardoublepage=empty,
parskip=half,
% draft % um zu sehen, wo noch nachgebessert werden muss - wichtig, da Bindungskorrektur mit drin
draft=false
]{scrbook}
\input{config}
\usepackage[
title={Implementing Variational Quantum Algorithms as Compositions of Reusable Microservice-based Plugins},
author={Matthias Weilinger},
type=master,
institute=iaas, % or other institute names - or just a plain string using {Demo\\Demo...}
course={Informatik},
examiner={Prof.\ Dr.\ Dr.\ h.\ c.\ Frank Leymann},
supervisor={M.Sc.\ Philipp Wundrack,\\M.Sc.\ Fabian Bühler},
startdate={April 19, 2023},
enddate={October 19, 2023}
]{scientific-thesis-cover}
\usepackage{ifoddpage}
\input{acronyms}
\makeindex
\begin{document}
%tex4ht-Konvertierung verschönern
\iftex4ht
\Configure{$}{\PicMath}{\EndPicMath}{}
\Css{body {text-align:justify;}}
%conversion of .pdf to .png
\Configure{graphics*}
{pdf}
{\Needs{"convert \csname Gin@base\endcsname.pdf
\csname Gin@base\endcsname.png"}%
\Picture[pict]{\csname Gin@base\endcsname.png}%
}
\fi
%\VerbatimFootnotes %verbatim text in Fußnoten erlauben. Geht normalerweise nicht.
\input{commands}
\pagenumbering{arabic}
\Titelblatt
%Eigener Seitenstil fuer die Kurzfassung und das Inhaltsverzeichnis
\deftriplepagestyle{preamble}{}{}{}{}{}{\pagemark}
%Doku zu deftriplepagestyle: scrguide.pdf
\pagestyle{preamble}
\renewcommand*{\chapterpagestyle}{preamble}
%Kurzfassung / abstract
%auch im Stil vom Inhaltsverzeichnis
\section*{Abstract}
With its transformative processing capabilities, Quantum computing has ushered in a new computational era, presenting unparalleled opportunities and intricate challenges.
One potential beneficiary of this quantum revolution is the Digital Humanities. With quantum computing, the field has the potential to enhance its quantitative analysis dramatically.
QHAna, the Quantum Humanities Analysis tool explicitly designed for Quantum Digital Humanities, emerges as a pivotal system.
This thesis focuses on enhancing QHAna by integrating variational algorithms and paving the way for Variational Quantum Algorithms in a modular manner.
The objective is to encapsulate components of variational algorithms as distinct, interchangeable plugins, ensuring adaptability and enabling end users to adapt the algorithms.
Addressing challenges like robust plugin communication and intuitive user experience, the research delves into this modular framework's design, implementation, and evaluation.
Beyond the immediate application to Variational Quantum Algorithms, the insights and methodologies derived here lay the foundational groundwork for future modular system designs in the quantum computing domain.
% \section*{Kurzfassung}
% Quantum computing, mit ihren transformativen Verarbeitungsfähigkeiten, hat eine neue Ära der Berechnung eingeläutet und bietet sowohl noch nie dagewesene Chancen als auch komplexe Herausforderungen.
% Ein bedeutender Profiteur dieser Quantenrevolution ist die \gls{dh}, die durch digitale Werkzeuge ihrer traditionell qualitativen Domäne eine quantitative Dimension hinzugefügt hat.
% \gls{qhana}, speziell für \gls{qdh} entwickelt, tritt in diesem Kontext als ein zentrales System hervor.
% Diese Arbeit konzentriert sich auf die Verbesserung von \gls{qhana} durch die Integration von variationalen Algorithmen, insbesondere \glspl{vqa}, auf modulare Weise.
% Das Ziel ist es, Komponenten von variationalen Algorithmen als eigenständige, austauschbare Plugins zu kapseln, um Anpassungsfähigkeit und Benutzerzentriertheit zu gewährleisten.
% Die Forschung geht auf Herausforderungen wie robuste Plugin-Kommunikation und intuitive Benutzererfahrung ein und vertieft das Design, die Implementierung und die Bewertung dieses modularen Frameworks.
% Jenseits von \gls{vqa} legen die Ergebnisse eine Grundlage für das modulare Systemdesign in \gls{qdh}.
\cleardoublepage
% BEGIN: Verzeichnisse
\iftex4ht
\else
\microtypesetup{protrusion=false}
\fi
%%%
% Literaturverzeichnis ins TOC mit aufnehmen, aber nur wenn nichts anderes mehr hilft!
% \addcontentsline{toc}{chapter}{Literaturverzeichnis}
%
% oder zB
%\addcontentsline{toc}{section}{Abkürzungsverzeichnis}
%
%%%
%Produce table of contents
%
%In case you have trouble with headings reaching into the page numbers, enable the following three lines.
%Hint by http://golatex.de/inhaltsverzeichnis-schreibt-ueber-rand-t3106.html
%
%\makeatletter
%\renewcommand{\@pnumwidth}{2em}
%\makeatother
%
\tableofcontents
% Bei einem ungünstigen Seitenumbruch im Inhaltsverzeichnis, kann dieser mit
% \addtocontents{toc}{\protect\newpage}
% an der passenden Stelle im Fließtext erzwungen werden.
\listoffigures
\listoftables
%Wird nur bei Verwendung von der lstlisting-Umgebung mit dem "caption"-Parameter benoetigt
\lstlistoflistings
%ansonsten:
% \listof{Listing}{List of Listings}
%mittels \newfloat wurde die Algorithmus-Gleitumgebung definiert.
%Mit folgendem Befehl werden alle floats dieses Typs ausgegeben
% \listof{Algorithmus}{List of Algorithms}
%\listofalgorithms %Ist nur für Algorithmen, die mittels \begin{algorithm} umschlossen werden, nötig
% Abkürzungsverzeichnis
\printnoidxglossaries
\iftex4ht
\else
%Optischen Randausgleich und Grauwertkorrektur wieder aktivieren
\microtypesetup{protrusion=true}
\fi
% END: Verzeichnisse
% Headline and footline
\renewcommand*{\chapterpagestyle}{scrplain}
\pagestyle{scrheadings}
\pagestyle{scrheadings}
\ihead[]{}
\chead[]{}
\ohead[]{\headmark}
\cfoot[]{}
\ofoot[\usekomafont{pagenumber}\thepage]{\usekomafont{pagenumber}\thepage}
\ifoot[]{}
%% vv scroll down for content vv %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Main content starts here
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Introduction}
\label{chap:introduction}
The dawn of quantum computing has revolutionized the landscape of computational research.
With its unparalleled processing capabilities and the potential to solve problems deemed impractical for classical computers, quantum computing heralds a new era of possibilities \cite{Shor}.
However, with these possibilities come challenges that demand innovative solutions, particularly in harnessing the power of quantum algorithms for diverse applications.
One domain that stands to benefit immensely from quantum computing is the \gls{dh}.
Traditionally, the humanities have been viewed through a lens of qualitative analysis.
However, with the advent of digital tools and methodologies, a quantitative dimension has emerged, enabling researchers to analyze vast datasets, uncover patterns, and derive insights that were previously unavailable \cite{Barzen2019}.
With its inherent strengths, Quantum computing offers the potential to elevate the \glspl{dh} to new heights, enabling analyses of unprecedented complexity and depth \cite{Barzen2022}.
Enter \gls{qhana} \cite{Buehler2022}.
Initially conceived and meticulously crafted for \gls{qdh}, its applicability has evolved, proving valuable not just for \glspl{dh} but for broader quantum computing applications.
The foundational architecture of the system is both robust and adaptable.
A logical extension of this framework is the integration of variational algorithms, particularly \glspl{vqa}, in a modular fashion.
The objective is to encapsulate components of variational algorithms as modular and interchangeable plugins within \gls{qhana}.
Such a modular approach promises enhanced adaptability towards a user-centric platform where researchers can precisely tailor their quantum optimization strategies to their needs.
However, the path to realizing this vision is full of challenges.
As plugins are essentially microservices, \gls{qhana} is a distributed system that brings its own challenges.
Integrating optimization as multiple plugins demands a robust communication mechanism, ensuring seamless interaction and data sharing.
Furthermore, the user experience must remain intuitive, allowing both quantum novices and experts to harness the full potential of the modular quantum optimization framework.
This work embarks on a journey to navigate those challenges. It aims to design and implement a modular framework within \gls{qhana}, delving into the intricacies of the unique plugin-based architecture of \gls{qhana}, the nuances of quantum optimization algorithms, and the challenges of ensuring seamless interaction between distinct components.
Moreover, the implications of this research extend beyond the limits of \gls{vqa} in \gls{qhana}.
By pioneering a methodology for \gls{vqa} plugin interactions within \gls{qhana}, this work lays the foundation for a broader paradigm of modular system design in the \gls{qdh}.
The thesis undertakes a comprehensive journey through modular \glspl{vqa} within \gls{qhana}.
Chapter \ref{chap:background} lays the groundwork by delving into the foundational principles and concepts that underpin the entire thesis.
Chapter \ref{chap:problem} sharpens the focus, presenting a clear and concise problem statement and outlining the objectives aimed to be achieved.
With a clear understanding of the problem at hand, Chapter \ref{chap:methodology} dives deep into the methodology.
The chapter explores the strategies and approaches employed to develop and evaluate the modular framework within \gls{qhana}.
Chapter \ref{chap:architecture} unveils the architectural blueprint of the modular framework.
Moving from design to implementation, Chapter \ref{chap:implementation} delves into the details of the framework's implementation.
In Chapter \ref{chap:results}, the design and implementation are put to the test. The architectural design's efficacy and real-world implementation are measured through rigorous evaluations, drawing insights from the results.
Chapter \ref{chap:discussion} delves into a thorough analysis of the findings and checks if set problems are adequately solved.
To place the work in a broader context, Chapter \ref{chap:relatedWork} explores the landscape of related research.
Finally, Chapter \ref{chap:conclusion} brings the journey to an end, summarizing the resulting framework and looking ahead to future possibilities and roads for further extension.
\chapter{Background}
\label{chap:background}
The study of \gls{qhana} and its advanced plugin interactions is rooted in foundational principles underpinning its functionality.
This chapter aims to offer a comprehensive introduction to these principles, encompassing key areas such as optimization algorithms, quantum computing, \glspl{vqa}, \gls{rest}, and the core architecture of \gls{qhana}.
By delving into these foundational topics, readers will gain the necessary context to understand the innovative approaches adopted in this thesis.
\section{QHana}
\label{sec:qhana}
\gls{qhana} was conceived as a specialized application in the domain of \gls{dh} and has since evolved into a versatile platform for quantum computing applications.
Its primary design allows users to explore various machine-learning algorithms on designated datasets.
While the primary vision of \gls{qhana} is to assess the potential advantages of quantum algorithms within the \gls{dh} community, the rise and cloud availability of quantum computers \cite{Castelvecchi2017} further underscore its relevance and timeliness.
\gls{qhana} is designed to be extensible, allowing the integration of new data sources and quantum algorithms as plugins.
Usually, plugins are built for specific applications, limiting their reusability in other contexts.
Moreover, an application's plugins must be developed in the same programming phrasing as the application.
Even if another application can reuse a plugin, a developer has to adapt the plugin's \gls{ui} to the new application.
Otherwise, users may need help understanding the plugin's functionality.
To address this limitation, \gls{qhana} is built on a novel concept of \glspl{ramp} \cite{Buehler2022}.
This concept allows microservices with an integrated \gls{ui} to be used as plugins by multiple applications, enhancing the reusability of the plugins across different applications.
\subsection{QHAna's Architecture}
\label{subsec:qhanaArchitecture}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{graphics/qhanaarch.png}
\caption{\gls{qhana}'s Architecture as depicted in \cite{Buehler2022}}
\label{fig:qhanaarch}
\end{figure}
QHAna's architecture, as depicted in Figure \ref{fig:qhanaarch}, is primarily microservice-oriented, emphasizing modularity and extensibility, which is evident from its use of \glspl{ramp} and the concept of \emph{microfrontends}.
Such an architectural choice is geared towards ensuring scalability and adaptability in the rapidly evolving field of quantum computing.
Key components of \gls{qhana}'s architecture are:
\begin{description}
\item[QHAna UI] Developed using Angular and TypeScript, the \gls{ui} serves as the primary interface for users, facilitating interaction with the system's functionalities.
\item[QHAna Backend] The backend provides essential services, including a \gls{rest} API for the \gls{ui}, data management, and functions as a \emph{\glspl{ramp} Registry} to discover and load \glspl{ramp}.
\item[RAMPs] These plugins encapsulate specific classical and quantum algorithms. Their development is streamlined by the Plugin Runner, a Python framework designed to handle generic \gls{ramp} tasks.
\item[Database] This component is responsible for the persistent storage of data related to the experiments conducted within \gls{qhana}.
\end{description}
The \emph{\gls{qhana} \gls{ui}} offers users a selection of \glspl{ramp}.
When a \gls{ramp} is selected, its microfrontend is embedded within the \gls{ui} through an iframe.
The \emph{\gls{qhana} Backend}, central to the system, manages data storage, acts as a \gls{ramp} registry, and provides necessary services to the \gls{ui}.
\glspl{ramp}, designed for modularity, can be developed independently and integrated into \gls{qhana}.
The \emph{Plugin Runner} demands the adherence of \glspl{ramp} to system standards.
Data from external sources is processed by \glspl{ramp} and stored in the database.
\subsection{RAMPs: Bridging UI and Data Processing}
\label{subsec:ramps}
\glspl{ramp} are designed to bridge the gap between traditional plugins and microservices.
They offer a comprehensive approach to user interaction and data processing, distinguishing themselves from conventional plugins.
One of the primary advantages of \glspl{ramp} is their ability to integrate seamlessly with \glspl{ui}.
Unlike traditional plugins, which might require modifications to fit an application's \gls{ui}, \glspl{ramp} come with context-sensitive microfrontends.
This ensures that the plugin's \gls{ui} aligns effortlessly with the primary application's interface, enhancing user experience.
Furthermore, \glspl{ramp} introduce the possibility of multi-step \gls{ui} interactions, where users can be presented with sequential interfaces based on prior inputs or processing results, enhancing the depth and interactivity of the user experience.
In summary, \glspl{ramp} blend the best of microservices and plugins.
They combine the reusability and accessibility of microservices with the \gls{ui} adaptability of plugins, making them a valuable asset in diverse application settings.
\section{Quantum Computing}
\label{sec:quantumComputing}
Quantum computing is a cutting-edge field that exploits the principles of quantum mechanics to process information.
Unlike classical computers that use bits (0s and 1s) to store and process information, quantum computers use quantum bits, or \emph{qubits}.
Through superposition and entanglement, qubits can exist in multiple states simultaneously and correlate in ways that classical bits cannot \cite{Nielsen2010}.
Superposition allows a qubit to be in a state of a combination of 0 and 1, with a certain probability for each.
This property enables quantum computers to perform many calculations simultaneously, vastly increasing their potential computational power.
Entanglement allows qubits to be intimately linked regardless of the distance separating them.
A change in the state of one will instantaneously affect the state of the other, a phenomenon that Einstein famously called spooky action at a distance \cite{Einstein1935}.
This property is essential for many quantum algorithms, quantum error correction, and quantum teleportation, making it a fundamental resource in quantum information processing \cite{Nielsen2010, Preskill1998}.
\section{Variational Quantum Algorithms}
\label{sec:variationalQuantumAlgorithms}
\glspl{vqa} combine the principles of quantum computing and optimization uniquely and powerfully.
They are a class of hybrid quantum-classical algorithms that leverage the strengths of both quantum and classical computing to solve complex problems \cite{McClean2016}.
The central concept of \glspl{vqa} is to use a sequence of quantum operations (a \emph{quantum circuit}) controlled by specific parameters.
These parameters are adjusted using classical optimization techniques to solve a specific problem.
This problem, in many cases, involves finding the lowest energy state, or \emph{ground state}, of a quantum system.
This problem maps to finding the minimum of a particular function \cite{Peruzzo2013}.
By leveraging classical optimization algorithms, \glspl{vqa} become more resistant to quantum errors, as classical computers perform most of the computation.
This combination of quantum and classical resources makes \glspl{vqa} a promising algorithm for near-term quantum devices \cite{Moll2017}.
\section{Optimization Algorithms}
\label{sec:optimizationAlgorithms}
Optimization is a powerful tool ubiquitous in various scientific and technological domains.
At its core, optimization is about finding the best solution from a set of possible choices.
This section provides a snapshot of optimization's fundamental principles, paving the way for deeper exploration in the context of \glspl{vqa} and plugin-based \glspl{vqa}.
\subsection{Objective Functions}
\label{subsec:objectiveFunctions}
\glspl{of} are fundamental to optimization problems, underpinning many computational algorithms and models.
Depending on specific requirements, the aim might be to minimize or maximize these functions.
Notably, within the realm of \glspl{vqa}, the focus is primarily on function minimization \cite{Weinan2017}.
The core inputs to a \gls{of} typically encompass data points (denoted as $x$), corresponding labels or outcomes (represented by $y$), and a set of parameters or weights (often symbolized by $\theta$ or $w$).
These parameters dictate how the model responds to the input data and makes predictions.
Additionally, certain \glspl{of} may also include hyperparameters as input, which control the behavior and complexity of the model.
In the context of optimization problems, the role of an \gls{of} is to capture both the problem we are attempting to solve and the strategy by which we are trying to solve it.
It provides a measure of the 'goodness' or 'fitness' of our current solution or parameters, and the aim is to adjust these parameters to improve this measure.
One example of an \gls{of} is the Lasso (Least Absolute Shrinkage and Selection Operator) Loss function.
The Lasso loss function has the form:
\[
L(Y, X, W, \lambda) = ||Y - XW||^2_2 + \lambda ||W||_1
\]
In this equation:
\begin{itemize}
\item \(Y\) is the vector of observed values.
\item \(X\) is the matrix of input data points.
\item \(W\) is the vector of weights, the model's parameters.
\item \(\lambda\) is the regularization parameter, a non-negative hyperparameter.
\end{itemize}
This function consists of two terms:
\begin{enumerate}
\item The first term \(||Y - XW||^2_2\) is the mean squared error between the predicted and actual outcomes.
It measures the discrepancy between the model's predictions and the true values.
\item The second term \(\lambda ||W||_1\) is a regularization term, where \(||W||_1\) represents the L1 norm (sum of absolute values) of the weight vector.
This term penalizes the absolute size of the coefficients, encouraging them to be small.
\end{enumerate}
The hyperparameter \(\lambda\) governs the trade-off between these two terms.
When \(\lambda = 0\), the \gls{of} reduces to ordinary least squares regression, and the weights are chosen to minimize the mean squared error alone.
As \(\lambda\) increases, more weight is given to the regularization term, and the solution becomes more sparse (i.e., more weights are driven to zero).
Increasing the regularization term can help to prevent overfitting by effectively reducing the complexity of the model \cite{ShalevShwartz2014}
\subsection{Minimization Functions}
\label{subsec:minimizationFunctions}
Minimization functions, generally called optimization algorithms, are pivotal in many computational models and algorithms.
In essence, they serve to iteratively enhance the parameters of a model to reduce the value of the \gls{of}.
These minimization functions aim to find the optimal set of parameters that yield the lowest possible value of the \gls{of} within the constraints of the problem \cite{Nocedal2006}.
The process of optimization involves a search through the parameter space.
This search can be visualized as navigating a landscape of hills and valleys, with each point in the landscape corresponding to a different set of parameters and the height at each point representing the value of the \gls{of}.
The goal of the minimization function is to find the lowest point in this landscape, corresponding to the minimum value of the \gls{of} \cite{Goodfellow2017}.
The core inputs to a minimization function are the initial parameters of the model or weights (denoted as \(\theta\) or \(w\)),
the \gls{of} that needs to be minimized, and optionally, the gradient of the \gls{of}.
Additionally, certain minimization functions may include hyperparameters as input, which control the behavior and complexity of the optimization process \cite{Virtanen2020}.
For instance, the learning rate is a typical hyperparameter that determines the step size in each iteration of the optimization process.
One of the most fundamental and widely used minimization functions is the Gradient Descent.
To find a local minimum of a function using gradient descent, one takes steps proportional to the negative of the function's gradient (or approximate gradient) at the current point.
The update rule of gradient descent has the form:
\[
\theta_{t+1} = \theta_t - \alpha \nabla F(\theta_t)
\]
In this formula:
\begin{itemize}
\item \(\theta_{t+1}\) represents the parameters at the next time step.
\item \(\theta_t\) represents the current parameters.
\item \(\alpha\) is the learning rate, a positive scalar determining the step size.
\item \(\nabla F(\theta_t)\) is the gradient of the \gls{of}.
\end{itemize}
Here, the \gls{of} \(F\) is assumed to be a differentiable function.
The gradient \(\nabla F(\theta_t)\) provides the direction of the steepest ascent at the point \(\theta_t\), and \(-\nabla F(\theta_t)\) provides the direction of the steepest descent.
We move towards the minimum of the function by taking a step in this direction.
The choice of minimization function can significantly influence the efficiency and success of the optimization process.
While some minimization functions may perform well on certain problems, they may yield different results on others.
Therefore, it is crucial to understand the underlying mechanisms of these functions and their suitability to the specific problem at hand.
\chapter{Problem Statement and Objectives}
\label{chap:problem}
Optimization algorithms, with their ability to find the best possible solution from a set of feasible solutions, play a pivotal role in numerous computational domains.
\glspl{vqa} are a subset of these algorithms that leverage quantum computing principles, particularly in the realm of \glspl{of} and minimization techniques.
However, the true potential of optimization is often hindered by rigid platforms where the components of these algorithms are tightly integrated, limiting adaptability and innovation.
\gls{qhana}, with its unique environment tailored for experimenting with plenty of machine learning and quantum algorithms, presents an opportunity to redefine this paradigm.
However, its current architecture does not fully exploit the modular benefits that can be achieved by decoupling the components of optimization algorithms.
Furthermore, while developing this modular framework, allowing plugins to interact with each other is essential.
This interaction-centric concept, once established, can be universally applied across \gls{qhana}, not just for optimization but for any scenario where plugin interaction is required.
\textbf{Problem Statement:}
How can we design and implement a modular framework within \gls{qhana} that allows components of optimization algorithms, specifically \glspl{of} and minimization functions, to be implemented as distinct, interchangeable plugins?
Furthermore, how can these plugins be structured to communicate and collaborate seamlessly, especially in the context of \glspl{vqa}?
This problem encompasses several challenges:
\begin{itemize}
\item \textbf{Communication:} Establishing a robust communication mechanism that enables interaction, data sharing, and collaboration among these plugins.
\item \textbf{Interchangeability:} Designing a system where different \gls{of} and minimization plugins can be effortlessly swapped, ensuring adaptability in optimization and \glspl{vqa}.
Implementing a consistent interface for these plugins, ensuring uniformity and compatibility across various \gls{of} and minimization plugins.
The design should ensure that interchangeability accommodates future use cases beyond the optimization context.
\item \textbf{User Experience:} Providing an intuitive \gls{ui} for users to easily choose and experiment with different optimization components tailored to their needs.
\item \textbf{Developer Experience:} Providing developers with an extensible framework to build new minimization and \gls{of} plugins.
\end{itemize}
Addressing this problem is essential to enhance the capabilities of \gls{qhana}, transforming it into a dynamic, adaptable, and user-centric platform for experimenting with optimization and \glspl{vqa}.
When solving this problem, technical requirements and constraints must be considered.
\gls{qhana}, with its design centered on the Digital Humanities, provides an extensible platform for experimenting with various algorithms.
\gls{qhana}'s architecture predominantly revolves around the concept of \glspl{ramp} \cite{Buehler2022}.
The objective is to leverage \gls{qhana}'s inherent modularity by enabling components of optimization algorithms to function as distinct and interchangeable plugins.
This brings us to the significance of modularity in optimization.
When \glspl{vqa} are designed with modular components, it allows for increased flexibility.
Specifically, having distinct \glspl{of} and minimization functions means parts of the algorithm can be adjusted or replaced seamlessly.
This reflects the goals of modularity and flexibility intrinsic to \gls{qhana}'s design.
Interactivity in \gls{qhana} should encompass various facets.
No plugin should be aware of specific user input requirements of another plugin to enable interchangeability and loose coupling between plugins.
This means that an invoking plugin should not have input fields that are specific to the invoked plugin.
Therefore, a plugin should be able to invoke the microfrontend of another plugin where the user can provide the required input.
Control should revert to the invoking plugin once the invoked plugin completes its tasks.
Interactions between plugins can have varying degrees of complexity, so the interaction mechanism should be flexible enough to accommodate different scenarios.
Both short-running tasks and long-running tasks should be facilitated.
For the latter, a callback mechanism is proposed, wherein the invoking plugin is notified upon completion of a long-running task by the invoked plugin.
The need for such interactivity stems from the inherent nature of optimization.
The \glspl{of} and minimization must closely interact to produce meaningful optimization results.
Moreover, since an invoking plugin is unaware of the parameters or requirements of the invoked plugin, direct interaction becomes imperative for dynamic data exchange and collaborative processing.
Drawing inspiration from existing systems, the interaction between the minimization and \glspl{of} in implementations like SciPy's \emph{optimizer.minimize} \cite{Virtanen2020} function serves as a precedent.
This thesis introduces the concept of \emph{interaction endpoints} to \gls{qhana} to elevate the interactivity between plugins.
While \gls{qhana} already employs a metadata field for plugins known as \emph{entry points} -- endpoints invoked by the \gls{qhana} \gls{ui} to render the \gls{ui} of a plugin -- interaction endpoints extend this paradigm by marking specific endpoints as callable by other plugins.
A defining characteristic of an interaction endpoint is its \emph{type}.
Interaction endpoints sharing the same type uphold uniformity in their signature and return type.
This typing ensures that they are invoked consistently by other plugins, irrespective of their specific implementation.
Inspiration for this typing mechanism is drawn from the OpenAPI specification \cite{Miller}, which defines a standard, language-agnostic interface for \gls{rest} APIs.
The proposed approach complements \gls{qhana}'s existing principles, resonating with its emphasis on extensibility, adaptability, and user-centric design.
By enhancing the interactivity and modularity of plugins within \gls{qhana}, we strive to elevate its capabilities, making it a more dynamic platform for optimization and \glspl{vqa}.
The subsequent sections of this thesis will delve into the methods, implementations, and evaluations related to this problem.
\chapter{Methods}
\label{chap:methodology}
This section outlines the method developed in this work for enabling modular \glspl{vqa} consisting of multiple plugins.
The chapter begins by defining the architectural design strategy and explaining the process of decomposing the optimization process into distinct plugins that interact.
Next, the implementation strategy is defined, outlining the tools and technologies employed in the implementation process.
Finally, the evaluation strategy is delineated, explaining the approach to evaluate the efficacy of the proposed design and implementation.
\section{Architectural Design Strategy}
\label{sec:architecturalDesignStrategy}
The architectural design process is a critical phase that dictates how the solution's components will function and interact with each other.
The final architectural design will be chosen by iteratively refining the existing architecture over multiple steps, considering different aspects like clarity, modularity, and extensibility.
Before diving into the details of the design process, it was essential to understand the existing architecture of \gls{qhana}.
\paragraph{Decomposition into Plugins:}
The first step involves decomposing the optimization process into distinct plugins.
Decomposition is achieved by reviewing relevant literature to understand standard practices and methods in optimization \cite{Virtanen2020, Nocedal2006, ShalevShwartz2014, Weinan2017}.
The main challenge is to find a decomposition so that, on the one hand, any functionality that should be interchangeable is encapsulated in an extra plugin,
on the other hand, splitting the process into too many plugins would be inefficient due to the overhead of the required communication between plugins.
The main question is how to encapsulate the \gls{of} and the minimization function and their coordination.
In order to represent the decomposition, a UML component diagram is created.
\paragraph{Defining Plugin Responsibilities:}
Once the plugins are identified, the next step is to define the responsibilities of each plugin precisely.
This ensures that every plugin has a well-defined purpose, preventing overlaps in functionality and ensuring clarity in their roles.
Several crucial decisions delineate these responsibilities:
\begin{itemize}
\item Which one prompts the user for the \gls{of} hyperparameters?
\item Which one gathers the minimization function hyperparameters from the user?
\item Which one inquires about the user's preference for the \gls{of} and minimization algorithm?
\item Which one solicits the input data from the user?
\item Which one requests the target variable?
\end{itemize}
\paragraph{Universal Plugin Interface Design:}
Recognizing the vast possibilities and variations that interchangeable plugins might encompass, it is crucial to formulate a universally adhered-to interface.
This interface acts as a \emph{contract}, ensuring that a consistent mode of interaction exists irrespective of the specific implementation details of a plugin.
The notion of interface contracts in microservice architectures is not new and is inspired by the OpenAPI specification \cite{Miller}.
Core attributes and functionalities, like querying the number of initial weights for the minimization process required, are defined as part of this universal interface.
This approach fosters interchangeability and adaptability, as the defined interface could accommodate a multitude of interchangeable plugins, each with its unique implementations.
In terms of optimization, this could mean that in the case of an \gls{of} plugin responsible for calculating the loss function, interfaces must be generalized to allow for any thinkable type of loss function.
A UML component diagram visualizes the interfaces of each plugin and how they are connected.
\paragraph{Plugin Interaction Design:}
The next step is to design the interaction between plugins.
This design process involved defining the various ways in which plugins could interact with each other.
It is crucial to build a robust and flexible interaction design to accommodate many scenarios since the interaction between plugins in \gls{qhana} should apply not only to optimization.
This interaction design should lay the foundation for all future multi-plugin interactions within \gls{qhana}.
Scenarios include, for instance, a plugin invoking the microfrontend of another plugin, or it could call a specific endpoint of another plugin.
Additionally, the interaction design also encompasses the flow of control between plugins.
A plugin should be able to invoke another plugin and then stop execution for as long as the invoked plugin is running.
Alternatively, a plugin should be able to invoke another plugin and then continue with its tasks without waiting for the invoked plugin to complete its tasks.
Intrinsic to this step is the design of a coordination mechanism that facilitates the interaction between plugins.
A UML sequence diagram shows the complete process of a generalized optimization run to represent the interactions between plugins.
\paragraph{Feedback and Refinement:}
Throughout the design process, continuous feedback loops are integrated. This involves:
\begin{itemize}
\item Revisiting each stage, evaluating its alignment with overarching goals.
\item Making necessary refinements to ensure the architecture is robust and flexible.
\end{itemize}
With the architectural design strategy in place, the next step is to define the implementation strategy.
\section{Implementation Strategy}
\label{sec:implementationStrategy}
Before diving into the implementation, an in-depth study of the \gls{qhana} documentation \cite{FabianBuehler} and a related paper on \gls{qhana}'s architecture \cite{Buehler2022} was undertaken to gain a comprehensive understanding of the system.
With component and sequence diagrams already in place, the next step is to define the implementation strategy.
\subsection{Development Environment and Toolset}
The choice of development tools and environment plays a pivotal role in the successful execution and maintenance of a project.
The right toolset facilitates smooth development and enhances the system's efficiency, productivity, and scalability.
The following list delineates the tools and technologies employed in the implementation process, each chosen for its specific capabilities tailored to the requirements of the project:
\begin{itemize}
\item \textbf{Visual Studio Code}: A versatile integrated development environment employed for its adaptability and support for Python development using extensions, facilitating comprehensive tools for coding, debugging, and testing.
\item \textbf{Docker}: Utilized to run all components of \gls{qhana}, ensuring consistent behavior across different computing environments and simplifying the deployment process.
\item \textbf{Postman}: An API testing tool employed to validate and debug various endpoints, ensuring consistent and expected behavior of the plugin interactions.
\item \textbf{Python}: As \gls{qhana} is implemented in Python, which offers versatility and a vast library ecosystem.
\item \textbf{Flask}: A lightweight Python web framework employed to develop the web services and \gls{rest}ful APIs for the plugins.
\item \textbf{Marshmallow}: A Python library pivotal for object serialization/deserialization, ensuring structured data transfer between the plugins.
\item \textbf{Flask-Smorest}: An extension of Flask, offering tools for building \gls{rest}ful APIs with Flask and Marshmallow, ensuring structured and accurate data transfer between plugins.
\item \textbf{Celery}: A task queue to manage long-running tasks, particularly for minimizer plugins, allowing for asynchronous task execution.
\item \textbf{Requests}: A Python library for interacting with HTTP endpoints. It invokes endpoints of plugins.
\end{itemize}
\subsection{Key Principles of QHana Plugins}
In the \gls{qhana} ecosystem, plugins play a pivotal role in extending functionality.
A set of principles governs the creation and integration of these plugins to ensure their seamless operation and interaction \cite{FabianBuehler}.
All plugins must adhere to these principles to ensure compatibility and consistency across the system.
To understand the decisions made in this work, consider at least the following principles:
\begin{itemize}
\item \textbf{Plugin Definition:}
A plugin is a Python module or package.
Conventionally, it inherits from the \texttt{QHAnaPluginBase} class and resides in a directory specified by the \texttt{PLUGIN\_FOLDERS} configuration variable.
The plugin imports its implementation class and all associated Celery tasks.
\item \textbf{Plugin Metadata and Endpoints:}
A plugin should contain metadata and links to all its endpoints. It is reachable via the "./" path.
The metadata includes crucial information like entry points.
\item \textbf{UI Interaction:}
Plugins define both \texttt{href} and \texttt{hrefUi} for each plugin with an \gls{ui}.
The `hrefUi` serves the microfrontend where users input data, and `href` is the underlying endpoint providing the functionality.
\item \textbf{Data Handling in Multi-step Plugins:}
Data is stored in a key-value store for plugins requiring multiple user input and processing steps.
A plugin task is associated with a unique database ID, and subsequent endpoint URLs of a plugin typically include the ID in the URL path \texttt{http(s)://.../<ID>/<endpointName>}.
That way, the plugin can retrieve the data from the database using the ID.
\item \textbf{Handling Long Running Tasks:}
For a plugin to be able to handle long-running tasks, \gls{qhana} offers the Celery framework.
Celery is a task queue that allows for asynchronous task execution.
\item \textbf{File Loading from URLs:}
Plugins have to be able to load files from URLs.
\item \textbf{Data Format Specification:}
Data formats, especially those shared across plugins, should be defined per the guidelines of \gls{qhana}.
For instance, for the \texttt{text/csv} format pertaining to entities:
\begin{itemize}
\item The first column must be the ID column (named ID). Subsequent columns represent entity attributes.
\item The CSV file should contain a header row specifying all attribute names.
\end{itemize}
\end{itemize}
It is imperative to note that while the outlined principles are crucial to this thesis, \gls{qhana}'s overarching documentation provides a more exhaustive list of best practices and guidelines for plugin creation \cite{FabianBuehler}.
\subsection{Data Handling and Transfer}
Flask-Smorest is instrumental in ensuring structured and accurate data transfer between plugins.
It provides functions for validating the correctness of passed data, returning appropriate error codes, and managing errors efficiently based on schemas.
This ensures that data exchanged between plugins is smooth and error-free.
\subsection{Testing and Debugging}
A multifaceted testing strategy addresses the paramount importance of the quality and reliability of plugins and their interactions:
\begin{enumerate}
\item \textbf{Static Code Analysis}:
\begin{itemize}
\item \textbf{Purpose}: To ensure code quality and maintainability and to identify potential vulnerabilities or deviations from coding standards.
\item \textbf{Tools \& Implementation}: The tool \emph{flake8}, in combination with type hints, is utilized to conduct static code analysis on the Python codebase.
\emph{Flake8} generates a report detailing any code inconsistencies, potential errors, or areas for improvement and provides valuable feedback for refinement.
\end{itemize}
\item \textbf{Logging and Monitoring}:
\begin{itemize}
\item \textbf{Purpose}: To capture, store, and analyze real-time information about the system's operations, aiding in troubleshooting and understanding system behavior.
\item \textbf{Tools \& Implementation}: Python's in-built \texttt{logging} package is leveraged to track and record various events during the execution of plugins.
By strategically placing logging statements within the code, it is possible to gain insights into the flow of operations, detect anomalies, and pinpoint areas that might require attention.
\end{itemize}
\item \textbf{Interactive Debugging}:
\begin{itemize}
\item \textbf{Purpose}: To step through the code in real-time, inspect variables, and analyze the program's flow to identify and rectify issues.
\item \textbf{Tools \& Implementation}: The integrated Python debugger in Visual Studio Code is employed.
This debugger allowed for setting breakpoints, stepping through code, inspecting variable states, and examining the call stack, providing a granular view of the system's operations and aiding in issue identification and resolution.
\end{itemize}
\item \textbf{Manual Testing}:
\begin{itemize}
\item \textbf{Purpose}: To capture nuances and potential issues that might be overlooked.
\item \textbf{Procedure}: A hands-on approach is adopted where the plugins are interactively used.
This involved navigating through the \gls{ui}, experimenting with different inputs, and observing the system's reactions to ensure it behaved as expected and met user requirements.
\end{itemize}
\end{enumerate}
Employing a combination of static code analysis, detailed logging, interactive debugging, and manual testing ensures functional correctness and that plugins adhere to coding standards and best practices.
\subsection{Performance Optimization}
The system employs several strategies to optimize performance in the microservice-based plugin architecture:
\begin{enumerate}
\item Reducing the number of interactions between plugins.
\item For each interaction, the amount of data transmitted across the network should be kept to a minimum to ensure efficient communication and faster response times.
\item For tasks that require extended processing, the Celery framework should be utilized, allowing these tasks to operate asynchronously and optimizing resource usage.
\end{enumerate}
These strategies are critical in ensuring swift and seamless interactions between plugins.
\subsection{Documentation and Extensibility}
The code includes comprehensive documentation that details how to add new \gls{of} and minimization plugins, facilitating the development of new plugins.
This documentation serves as a guideline for developers aiming to extend the capabilities of \gls{qhana} with plugin interaction.
\section{Evaluation Strategy}
\label{sec:evaluationStrategy}
To validate the effectiveness of the proposed solutions and to assess whether the goals set out in the problem statement have been achieved, the following evaluation methods are adopted:
\paragraph{Performance Benchmarking:}
\label{subsec:performanceBenchmarking}
Performance is paramount, especially in a plugin-based architecture.
A direct comparison shows the differences between the two plugin-based and non-service-based approaches.
Critical metrics for this comparison include:
\begin{itemize}
\item \textbf{Objective Function Calculation Time}: This measures the time to retrieve the loss, directly impacting the overall optimization time.
For the plugin-based approach, this is the time, as observed by the client calling the calculation endpoint, meaning it includes the network latency.
As all system components run on the same machine, network, in this case, means the \emph{localhost}.
\item \textbf{Minimization Time}: This refers to the time needed to minimize the \gls{of}.
The service-based approach includes the time taken for the minimization endpoint to return a result via the network.
\item \textbf{Network Latency}: This exclusively quantifies the time required for a request to reach the server and for the corresponding response to be received.
This metric does not include any computation time that occurs on the server.
This metric is exclusive to the service-based approach.
\item \textbf{Database Access Times}: It is essential to gauge the time required to retrieve data from the database since endpoints access context data during each invocation.
\end{itemize}
This evaluation hinges on quantitative metrics, with results graphically depicted for enhanced clarity.
The \emph{time.perf\_count} function from Python measures the time taken for a function to execute, providing a reliable and accurate measure of performance.
\paragraph{Interchangeability:}
The accurate measure of interchangeability is the ability to swap components without causing disruptions.
Accordingly, all allowed combinations of plugins were tested to validate seamless interchangeability.
\paragraph{Standardization Adherence:}
Standardization is checked to ensure compatibility and uniformity across diverse plugins.
An evaluation determines whether all implemented plugins conform to the prescribed standards.
This guarantees that all possible optimization plugins can be implemented uniformly, facilitating consistent and compatible integrations in the future.
\paragraph{Developer Experience:}
The developer experience has to be maintained.
To measure the experience, the steps required to implement a new plugin are counted, and each step is evaluated for its complexity.
The evaluation acknowledges any documentation that guides developers through the process.
An assessment determines the ease and efficiency with which a developer can introduce a new plugin in plugin-based optimization in \gls{qhana}.
The goal is to ensure that the plugin-based approach is as easy to implement as the non-service-based approach.
This thesis thoroughly appraises the solutions concerning the challenges outlined in the problem statement by meticulously evaluating these parameters.
\section{Test Data Generation for Evaluation}
To robustly evaluate the solutions proposed in this work, testing them on diverse datasets with different sizes and complexity is essential.
The objective is to mimic real-world scenarios where optimization problems can range from simple tasks with a few data points to complex challenges with many features and data points.
The code used to generate the test data can be found in the \hyperref[chap:appendix]{Appendix}.
The following criteria are employed to generate the test data:
Datasets of different \emph{sizes} are generated, spanning from a modest 200 data points to a substantial 1400 data points.
This variation ensures that the optimization performance is assessed across different scales, from quick-to-process small datasets to computationally demanding large datasets.
The \emph{number of features} in each dataset is dynamically determined based on the dataset's size, calculated explicitly as \(\lfloor \sqrt{\text{size}} \times 1.5 \rfloor\).
This approach ensures that with the growth of the dataset, its complexity also increases, mirroring real-world scenarios where larger datasets often present more features or dimensions.
The \texttt{make\_regression} function from the Scikit-learn library generates data.
An added \emph{noise} parameter introduces an element of randomness, making the optimization task more intricate and resembling real-world challenges.
To maintain the consistency and reliability of the generated datasets across multiple runs or evaluations, a fixed random seed (\texttt{numpy.random.seed(42)}) has been set.
This ensures that the data, though synthetic and noisy, remains consistent across evaluations, enabling accurate comparisons, assessments, and \emph{reproducibility}.
Two criteria are employed to adhere to \gls{qhana}'s data standards:
Each data point in the dataset is allocated a unique ID in the format \emph{entityX}, where X represents the entity number.
This aligns with \gls{qhana}'s data standard that mandates every data point to have an identifiable ID.
All datasets are stored in the CSV (Comma Separated Values) format, adhering to \gls{qhana}'s accepted data formats.
% Listing \ref{lst:data_csv} shows an excerpt of a generated CSV data set with 10 data points 4 features and a noise of 10.
% For better readability, the number of decimal places has been reduced to 4.
% The first column contains the entity IDs, the last column the target variable, and the columns in between the features.
% \begin{center}
% \lstinputlisting[language={},caption={Excerpt of a test data file with 10 data points},label={lst:data_csv}]{data/data.csv}
% \end{center}
By employing such datasets, the methodology objectively evaluates the optimization solutions, assessing their performance, interchangeability, and user experience across various scenarios.
\chapter{Resulting System Architecture}
\label{chap:architecture}
This chapter delves into the intricate architectural blueprint of the proposed plugin-based optimization framework.
It explores the decomposition into distinct plugin types, each with clearly defined roles and responsibilities.
The chapter also elucidates the universal plugin interfaces designed to ensure seamless interaction between different plugins, fostering modularity and extensibility.
By the end of this chapter, readers will gain a comprehensive understanding of the system's interaction flow, its various components, and their interdependencies, all illustrated through detailed component and sequence diagrams.
\section{Resulting Decomposition into Plugins and their Responsibilities}
\label{sec:resdecomposition}
Following the decomposition strategy, the plugin-based optimization framework is divided into three primary plugin types:
\gls{of} plugin, the minimizer plugin, and the coordinator plugin.
These plugins have specific roles and responsibilities, ensuring a modular and efficient optimization process.
This split is visualized in the component diagram in figure \ref{fig:component_diagram}.
It is important to note that this decomposition and the associated responsibilities remain consistent for both proposed plugin-based approaches.
\paragraph{Objective Function Plugin:}
The \gls{of} plugin is central to the optimization framework, encapsulating the mathematical function that defines the problem at hand.
Its primary roles include:
\begin{itemize}
\item \textbf{Metadata Provision}: The plugin offers metadata about itself.
\item \textbf{Hyperparameters Acquisition}: It prompts the user to provide the hyperparameters necessary for the loss function calculation.
\item \textbf{Loss Calculation}: The plugin computes the loss based on the provided input data, representing the discrepancy between predicted and target values.
\item \textbf{Gradient Calculation (Optional)}: For optimization algorithms that leverage gradient-based methods, the plugin can optionally compute the gradient of the loss function.
The gradient aids in guiding the optimization process toward the desired minimum.
\end{itemize}
\paragraph{Minimizer Plugin:}
The minimizer plugin is responsible for iteratively adjusting parameters to minimize the loss provided by the \gls{of} plugin.
Its functions include:
\begin{itemize}
\item \textbf{Metadata Provision}: Similar to the \gls{of} plugin, it provides essential metadata.
\item \textbf{Hyperparameters Acquisition}: The plugin acquires the hyperparameters crucial for the employed minimization algorithm from the user.
\item \textbf{Minimization Process}: Using the loss (and optionally the gradient) from the \gls{of} plugin, the minimizer plugin endeavors to find the parameter values that minimize this loss.
\end{itemize}
\paragraph{Coordinator Plugin:}
The Coordinator plugin acts as the orchestrator, ensuring seamless interaction between the \gls{of} and minimizer plugins and the user.
Its primary responsibilities are:
\begin{itemize}
\item \textbf{Plugin Selection}: It prompts the user to select the desired \gls{of} and minimizer plugins for optimization.
\item \textbf{Data Acquisition}: The plugin gathers the necessary input data and the target variable from the user, which the optimization process will use.
\item \textbf{Endpoint Acquisition}: It obtains the necessary endpoints from the selected plugins.
\item \textbf{Coordination Role}: It manages the interaction between the \gls{of} and minimizer plugins, ensuring that the loss (and optionally gradient) calculation function is provided to the minimizer plugin for the optimization process.
Additionally, it coordinates the interaction between the user and the selected plugins, ensuring the user sees the necessary microfrontends.
\item \textbf{Results Presentation}: Post-optimization, the coordinator plugin presents the optimization results to the user.
\end{itemize}
\section{Universal Plugin Interface Design}
The process of optimization is inherently complex, with a multitude of variations and nuances.
It is imperative to establish universal plugin interfaces for each type of plugin to ensure a streamlined interaction between different plugins.
This interface acts as a standard that every plugin of a specific type has to adhere to.
The interfaces for each plugin are detailed below and are visualized in the component diagram in figure \ref{fig:component_diagram}.
\begin{figure}[ht]
\centering
\includegraphics[width=\textwidth]{graphics/plugin_decomposition.svg}
\caption{Component Diagram of decomposed optimization process}
\label{fig:component_diagram}
\end{figure}
\paragraph{Objective Function Plugin Interfaces:}
The \gls{of} plugin interface accommodates a wide range of loss functions, including those that offer gradient computation.
Its interfaces are:
\begin{itemize}
\item \textbf{Metadata}: The plugin provides metadata about itself as specified in the \gls{qhana} documentation \cite{FabianBuehler}.
\item \textbf{UIRef}: This endpoint returns the microfrontend for the \gls{of} plugin, where the user inputs the hyperparameters for the calculation.
This interface also follows the \gls{qhana} documentation \cite{FabianBuehler}.
\item \textbf{HRef}: This endpoint is used to process the input from the \gls{of} microfrontend and is therefore usually called the \textbf{processing} endpoint.
It is usually triggered by the user clicking the \emph{submit} button on the microfrontend.
This interface also follows the \gls{qhana} documentation \cite{FabianBuehler}.
\item \textbf{PassData}: Via this endpoint, the coordinator passes the input and target data to the \gls{of} plugin.
It returns the number of weights required for the optimization process.
It returns the number of weights required by the objective function.
\item \textbf{CalculateLoss}: This endpoint calculates the loss.
\item \textbf{CalculateGradient (Optional)}: This endpoint calculates the gradient of the loss. It is optional since the gradient cannot be computed efficiently for all \glspl{of}.
\item \textbf{CalculateLossAndGradient (Optional)}: This endpoint calculates the loss and the gradient of the loss function. Similar to the previous endpoint, it is optional.
\end{itemize}
\paragraph{Minimizer Plugin Interfaces:}
The minimizer plugin, responsible for optimizing the loss function provided by the \gls{of} plugin, offers these interfaces:
\begin{itemize}
\item \textbf{Metadata}: same as for the \gls{of} plugin
\item \textbf{UIRef}: same as for the \gls{of} plugin
\item \textbf{HRef}: same as for the \gls{of} plugin
\item \textbf{Minimize}: This endpoint minimizes the loss function.
\end{itemize}
\paragraph{Coordinator Plugin Interfaces:}
The coordinator plugin, orchestrating the interaction between the \gls{of} and minimizer plugins, is equipped with the standard \gls{qhana} interfaces \textbf{Metadata}, \textbf{UIRef}, and \textbf{HRef}.
A systematic, consistent, and efficient optimization process is ensured by establishing these interfaces and ensuring that each plugin conforms to them.
This structured approach facilitates seamless interactions and fosters interchangeability, modularity, and extensibility, making it easy to add new \gls{of} and minimizer plugins in the future.
\section{Plugin Interaction Design}
The design of plugin interactions is pivotal to ensuring efficient and seamless coordination between different system components.
Given the extensive possibilities of interactions within the \gls{qhana} environment, the design phase is meticulous, considering various scenarios and ensuring adaptability.
The two primary modes of interaction are short-running and long-running, each catering to specific requirements.
\paragraph{Short-Running Interaction:}
In short-running interactions, a plugin invokes another plugin's endpoint, typically via a `GET` or a `POST` request, and immediately receives a response.
This mode of interaction is synchronous, wherein the invoking plugin waits for the response before proceeding.
Instances of such interactions in the optimization context are:
\begin{itemize}
\item The coordinator plugin retrieves metadata from the \gls{of} and minimizer plugins.
\item The coordinator plugin passes data to the \gls{of} plugin.
\item The minimizer plugin calls the \texttt{CalculateLoss} endpoint of the \gls{of} plugin.
\end{itemize}
\paragraph{Long-Running Interaction:}
Long-running interactions come into play for processes requiring extensive computation time or involving multiple steps.
In such a case, the calling plugin invokes the endpoint of the invocable plugin.
The invoked endpoint then schedules a long-running task and returns immediately.
The calling plugin can then continue with its execution asynchronously without waiting for the long-running task to finish.
The calling plugin gets an additional endpoint that is called by the long-running task once it finishes.
This endpoint is called a callback endpoint.
Instances of such interactions are:
\begin{itemize}
\item The coordinator schedules the microfrontend of the \gls{of} plugin.
The coordinator plugin provides a callback endpoint to the \gls{of} plugin that is called once the user enters the input and the input is processed.
\item The coordinator schedules the microfrontend of the minimizer plugin.
This mechanism works identically to the previous item.
\item The coordinator plugin calls the minimization endpoint of the minimizer plugin.
The minimizer plugin schedules the minimization process and returns immediately.
Once the minimization process finishes, the minimizer plugin calls a callback endpoint of the coordinator plugin.
\end{itemize}
The design of these interactions ensures that plugins can interact seamlessly and efficiently regardless of the complexity or duration of tasks.
\section{Introduction of Interaction Endpoints}
\label{sec:introie}
Building upon the idea of plugins interacting with each other, as detailed in the previous section, a crucial question arises:
How does one plugin discover the available endpoints of another?
This thesis introduces a novel concept called \textit{interaction endpoints} to \gls{qhana} to address this very challenge.
While \gls{qhana} already has a metadata field named \emph{entry points}, which are endpoints invoked by the \gls{qhana} \gls{ui} to render a plugin's \gls{ui}, interaction endpoints extend this idea further.
They specifically define endpoints in the metadata that other plugins can invoke, facilitating seamless integration and interaction.
The core of interaction endpoints is their \emph{type}.
All interaction endpoints with the same type must adhere to the same signature and return type.
This uniformity ensures that other plugins can invoke them interchangeably.
The \gls{of} plugin provides interaction endpoints of types \emph{calc\_loss}, \emph{calc\_grad}, \emph{calc\_loss\_and\_grad}, and \emph{of\_pass\_data}.
The minimizer plugin offers the \emph{minimization} type.
These interaction endpoints correspond to the endpoints defined in the previous section.
The introduction of interaction endpoints significantly enhances the modularity and interchangeability within \gls{qhana}, paving the way for a more dynamic and adaptable plugin ecosystem.
More on how these interaction endpoints are implemented can be found in the implementation chapter \ref{chap:implementation}.
\section{Final Interaction Flow}
The architecture's final interaction flow is split into three main parts, each ending in a new \gls{ui} displayed to the user.
The sequence diagrams in figures \ref{fig:interaction_flow_part1}, \ref{fig:interaction_flow_part2}, and \ref{fig:interaction_flow_part3} visualize the interaction flow.
The first part begins after selecting the optimization plugin and concludes when the \gls{of} plugin's \gls{ui} is set as the next step.
Here, the coordinator plugin retrieves the user-selected \gls{of} and minimization plugin metadata, including their interaction endpoints.
This flow is represented in Figure \ref{fig:interaction_flow_part1}.
The second part starts with retrieving the \gls{of} plugin's microfrontend and ends when the minimizer plugin \gls{ui} is set as the next step.
After the user inputs hyperparameters and submits, the \gls{of} processes the input and sends a callback to the coordinator plugin,
The callback endpoint then passes the input and target data to the PassData endpoint.
This sequence is depicted in Figure \ref{fig:interaction_flow_part2}.
The last segment starts with the minimizer plugin's microfrontend retrieval and ends when the optimization process concludes.
After users input the minimization hyperparameters, the minimizer processes the data and sends a callback to the coordinator.
The coordinator then triggers the minimization endpoint, initiating a long-running minimization task that continuously calls the \gls{of} calculation endpoint.
Once this task is completed, the minimizer makes a final call to the coordinator with the minimization results.
Figure \ref{fig:interaction_flow_part3} shows this flow.
\begin{figure}[p]
\centering
\checkoddpage
\ifoddpage
\rotatebox{-90}{\includegraphics[width=0.9\textheight]{graphics/interaction_flow_1.svg}}
\else
\rotatebox{90}{\includegraphics[width=0.9\textheight]{graphics/interaction_flow_1.svg}}
\fi
\caption{Final interaction flow of the optimization process (part 1/3).}
\label{fig:interaction_flow_part1}
\end{figure}
\begin{figure}[p]
\centering
\checkoddpage
\ifoddpage
\rotatebox{90}{\includegraphics[width=0.9\textheight]{graphics/interaction_flow_2.svg}}
\else
\rotatebox{-90}{\includegraphics[width=0.9\textheight]{graphics/interaction_flow_2.svg}}
\fi
\caption{Final interaction flow of the optimization process (part 2/3).}
\label{fig:interaction_flow_part2}
\end{figure}
\begin{figure}[p]
\centering
\checkoddpage
\ifoddpage
\rotatebox{-90}{\includegraphics[width=0.9\textheight]{graphics/interaction_flow_3.svg}}
\else
\rotatebox{90}{\includegraphics[width=0.9\textheight]{graphics/interaction_flow_3.svg}}
\fi
\caption{Final interaction flow of the optimization process (part 3/3).}
\label{fig:interaction_flow_part3}
\end{figure}
\chapter{Implementation}
\label{chap:implementation}