From 49ba9cfec51dac785054b302ac201b830aeb49f9 Mon Sep 17 00:00:00 2001 From: "Adam M. Krajewski" <54290107+amkrajewski@users.noreply.github.com> Date: Tue, 25 Jun 2024 17:37:54 +0200 Subject: [PATCH] - adjust colorized code listings to PNGs --- nimcsotutorial.tex | 269 +++++++-------------------------------------- 1 file changed, 39 insertions(+), 230 deletions(-) diff --git a/nimcsotutorial.tex b/nimcsotutorial.tex index 7b9a418..839c8ec 100644 --- a/nimcsotutorial.tex +++ b/nimcsotutorial.tex @@ -1,4 +1,4 @@ -\chapter{\texttt{nimCSO} Tutorial} \label{chap:nimplextutorial2}} +\chapter{\texttt{nimCSO} Tutorial} \label{chap:nimplextutorial2} The purpose of this guide is to demonstrate some common use cases of \texttt{nimCSO} and go in a bit more into the details @@ -108,57 +108,16 @@ \section{Dataset, Config, and \end{minted} \begin{minted}[xleftmargin=3\parindent, fontsize=\small, bgcolor=subtlegray]{output} -Hint: used config file '/opt/conda/nim/config/nim.cfg' [Conf] -Hint: used config file '/opt/conda/nim/config/config.nims' [Conf] -........................................................................................................................................................... -/root/.nimble/pkgs2/nimblas-0.3.0-d5033749759fc7a2a316acf623635dcb6d69d32a/nimblas/private/common.nim(52, 7) Hint: Using BLAS library with name: lib(blas|cblas|openblas).so(||.3|.2|.1|.0) [User] -........................................................................... +... config.yaml CC: ../../../opt/conda/nim/lib/system/exceptions.nim CC: ../../../opt/conda/nim/lib/std/private/digitsutils.nim CC: ../../../opt/conda/nim/lib/std/assertions.nim -CC: ../../../opt/conda/nim/lib/system/dollars.nim -CC: ../../../opt/conda/nim/lib/std/syncio.nim -CC: ../../../opt/conda/nim/lib/system.nim -CC: ../../../opt/conda/nim/lib/pure/parseutils.nim -CC: ../../../opt/conda/nim/lib/pure/math.nim -CC: ../../../opt/conda/nim/lib/pure/unicode.nim -CC: ../../../opt/conda/nim/lib/pure/strutils.nim -CC: ../../../opt/conda/nim/lib/pure/hashes.nim -CC: ../../../opt/conda/nim/lib/pure/collections/sets.nim -CC: ../../../opt/conda/nim/lib/pure/times.nim -CC: ../../../opt/conda/nim/lib/std/private/ospaths2.nim -CC: ../../../opt/conda/nim/lib/std/envvars.nim -CC: ../../../opt/conda/nim/lib/std/cmdline.nim -CC: ../../../opt/conda/nim/lib/pure/collections/sequtils.nim -CC: ../../../opt/conda/nim/lib/pure/random.nim -CC: ../../../opt/conda/nim/lib/pure/collections/heapqueue.nim -CC: ../../../opt/conda/nim/lib/pure/strformat.nim -CC: ../../../opt/conda/nim/lib/pure/terminal.nim -CC: ../../../root/.nimble/pkgs2/yaml-2.1.1-302727fcd74c79d0697a4e909d26455d61a5b979/yaml/presenter.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/laser/dynamic_stack_arrays.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/laser/private/memory.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/laser/tensor/datatypes.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/laser/tensor/initialization.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/tensor/init_cpu.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/tensor/higher_order_applymap.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/tensor/private/p_shapeshifting.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/tensor/init_copy_cpu.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/tensor/private/p_accessors_macros_read.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/tensor/private/p_accessors_macros_write.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/tensor/shapeshifting.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/private/functional.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/tensor/private/p_display.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/tensor/display.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/tensor/ufunc.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/laser/cpuinfo_x86.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/tensor/operators_broadcasted.nim -CC: ../../../root/.nimble/pkgs2/arraymancer-0.7.28-d4a45ada1c7a6abebe60bcdd5ee2d7c4680799a4/arraymancer/tensor/aggregate.nim +... CC: nimcso/bitArrayAutoconfigured.nim CC: nimcso.nim -Hint:  [Link] -Hint: mm: orc; threads: on; opt: speed; options: -d:release -87026 lines; 7.635s; 257.383MiB peakmem; proj: /workspaces/nimCSO/src/nimcso; out: /workspaces/nimCSO/examples/nimcso [SuccessX] +Hint: orc; threads: on; opt: speed; options: -d:release +87026 lines; 7.635s; 257.383MiB peakmem; proj: /workspaces/nimCSO/src/nimcso; out: /workspaces/nimCSO/examples/nimcso[SuccessX] \end{minted} Now, let's run \texttt{nimCSO} and see what happens! @@ -167,23 +126,10 @@ \section{Dataset, Config, and !./nimcso \end{minted} -\begin{minted}[xleftmargin=3\parindent, fontsize=\small, bgcolor=subtlegray]{output} -Using 1 uint64s to store 19 elements. -Configured for task: QuickStart (Just a copy of RCCA Palette from Senkov 2018 Review) -***** nimCSO (Composition Space Optimization) ***** -To use form command line, provide parameters. Currently supported usage: - ---covBenchmark | -cb --> Run small coverage benchmarks under two implementations. ---expBenchmark | -eb --> Run small node expansion benchmarks. ---leastPreventing | -lp --> Run a search for single-elements preventing the least data, i.e. the least common elements. ---mostCommon | -mc --> Run a search for most common elements. ---bruteForce | -bf --> Run brute force algorithm after getting ETA. Note that it is not feasible for more than 25ish elements. ---bruteForceInt | -bfi --> Run brute force algorithm with faster but not extensible uint64 representation after getting ETA. Up to 64 elements only. ---geneticSearch | -gs --> Run a genetic search algorithm. ---algorithmSearch | -as --> Run a custom problem-informed best-first search algorithm. ---singleSolution | -ss --> Evaluate a single solution based on the elements provided as arguments after the flag. It can be stacked on itself like: - ./nimcso -ss Ta W Hf Si -ss V W Hf Si --singleSolution Ta V -\end{minted} +\begin{figure}[H] + \centering + \includegraphics[width=0.9\textwidth]{nimcsotutorial/1.png} +\end{figure} You should have seen a neat \texttt{help} message that tells you how to use \texttt{nimCSO}. Let's start with @@ -195,36 +141,13 @@ \section{Dataset, Config, and !./nimcso -cb \end{minted} -\begin{minted}[xleftmargin=3\parindent, fontsize=\small, bgcolor=subtlegray]{output} -Using 1 uint64s to store 19 elements. -Configured for task: QuickStart (Just a copy of RCCA Palette from Senkov 2018 Review) -***** nimCSO (Composition Space Optimization) ***** -Running coverage benchmark with int8 Tensor representation -Tensor[system.int8] of shape "[1, 19]" on backend "Cpu" -|1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0| -CPU Time [arraymancer+randomizing] 133.6μs -Prevented count:995 - -Running coverage benchmark with BitArray representation -CPU Time [bitty+randomizing] 13.6μs - | 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|16|17|18|19| - 19 | 1| 1| 1| 1| 1| 1| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| -MoTaVWTiZr->995 -Prevented count:995 - -Running coverage benchmark with bool arrays representation (BitArray graph retained) -CPU Time [bit&boolArrays+randomizing] 16.1μs - | 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|16|17|18|19| - 19 | 1| 1| 1| 1| 1| 1| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0| -MoTaVWTiZr->995 -Prevented count:995 - -nimCSO Done! -\end{minted} +\begin{figure}[H] + \centering + \includegraphics[width=0.9\textwidth]{nimcsotutorial/2.png} +\end{figure} -\hypertarget{key-routines-and-brute-forcing}{% -\section{Key Routines and Brute -Forcing}\label{nimcsotutorial:key-routines-and-brute-forcing}} +\hypertarget{key-routines-and-brute-forcing}{ +\section{Key Routines and Brute Forcing}\label{nimcsotutorial:key-routines-and-brute-forcing}} And if you were able to run that, you are all set to start using \texttt{nimCSO}! @@ -236,34 +159,10 @@ \section{Key Routines and Brute !./nimcso --mostCommon \end{minted} -\begin{minted}[xleftmargin=3\parindent, fontsize=\small, bgcolor=subtlegray]{output} -Using 1 uint64s to store 19 elements. -Configured for task: QuickStart (Just a copy of RCCA Palette from Senkov 2018 Review) -***** nimCSO (Composition Space Optimization) ***** - -Running search for single-elements preventing the most data. - 0: Cr->667 - 1: Ti->649 - 2: Fe->622 - 3: Ni->620 - 4: Nb->587 - 5: Co->573 - 6: Al->569 - 7: Mo->466 - 8: Zr->346 - 9: Ta->330 -10: V->256 -11: Hf->219 -12: W->207 -13: Si->92 -14: B->69 -15: Re->55 -16: C->36 -17: Y->3 -18: N->1 - -nimCSO Done! -\end{minted} +\begin{figure}[H] + \centering + \includegraphics[width=0.9\textwidth]{nimcsotutorial/3.png} +\end{figure} If you didn't modify anything, you should now see that elements like \texttt{N}, \texttt{Y}, @@ -287,38 +186,10 @@ \section{Key Routines and Brute !./nimcso -bfi \end{minted} -\begin{minted}[xleftmargin=3\parindent, fontsize=\small, bgcolor=subtlegray]{output} -Using 1 uint64s to store 19 elements. -Configured for task: QuickStart (Just a copy of RCCA Palette from Senkov 2018 Review) -***** nimCSO (Composition Space Optimization) ***** - -Running brute force algorithm for 19 elements and 1349 data points. -Solution space size: 524287 -Task ETA Estimate: 7 seconds and 30 milliseconds - 0: ->0 - 1: N->1 - 2: YN->4 - 3: YCN->39 - 4: ReYCN->89 - 5: ReYBCN->142 - 6: SiReYBCN->203 - 7: WSiReYBCN->340 - 8: WHfSiReYBCN->511 - 9: TaWHfSiReYBCN->630 -10: TaWZrHfSiReYBCN->735 -11: TaVWZrHfSiReYBCN->816 -12: TaVWZrHfNbSiReYBCN->859 -13: TaVWTiZrHfNbSiReYBCN->952 -14: MoTaVWTiZrHfNbSiReYBCN->1038 -15: MoTaVWTiZrHfNbAlSiReYBCN->1304 -16: TaVWTiZrHfNbCrAlCoNiReFeYCN->1327 -17: MoTaVWTiZrHfNbCrAlSiCoNiReFeYB->1349 -18: MoTaVWTiZrHfNbCrAlSiCoNiReFeYBC->1349 -19: MoTaVWTiZrHfNbCrAlSiCoNiReFeYBCN->1349 -CPU Time [Brute Force] 7308.5ms - -nimCSO Done! -\end{minted} +\begin{figure}[H] + \centering + \includegraphics[width=0.9\textwidth]{nimcsotutorial/4.png} +\end{figure} Let's look at the result! As expected, \texttt{N}, \texttt{Y}, \texttt{C}, and @@ -340,16 +211,10 @@ \section{Key Routines and Brute !./nimcso -ss Ta W Hf Si Re Y B C N -ss V W Hf Si Re Y B C N \end{minted} -\begin{minted}[xleftmargin=3\parindent, fontsize=\small, bgcolor=subtlegray]{output} -Using 1 uint64s to store 19 elements. -Configured for task: QuickStart (Just a copy of RCCA Palette from Senkov 2018 Review) -***** nimCSO (Composition Space Optimization) ***** -Testing solution with @[@["Ta", "W", "Hf", "Si", "Re", "Y", "B", "C", "N"], @["V", "W", "Hf", "Si", "Re", "Y", "B", "C", "N"]] - 9: TaWHfSiReYBCN->630 - 9: VWHfSiReYBCN->697 - -nimCSO Done! -\end{minted} +\begin{figure}[H] + \centering + \includegraphics[width=0.9\textwidth]{nimcsotutorial/5.png} +\end{figure} Wow! Looking at the \texttt{--mostCommon} output from earlier, we can see that \textbf{\texttt{Ta} is present @@ -377,17 +242,10 @@ \section{Key Routines and Brute !./nimcso -ss Ta V W Zr Hf Nb Si Re Y B C N -ss Ta V W Zr Hf Mo Si Re Y B C N -ss Ta V W Zr Hf Ti Si Re Y B C N \end{minted} -\begin{minted}[xleftmargin=3\parindent, fontsize=\small, bgcolor=subtlegray]{output} -Using 1 uint64s to store 19 elements. -Configured for task: QuickStart (Just a copy of RCCA Palette from Senkov 2018 Review) -***** nimCSO (Composition Space Optimization) ***** -Testing solution with @[@["Ta", "V", "W", "Zr", "Hf", "Nb", "Si", "Re", "Y", "B", "C", "N"], @["Ta", "V", "W", "Zr", "Hf", "Mo", "Si", "Re", "Y", "B", "C", "N"], @["Ta", "V", "W", "Zr", "Hf", "Ti", "Si", "Re", "Y", "B", "C", "N"]] -12: TaVWZrHfNbSiReYBCN->859 -12: MoTaVWZrHfSiReYBCN->935 -12: TaVWTiZrHfSiReYBCN->938 - -nimCSO Done! -\end{minted} +\begin{figure}[H] + \centering + \includegraphics[width=0.9\textwidth]{nimcsotutorial/6.png} +\end{figure} We can see that \textbf{\texttt{Nb} is present in 121 more datapoints than \texttt{Mo}, but after removing @@ -420,34 +278,10 @@ \section{Algorithm Search}\label{nimcsotutorial:algorithm-search}} !./nimcso -as \end{minted} -\begin{minted}[xleftmargin=3\parindent, fontsize=\small, bgcolor=subtlegray]{output} -Using 1 uint64s to store 19 elements. -Configured for task: QuickStart (Just a copy of RCCA Palette from Senkov 2018 Review) -***** nimCSO (Composition Space Optimization) ***** - -Running Algorithm Search for 19 elements. - 1: N->1 (tree size: 19) - 2: YN->4 (tree size: 52) - 3: YCN->39 (tree size: 113) - 4: ReYCN->89 (tree size: 275) - 5: ReYBCN->142 (tree size: 581) - 6: SiReYBCN->203 (tree size: 690) - 7: WSiReYBCN->340 (tree size: 1818) - 8: WHfSiReYBCN->511 (tree size: 3873) - 9: TaWHfSiReYBCN->630 (tree size: 5213) -10: TaWZrHfSiReYBCN->735 (tree size: 4833) -11: TaVWZrHfSiReYBCN->816 (tree size: 4192) -12: TaVWZrHfNbSiReYBCN->859 (tree size: 3784) -13: TaVWTiZrHfNbSiReYBCN->952 (tree size: 2955) -14: MoTaVWTiZrHfNbSiReYBCN->1038 (tree size: 1765) -15: MoTaVWTiZrHfNbAlSiReYBCN->1304 (tree size: 45) -16: MoTaVWTiZrHfNbAlSiReFeYBCN->1338 (tree size: 8) -17: MoTaVWTiZrHfNbCrAlSiReFeYBCN->1349 (tree size: 4) -18: MoTaVWTiZrHfNbCrAlSiNiReFeYBCN->1349 (tree size: 4) -CPU Time [exploring] 109.7ms - -nimCSO Done! -\end{minted} +\begin{figure}[H] + \centering + \includegraphics[width=0.9\textwidth]{nimcsotutorial/7.png} +\end{figure} As you can see, \textbf{the algorithm reproduced the same results as the brute force search around 100 times faster}, except for third-to-last @@ -469,35 +303,10 @@ \section{Genetic Search}\label{nimcsotutorial:genetic-search}} !./nimcso -gs \end{minted} -\begin{minted}[xleftmargin=3\parindent, fontsize=\small, bgcolor=subtlegray]{output} -Using 1 uint64s to store 19 elements. -Configured for task: QuickStart (Just a copy of RCCA Palette from Senkov 2018 Review) -***** nimCSO (Composition Space Optimization) ***** - -Running Genetic Search algorithm for 19 elements and 1349 data points. -Initiating each level with 100 random solutions and expanding 100 solutions at each level for up to 1000 iterations. - 1: N->1 - 2: YN->4 (queue size: 256) - 3: YCN->39 (queue size: 615) - 4: ReYCN->89 (queue size: 869) - 5: ReYBCN->142 (queue size: 929) - 6: SiReYBCN->203 (queue size: 1379) - 7: WSiReYBCN->340 (queue size: 1267) - 8: WHfSiReYBCN->511 (queue size: 1631) - 9: TaWHfSiReYBCN->630 (queue size: 1578) -10: TaWZrHfSiReYBCN->735 (queue size: 1835) -11: TaVWZrHfSiReYBCN->816 (queue size: 1621) -12: TaVWZrHfNbSiReYBCN->859 (queue size: 1746) -13: VWCrAlSiCoNiReFeYBCN->1176 (queue size: 1713) -14: MoTaVWTiZrHfNbSiReYBCN->1038 (queue size: 1565) -15: MoTaVWCrAlSiCoNiReFeYBCN->1320 (queue size: 1028) -16: TaVWTiZrHfNbCrAlCoNiReFeYCN->1327 (queue size: 1575) -17: MoTaVWTiZrHfNbCrAlSiCoFeYBCN->1349 (queue size: 268) -18: MoTaVWTiZrHfNbCrAlSiCoNiReFeBCN->1349 (queue size: 18) -CPU Time [Genetic Search] 766.9ms - -nimCSO Done! -\end{minted} +\begin{figure}[H] + \centering + \includegraphics[width=0.9\textwidth]{nimcsotutorial/8.png} +\end{figure} \hypertarget{summary}{% \subsection{Summary}\label{nimcsotutorial:summary}}