diff --git a/.gitignore b/.gitignore index 5a4c1886..d91dd280 100644 --- a/.gitignore +++ b/.gitignore @@ -314,3 +314,4 @@ slides .slides ./.slides BSS-Algorytmy_Szyfrowania +venv \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json index f3863412..0362f1bc 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,7 @@ { "recommendations": [ + "james-yu.latex-workshop", "tomoki1207.pdf" + ] } \ No newline at end of file diff --git a/NotProgramming/SDM2/presentations/my_thesis/main.pdf b/NotProgramming/SDM2/presentations/my_thesis/main.pdf index 0db81664..35bef376 100644 Binary files a/NotProgramming/SDM2/presentations/my_thesis/main.pdf and b/NotProgramming/SDM2/presentations/my_thesis/main.pdf differ diff --git a/NotProgramming/SDM2/presentations/my_thesis/main.tex b/NotProgramming/SDM2/presentations/my_thesis/main.tex index c672384b..324fdc4c 100644 --- a/NotProgramming/SDM2/presentations/my_thesis/main.tex +++ b/NotProgramming/SDM2/presentations/my_thesis/main.tex @@ -1,14 +1,18 @@ \documentclass{beamer} + \usepackage[fontsize=20pt]{fontsize} \usepackage{graphicx} \usepackage{tikz} +\usepackage{changepage} % Add to your preamble \usepackage{svg} -\usepackage[T1]{fontenc} \usepackage[polish]{babel} -\usepackage[utf8]{inputenc} + + \graphicspath{ {./images/} } \usetheme{Warsaw} + + %Information to be included in the title page: % Custom title page layout adjustments @@ -52,7 +56,7 @@ \tableofcontents \end{frame} -\section{Teoria} +\section{Definicje} \begin{frame} \frametitle{Gra komputerowa} \large Aplikacja dostępna na platformie "Steam" oznaczona typem "Game" @@ -151,8 +155,7 @@ \begin{frame} \end{frame} } - - + \begin{frame} \frametitle{Nsight - Analiza FPS} \center @@ -183,19 +186,14 @@ % I jaka metoda w api tę zawieszkę spowodowała \end{frame} - \begin{frame} - \frametitle{Nsight - Zużycie VRAM} - \center - \includegraphics[width=1\textwidth]{memory_utilization.png} - % Zielony -> ile pamięci mamy dostępnej - % Pomarańczowy -> ile pamięci zużyliśmy - \end{frame} \begin{frame} \frametitle{Nsight - Zużycie VRAM} \center \includegraphics[width=1\textwidth]{memory_utilization_gpu_vram.png} - % VidMm Device Suspension -> okresy kiedy przetransferowano + % Zielony -> ile pamięci mamy dostępnej + % Pomarańczowy -> ile pamięci zużyliśmy + % VidMm Device Suspension -> okresy czasku kiedy przetransferowano % Jeden duży zasób pamięci % Demoted Memory -> w GPU mamy local memory (szybsze) i global memory % (wolniejsze) to może nam mówić o "wyciekach" pamięci @@ -300,338 +298,15 @@ \item Intuicyjność \item Materiały \item Zasoby (Assety) - \item Dostępne funkcje} - \item ChatGPT + \item Dostępne funkcje \end{itemize} \end{frame} - \documentclass{beamer} - \usepackage[fontsize=20pt]{fontsize} - \usepackage{graphicx} - \usepackage{tikz} - \usepackage{svg} - \usepackage[polish]{babel} - \graphicspath{ {./images/} } - \usetheme{Warsaw} - - %Information to be included in the title page: - - % Custom title page layout adjustments - \title{\large Porównanie wydajności i możliwości współczesnych silników do gier komputerowych} - \author{Krzysztof Rudnicki} - \institute{ - \textbf{Promotor} \\ - dr inż. Michał Chwesiuk - } - \date{\scriptsize \today} % Adjust the font size here - - - \setbeamertemplate{footline}[frame number]{} - \beamertemplatenavigationsymbolsempty - \setbeamertemplate{headline}{} - - - - - - - \begin{document} - - \begin{frame} - \vspace{-0.5cm} % Adjust vertical space above title - \maketitle - % Alternatively, use a completely custom layout: - %\begin{center} - % {\Large\inserttitle\par} - % \vskip1em - % {\insertauthor\par} - % \vskip1em - % {\insertinstitute\par} - % \vskip1em - % {\insertdate\par} - %\end{center} - \end{frame} - - \begin{frame} - \frametitle{Plan prezentacji} - \tableofcontents - \end{frame} - - \section{Teoria} - \begin{frame} - \frametitle{Gra komputerowa} - \large Aplikacja dostępna na platformie "Steam" oznaczona typem "Game" - \end{frame} - \begin{frame} - \frametitle{Silnik do gier} - \large Oprogramowanie zaprojektowane i stworzone do kreacji gier komputerowych - \end{frame} - - \begin{frame} - \frametitle{Nowoczesne} - \large Ponad 1000 gier w tej dekadzie na platformie "Steam" - \end{frame} - - - { - \setbeamercolor{footline}{fg=white} - \usebackgroundtemplate{\includegraphics[width=\paperwidth, height=\paperheight]{steamdb_main.png}} - \begin{frame} - \end{frame} - } - - - { - \usebackgroundtemplate{\includegraphics[width=\paperwidth, height=\paperheight]{steamdb_filter.drawio.pdf}} - \begin{frame} - \end{frame} - } - - \begin{frame} - \frametitle{Wybrane silniki - start} - \begin{center} - \includegraphics[width=0.8\paperwidth, height=0.8\paperheight]{usedEngines.pdf} - \end{center} - \end{frame} - - \begin{frame} - \frametitle{Wybrane silniki} - \begin{itemize} - \item Wyeliminowanie nie generycznych - Ren'Py, RPGMaker - \item Wybór najpopularniejszych - Unity, Unreal - % Prawie 25k i ponad 7.5k - \end{itemize} - \end{frame} - - \begin{frame} - \frametitle{Wydajność silnika} - \begin{itemize} - \item Klatki na sekundę (FPS) - \item Zużycie CPU, GPU, RAM i VRAM - \item Liczba draw calls - \item Czas ładowania assetów - \item Czas odpowiedzi na interakcję gracza - \end{itemize} - \end{frame} - \begin{frame} - \frametitle{Możliwości Silnika} - \begin{itemize} - \item Renderowanie grafiki - % Ray tracing, HDR lighting, dynamic shadows, particle systems, animacja - \item Silnik Fizyczny - \item Multiplatformowość (VR) - % Linux, Windows, MacOS, Android, IOs, Xbox, PlayStation, Nintendo, VR - \item Skryptowanie logiki gier (AI) - \item Gry online - \item Sklepy z assetami - \end{itemize} - \end{frame} - \section{Narzędzia} - \frametitle{Unity Profiler} - { - \setbeamercolor{footline}{fg=white} - \usebackgroundtemplate{ - \includegraphics[width=\paperwidth, height=\paperheight] - {unity_profiler.png}} - \begin{frame} - \end{frame} - } - - \frametitle{Unreal Profiler} - { - \setbeamercolor{footline}{fg=white} - \usebackgroundtemplate{ - \includegraphics[width=\paperwidth, height=\paperheight] - {unreal_profiler.jpg}} - \begin{frame} - \end{frame} - } - - \begin{frame} - \frametitle{Nsight - Analiza FPS} - \center - \includegraphics[width=1\textwidth]{fps_overview.png} - % Ile klatek pokazaliśmy na ile - % ile trwała średnio klatka - % Ile trwała najkrótsza klatka - % Ile trwała najdłuższa klatka - % Przeciętne klatki na sekundę dla pokazanego wycinka - % Tyle lub mniej czasu trwało 99% klatek - \end{frame} - - \begin{frame} - \frametitle{Nsight - Analiza FPS} - \center - \includegraphics[width=1\textwidth]{stutter_row.png} - % Wykrywanie "zawieszek" - % Wykrywamy klatki których długość - % jest znacznie dłuższa od długości mediany pobliskich 19 klatek - % zawieszka musi być dłuższa niż 4 milisekundy - \end{frame} - - \begin{frame} - \frametitle{Nsight - Analiza FPS} - \center - \includegraphics[width=1\textwidth]{dx12_frame_health.png} - % Możemy sprawdzić jaka klatka miała zawieszkę - % I jaka metoda w api tę zawieszkę spowodowała - \end{frame} - - \begin{frame} - \frametitle{Nsight - Zużycie VRAM} - \center - \includegraphics[width=1\textwidth]{memory_utilization.png} - % Zielony -> ile pamięci mamy dostępnej - % Pomarańczowy -> ile pamięci zużyliśmy - \end{frame} - - \begin{frame} - \frametitle{Nsight - Zużycie VRAM} - \center - \includegraphics[width=1\textwidth]{memory_utilization_gpu_vram.png} - % VidMm Device Suspension -> okresy czasku kiedy przetransferowano - % Jeden duży zasób pamięci - % Demoted Memory -> w GPU mamy local memory (szybsze) i global memory - % (wolniejsze) to może nam mówić o "wyciekach" pamięci - % źle zooptymalizowanej pamięci itd. - % Allokacja pamięci -> zielone aplikacja, szare -> system - \end{frame} - - \begin{frame} - \frametitle{Nsight - Zużycie VRAM} - \center - \includegraphics[width=1\textwidth]{memory_utilization_resource_migrations.png} - % W kolejności co najwięcej zużyło zasobów - % Konkretnie ile i kiedy - \end{frame} - - \begin{frame} - \frametitle{Nsight - Zużycie VRAM} - \center - \includegraphics[width=1\textwidth]{memory_utilization_memory_transfer.png} - % W kolejności co najwięcej zużyło zasobów - % Konkretnie ile i kiedy - \end{frame} - - \begin{frame} - \frametitle{Jak porównywać?} - \begin{itemize} - \item Stworzenie gry na obu - \item Porównywanie istniejących gier - \item Porównanie samych edytorów - \end{itemize} - \end{frame} - - { - \setbeamercolor{footline}{fg=white} - \usebackgroundtemplate{ - \includegraphics[width=\paperwidth, height=\paperheight] - {maxresdefault (1).jpg}} - \begin{frame} - \end{frame} - } - - \begin{frame} - \frametitle{Wybór gatunku} - FPS: - \begin{itemize} - \item Wystarczająco skomplikowany - \item Grafika - \item Fizyka - \item Klasyczny benchmark - % Wolfenstein, Doom, Quake, Crysis - \end{itemize} - \end{frame} - \begin{frame} - \frametitle{Problem} - Inklinacja Silnika \\ - \begin{itemize} - \item $ \frac{2478}{39713} \approx 6\% $ gier Unity to FPS \\ - \item $ \frac{1765}{11158} \approx 15\% $ gier Unreal to FPS \\ - \end{itemize} - Źródło: steamdb.info - \end{frame} - - \begin{frame} - \frametitle{Wybór gatunku} - Bullet hell: - \begin{itemize} - \item Wystarczająco skomplikowany - \item Grafika - \item Czas jest ważny - % W Bullet hell czas jest ważny, gra musi być płynna - \end{itemize} - \end{frame} - - { - \setbeamercolor{footline}{fg=white} - \usebackgroundtemplate{ - \includegraphics[width=\paperwidth, height=\paperheight] - {maxresdefault.jpg}} - \begin{frame} - \end{frame} - } - \begin{frame} - \frametitle{Wyzwania} - \begin{itemize} - \item Sprzęt - % Ten sam, jeden i ten sam komputer użyty w procesie kreacji obu - \item Umiejętności - % Nie mam - \item Podobne wersje silnika - % Użyje ostatniego LTS - \item Inklinacja Silnika \\ (3\% Unity, 2.4\% Unreal) - % ??? Ch - % 1577 FPS UNITY, 271 FPS UNREAL - % 39713 Total Unity, 11158 Total Unreal (proporcjonalnie 2 razy więcej :<) - \end{itemize} - \end{frame} - - \begin{frame} - \frametitle{Ocena łatwości użycia} - \begin{itemize} - \item Dokumentacja - \item Intuicyjność - \item Materiały - \item Zasoby (Assety) - \item Dostępne funkcje} - \item ChatGPT - \end{itemize} - \end{frame} - - - - \begin{frame} - \frametitle{Po stworzeniu} - Przejść obie gry, monitorując używając Nvidia Nsight i porównać wyniki - \end{frame} - - - \section{Źródła} - \begin{frame} - \frametitle{Źródła} - \begin{itemize} - \item \href{https://steamdb.info/}{https://steamdb.info/} - \item \href{https://docs.nvidia.com/nsight-systems}{https://docs.nvidia.com/nsight-systems} - \item An Overview Study of Game Engines, Faizi Noor Ahmad - \item Game Engine Architecture, Jason Gregory - \end{itemize} - \end{frame} - - \begin{frame} - \frametitle{Źródła obrazów} - \begin{itemize} - \item Crysis - kanał youtube \href{https://www.youtube.com/watch?v=vGjOALIrL_U}{Thronefull} - \item BulletHell - kanał youtube \href{https://www.youtube.com/watch?app=desktop&v=h-wr6LoETA0}{Beat that boss} - \end{itemize} - \end{frame} - - \end{document} - + \begin{frame} \frametitle{Po stworzeniu} - Przejść obie gry, monitorując używając Nvidia Nsight i porównać wyniki + Przejść obie gry, monitorując przy użyciu Nvidia Nsight i porównać wyniki \end{frame} @@ -654,4 +329,4 @@ \end{itemize} \end{frame} -\end{document} +\end{document} \ No newline at end of file diff --git a/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/1.png b/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/1.png new file mode 100644 index 00000000..f7d838c7 Binary files /dev/null and b/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/1.png differ diff --git a/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/2.png b/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/2.png new file mode 100644 index 00000000..2e4c9185 Binary files /dev/null and b/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/2.png differ diff --git a/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/3.png b/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/3.png new file mode 100644 index 00000000..3e7cb278 Binary files /dev/null and b/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/3.png differ diff --git a/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/4.png b/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/4.png new file mode 100644 index 00000000..e2e246a3 Binary files /dev/null and b/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/4.png differ diff --git a/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/5.png b/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/5.png new file mode 100644 index 00000000..21d984c2 Binary files /dev/null and b/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/5.png differ diff --git a/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/6.png b/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/6.png new file mode 100644 index 00000000..39bd7734 Binary files /dev/null and b/NotProgramming/SDM2/presentations/my_thesis/obrazki_do_pokazania/6.png differ diff --git a/NotProgramming/SPD/lab1/assets/glosnosc_40.png b/NotProgramming/SPD/lab1/assets/glosnosc_40.png new file mode 100644 index 00000000..d9bdfcb9 Binary files /dev/null and b/NotProgramming/SPD/lab1/assets/glosnosc_40.png differ diff --git a/NotProgramming/SPD/lab1/assets/glosnosc_60.png b/NotProgramming/SPD/lab1/assets/glosnosc_60.png new file mode 100644 index 00000000..d1da9733 Binary files /dev/null and b/NotProgramming/SPD/lab1/assets/glosnosc_60.png differ diff --git a/NotProgramming/SPD/lab1/assets/glosnosc_80.png b/NotProgramming/SPD/lab1/assets/glosnosc_80.png new file mode 100644 index 00000000..041214a4 Binary files /dev/null and b/NotProgramming/SPD/lab1/assets/glosnosc_80.png differ diff --git a/NotProgramming/SPD/lab1/assets/sony.png b/NotProgramming/SPD/lab1/assets/sony.png new file mode 100644 index 00000000..9c7a1d91 Binary files /dev/null and b/NotProgramming/SPD/lab1/assets/sony.png differ diff --git a/NotProgramming/SPD/lab1/assets/szum_0.png b/NotProgramming/SPD/lab1/assets/szum_0.png new file mode 100644 index 00000000..ea326e2f Binary files /dev/null and b/NotProgramming/SPD/lab1/assets/szum_0.png differ diff --git a/NotProgramming/SPD/lab1/assets/szum_20.png b/NotProgramming/SPD/lab1/assets/szum_20.png new file mode 100644 index 00000000..a11fafde Binary files /dev/null and b/NotProgramming/SPD/lab1/assets/szum_20.png differ diff --git a/NotProgramming/SPD/lab1/assets/szum_40.png b/NotProgramming/SPD/lab1/assets/szum_40.png new file mode 100644 index 00000000..d555180b Binary files /dev/null and b/NotProgramming/SPD/lab1/assets/szum_40.png differ diff --git a/NotProgramming/SPD/lab1/assets/ton_40.png b/NotProgramming/SPD/lab1/assets/ton_40.png new file mode 100644 index 00000000..0276f1df Binary files /dev/null and b/NotProgramming/SPD/lab1/assets/ton_40.png differ diff --git a/NotProgramming/SPD/lab1/assets/ton_60.png b/NotProgramming/SPD/lab1/assets/ton_60.png new file mode 100644 index 00000000..1ecaefe3 Binary files /dev/null and b/NotProgramming/SPD/lab1/assets/ton_60.png differ diff --git a/NotProgramming/SPD/lab1/assets/ton_80.png b/NotProgramming/SPD/lab1/assets/ton_80.png new file mode 100644 index 00000000..250adc23 Binary files /dev/null and b/NotProgramming/SPD/lab1/assets/ton_80.png differ diff --git a/NotProgramming/SPD/lab1/main.pdf b/NotProgramming/SPD/lab1/main.pdf new file mode 100644 index 00000000..8b29e39f Binary files /dev/null and b/NotProgramming/SPD/lab1/main.pdf differ diff --git a/NotProgramming/SPD/lab1/main.tex b/NotProgramming/SPD/lab1/main.tex new file mode 100644 index 00000000..f98644cc --- /dev/null +++ b/NotProgramming/SPD/lab1/main.tex @@ -0,0 +1,168 @@ +\documentclass[12pt]{article} +\usepackage[polish]{babel} +\usepackage[utf8]{inputenc} +\usepackage{array} +\usepackage{float} +\usepackage{graphicx} % Add this line to include graphics +\graphicspath{ {./assets/} } + +\title{SPD Lab 1 Głośność} +\author{Krzysztof Rudnicki, 307585} +\date{\today} + +\begin{document} + +\maketitle + + +\section{Krzywe poziomu głośności} +\begin{center} + \begin{tabular}{ | >{\arraybackslash}m{3cm} | l | l | l | l | l | l | l | l | } + \hline + & \multicolumn{8}{c|}{Częstotliwość f tonu regulowanego (Hz)} \\ \hline + Poziom tonu odniesienia 1000 Hz (dB) & 125 & 250 & 500 & 1000 & 1500 & 2000 & 3000 & 4000 \\ + \hline + 40 & 62 & 52 & 46 & 40 & 32 & 34 & 26 & 40 \\ + \hline + 60 & 62 & 56 & 58 & 60 & 50 & 46 & 38 & 52 \\ + \hline + 80 & 78 & 70 & 78 & 80 & 74 & 70 & 58 & 68 \\ + \hline + \end{tabular} + \end{center} + \begin{figure}[H] + \centering + \includegraphics[width=\textwidth]{glosnosc_40.png} + \caption{Krzywa poziomu głośności dla 40 dB} + \end{figure} + \begin{figure}[H] + \centering + \includegraphics[width=\textwidth]{glosnosc_60.png} + \caption{Krzywa poziomu głośności dla 60 dB} + \end{figure} + \begin{figure}[H] + \centering + \includegraphics[width=\textwidth]{glosnosc_80.png} + \caption{Krzywa poziomu głośności dla 80 dB} + \end{figure} + +\newpage +\section{Sony} +Poziomy [fony] Poziomy [dB] i macierz ocen: +\begin{verbatim} +ans = + Columns 1 through 11 + 30.0000 30.0083 30.0000 30.0000 30.0000 + 30.0000 30.0000 30.0000 30.0000 33.0000 + 30.0000 40.0000 40.0100 35.0000 30.0000 + 35.0000 30.0000 35.0000 30.0000 30.0000 + 30.0000 35.0000 50.0000 50.0110 50.0000 + 30.0000 40.0000 35.0000 35.0000 40.0000 + 40.0000 35.0000 40.0000 60.0000 60.0116 + 0.0000 35.0000 41.0000 46.0000 40.0000 + 50.0000 49.0000 40.0000 40.0000 70.0000 + 70.0119 40.0000 40.0000 45.0000 45.0000 + 50.0000 70.0000 45.0000 50.0000 60.0000 + 80.0000 80.0121 80.0000 65.0000 75.0000 + 75.0000 56.0000 50.0000 50.0000 55.0000 + 55.0000 + + Columns 12 through 22 + 30.0000 30.0000 28.0000 30.0000 32.0000 + 30.0000 25.0000 30.0000 30.0000 30.0000 + 29.0000 39.0000 30.0000 40.0000 30.0000 + 35.0000 30.0000 30.0000 35.0000 30.0000 + 35.0000 33.0000 30.0000 39.0000 38.0000 + 30.0000 35.0000 35.0000 30.0000 45.0000 + 40.0000 39.0000 30.0000 33.0000 35.0000 + 40.0000 35.0000 35.0000 40.0000 40.0000 + 35.0000 38.0000 55.0000 30.0000 40.0000 + 55.0000 45.0000 45.0000 40.0000 40.0000 + 60.0000 40.0000 45.0000 48.0000 65.0000 + 50.0000 60.0000 78.0000 78.0000 45.0000 + 45.0000 80.0000 70.0000 55.0000 75.0000 + 60.0000 + + Columns 23 through 32 + 30.0000 29.0000 28.0000 30.0000 29.0000 + 29.0000 30.0000 30.0000 30.0000 30.0000 + 30.0000 30.0000 40.0000 38.0000 30.0000 + 30.0000 35.0000 29.0000 30.0000 40.0000 + 40.0000 40.0000 37.0000 30.0000 30.0000 + 35.0000 36.0000 35.0000 30.0000 40.0000 + 40.0000 40.0000 45.0000 39.0000 45.0000 + 60.0000 40.0000 50.0000 36.0000 35.0000 + 40.0000 45.0000 55.0000 40.0000 42.0000 + 45.0000 50.0000 60.0000 45.0000 5.0000 + 65.0000 75.0000 50.0000 45.0000 70.0000 + 65.0000 55.0000 70.0000 70.0000 60.0000 +\end{verbatim} +\begin{figure}[H] + \centering + \includegraphics[width=\textwidth]{sony.png} + \caption{Macierz ocen Sony} +\end{figure} +\begin{table}[H] +\centering +\begin{tabular}{|c|c|c|c|c|} +\hline +Poziomy [fony] & Poziomy [dB] & Oceny średnie & Zakres minus & Zakres plus \\ \hline +30.0000 & 30.0083 & 29.7054 & 28.4096 & 31.0602 \\ \hline +40.0000 & 40.0100 & 32.7776 & 29.4227 & 36.5149 \\ \hline +50.0000 & 50.0110 & 35.9764 & 31.4093 & 41.2075 \\ \hline +60.0000 & 60.0116 & 40.4154 & 34.6291 & 47.1686 \\ \hline +70.0000 & 70.0119 & 43.8832 & 28.2547 & 68.1563 \\ \hline +80.0000 & 80.0121 & 61.7038 & 51.2020 & 74.3595 \\ \hline +\end{tabular} +\end{table} + +\begin{table}[H] +\centering +\begin{tabular}{|c|c|c|c|c|} +\hline +Poziomy [fony] & Poziomy [dB] & Wartości w sonach & Zakres minus & Zakres plus \\ \hline +30.0000 & 30.0083 & 0.9163 & 0.8764 & 0.9581 \\ \hline +40.0000 & 40.0100 & 1.0111 & 0.9076 & 1.1264 \\ \hline +50.0000 & 50.0110 & 1.1098 & 0.9689 & 1.2712 \\ \hline +60.0000 & 60.0116 & 1.2467 & 1.0682 & 1.4550 \\ \hline +70.0000 & 70.0119 & 1.3537 & 0.8716 & 2.1025 \\ \hline +80.0000 & 80.0121 & 1.9034 & 1.5795 & 2.2938 \\ \hline +\end{tabular} +\end{table} + +\section{$\Delta L$} +\subsection{$\Delta L$ szum} +\begin{figure}[H] + \centering + \includegraphics[width=\textwidth]{szum_0.png} + \caption{$\Delta L$ szum 0 dB} +\end{figure} +\begin{figure}[H] + \centering + \includegraphics[width=\textwidth]{szum_20.png} + \caption{$\Delta L$ szum 20 dB} +\end{figure} +\begin{figure}[H] + \centering + \includegraphics[width=\textwidth]{szum_40.png} + \caption{$\Delta L$ szum 40 dB} +\end{figure} + +\subsection{$\Delta L$ ton} +\begin{figure}[H] + \centering + \includegraphics[width=\textwidth]{ton_40.png} + \caption{$\Delta L$ ton 40 dB} +\end{figure} +\begin{figure}[H] + \centering + \includegraphics[width=\textwidth]{ton_60.png} + \caption{$\Delta L$ ton 60 dB} +\end{figure} +\begin{figure}[H] + \centering + \includegraphics[width=\textwidth]{ton_80.png} + \caption{$\Delta L$ ton 80 dB} +\end{figure} + +\end{document} \ No newline at end of file diff --git a/NotProgramming/SPD/lab2_spd/lab2.drawio b/NotProgramming/SPD/lab2_spd/lab2.drawio new file mode 100644 index 00000000..a7b7307a --- /dev/null +++ b/NotProgramming/SPD/lab2_spd/lab2.drawio @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/NotProgramming/SPD/lab2_spd/lab2_1.drawio b/NotProgramming/SPD/lab2_spd/lab2_1.drawio new file mode 100644 index 00000000..b025fbca --- /dev/null +++ b/NotProgramming/SPD/lab2_spd/lab2_1.drawio @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/NotProgramming/SPD/lab2_spd/lab2_2.drawio b/NotProgramming/SPD/lab2_spd/lab2_2.drawio new file mode 100644 index 00000000..c1c34522 --- /dev/null +++ b/NotProgramming/SPD/lab2_spd/lab2_2.drawio @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/NotProgramming/SPD/lab2_spd/lab2_3.drawio b/NotProgramming/SPD/lab2_spd/lab2_3.drawio new file mode 100644 index 00000000..9f6b5f1e --- /dev/null +++ b/NotProgramming/SPD/lab2_spd/lab2_3.drawio @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/NotProgramming/SPD/lab2_spd/lab4 b/NotProgramming/SPD/lab2_spd/lab4 new file mode 100644 index 00000000..ba265b2b --- /dev/null +++ b/NotProgramming/SPD/lab2_spd/lab4 @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/NotProgramming/SPD/lab4_spd/main.py b/NotProgramming/SPD/lab4_spd/main.py new file mode 100644 index 00000000..b50d9926 --- /dev/null +++ b/NotProgramming/SPD/lab4_spd/main.py @@ -0,0 +1,128 @@ +import matplotlib.pyplot as plt + +# Prepare the datasets +datasets_200Hz = [] +datasets_400Hz = [] + +# Dataset 1: Wieloton 200 Hz, 7 (1400 Hz), 3 składowe +# Starting x value is 1400 Hz +datasets_200Hz.append({ + 'name': '200 Hz, 7 (1400 Hz), 3 składowe', + 'x': [1400 + 0, 1400 + 50, 1400 + 100, 1400 + 150], + 'y': [200, 200, 215, 230] +}) + +# Dataset 2: Wieloton 200 Hz, 7 (1400 Hz), 7 składowych +datasets_200Hz.append({ + 'name': '200 Hz, 7 (1400 Hz), 7 składowych', + 'x': [1400 + 0, 1400 + 50, 1400 + 100, 1400 + 150], + 'y': [190, 190, 200, 195] +}) + +# Dataset 3: Wieloton 200 Hz, 10 (2000 Hz), 3 składowe +# Starting x value is 2000 Hz +datasets_200Hz.append({ + 'name': '200 Hz, 10 (2000 Hz), 3 składowe', + 'x': [2000 + 0, 2000 + 50, 2000 + 100, 2000 + 150], + 'y': [225, 215, 220, 265] +}) + +# Dataset 4: Wieloton 200 Hz, 10 (2000 Hz), 7 składowych +datasets_200Hz.append({ + 'name': '200 Hz, 10 (2000 Hz), 7 składowych', + 'x': [2000 + 0, 2000 + 50, 2000 + 100, 2000 + 150], + 'y': [190, 205, 205, 210] +}) + +# Dataset 4: Wieloton 200 Hz, 10 (2000 Hz), 7 składowych +datasets_200Hz.append({ + 'name': 'Shouten - 7', + 'x': [1400 + 0, 1400 + 50, 1400 + 100, 1400 + 150], + 'y': [200, 207.5, 214, 222] +}) + +# Dataset 4: Wieloton 200 Hz, 10 (2000 Hz), 7 składowych +datasets_200Hz.append({ + 'name': 'Shouten - 10', + 'x': [2000 + 0, 2000 + 50, 2000 + 100, 2000 + 150], + 'y': [200, 205, 210, 215] +}) + + + +# Dataset 5: Wieloton 400 Hz, 7 (2800 Hz), 3 składowe +# Starting x value is 2800 Hz +datasets_400Hz.append({ + 'name': '400 Hz, 7 (2800 Hz), 3 składowe', + 'x': [2800 + 0, 2800 + 100, 2800 + 200, 2800 + 300], + 'y': [405, 410, 410, 405] +}) + +# Dataset 6: Wieloton 400 Hz, 7 (2800 Hz), 7 składowych +datasets_400Hz.append({ + 'name': '400 Hz, 7 (2800 Hz), 7 składowych', + 'x': [2800 + 0, 2800 + 100, 2800 + 200, 2800 + 300], + 'y': [410, 420, 420, 425] +}) + +# Dataset 7: Wieloton 400 Hz, 10 (4000 Hz), 3 składowe +# Starting x value is 4000 Hz +datasets_400Hz.append({ + 'name': '400 Hz, 10 (4000 Hz), 3 składowe', + 'x': [4000 + 0, 4000 + 100, 4000 + 200, 4000 + 300], + 'y': [407, 419, 425, 425] +}) + +# Dataset 8: Wieloton 400 Hz, 10 (4000 Hz), 7 składowych +# Note: The last two 'Wynik [Hz]' values seem inconsistent. +# They are much lower than expected based on prior values. +# Assuming there might be typos, and they should be 2200 and 2400 +# instead of 220 and 240. +datasets_400Hz.append({ + 'name': '400 Hz, 10 (4000 Hz), 7 składowych', + 'x': [4000 + 0, 4000 + 100, 4000 + 200, 4000 + 300], + 'y': [405, 410, 415, 415] # Original data +}) + +datasets_400Hz.append({ + 'name': 'Shouten - 7', + 'x': [2800 + 0, 2800 + 100, 2800 + 200, 2800 + 300], + 'y': [400, 414, 428, 443] +}) + + +datasets_400Hz.append({ + 'name': 'Shouten - 10', + 'x': [4000 + 0, 4000 + 100, 4000 + 200, 4000 + 300], + 'y': [400, 410, 420, 430] # Original data +}) + +# Plot the data for 200 Hz +plt.figure(figsize=(12, 8)) +for dataset in datasets_200Hz: + if 'Shouten' in dataset['name']: + plt.plot(dataset['x'], dataset['y'], marker='s', color='red', label=dataset['name']) # Shouten datasets + else: + plt.plot(dataset['x'], dataset['y'], marker='o', label=dataset['name']) # Other datasets +plt.xlabel('Frequency [Hz]') +plt.ylabel('Result [Hz]') +plt.title('Combined Graph of Results for 200 Hz') +plt.legend() +plt.grid(True) +plt.savefig('results_200Hz.png') # Save the plot +plt.show() + +# Plot the data for 400 Hz +plt.figure(figsize=(12, 8)) +for dataset in datasets_400Hz: + if 'Shouten' in dataset['name']: + plt.plot(dataset['x'], dataset['y'], marker='s', color='red', label=dataset['name']) # Shouten datasets + else: + plt.plot(dataset['x'], dataset['y'], marker='o', label=dataset['name']) # Other datasets +plt.xlabel('Frequency [Hz]') +plt.ylabel('Result [Hz]') +plt.title('Combined Graph of Results for 400 Hz') +plt.legend() +plt.grid(True) +plt.savefig('results_400Hz.png') # Save the plot +plt.show() \ No newline at end of file diff --git a/NotProgramming/SPD/lab4_spd/results_200Hz.png b/NotProgramming/SPD/lab4_spd/results_200Hz.png new file mode 100644 index 00000000..c04317ed Binary files /dev/null and b/NotProgramming/SPD/lab4_spd/results_200Hz.png differ diff --git a/NotProgramming/SPD/lab4_spd/results_400Hz.png b/NotProgramming/SPD/lab4_spd/results_400Hz.png new file mode 100644 index 00000000..6f8b2dae Binary files /dev/null and b/NotProgramming/SPD/lab4_spd/results_400Hz.png differ diff --git a/NotProgramming/SPD/spd3/cw1.png b/NotProgramming/SPD/spd3/cw1.png new file mode 100644 index 00000000..c7c4f73f Binary files /dev/null and b/NotProgramming/SPD/spd3/cw1.png differ diff --git a/NotProgramming/SPD/spd3/main.py b/NotProgramming/SPD/spd3/main.py new file mode 100644 index 00000000..fab8d2fa --- /dev/null +++ b/NotProgramming/SPD/spd3/main.py @@ -0,0 +1,136 @@ +import matplotlib.pyplot as plt + +# Values 1 +x1 = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6] +y1 = [33.2, 35.48, 27.67, 19.41, 15.3, 15.44, 13.59] + +# Values 2 +x2 = [0.4, 0.5, 0.6, 0.7] +y2 = [13.29, 11.25, 12.55, 13.26] + +# Values 3 +x3 = [0.4, 0.5, 0.6, 0.7] +y3 = [22.06, 15.48, 18.74, 17.71] + +# Create the plot +plt.figure(figsize=(10, 6)) + +# Plot each line with different styles +plt.plot(x1, y1, marker='o', linestyle='-', color='blue', label='symetrycznie 500 Hz') +plt.plot(x2, y2, marker='s', linestyle='--', color='green', label='asymetrycznie 550 Hz') +plt.plot(x3, y3, marker='^', linestyle='-.', color='red', label='asymetrycznie 450 Hz') + +# Add labels and title +plt.xlabel('parametr g', fontsize=40) +plt.ylabel('Prod detekcji syngalu [dB]', fontsize=40) +plt.title('500 Hz', fontsize=48) + +# Add a legend +plt.legend(fontsize=32) + +# Optional: Add gridlines +plt.grid(True) +plt.xticks(fontsize=32) +plt.yticks(fontsize=32) + +# Display the plot +plt.show() + +# Values 1 +x1 = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6] +y1 = [33.06, 35.28, 23.33, 17.14, 14.33, 10.01, 4.43] + +# Values 2 +x2 = [0.4, 0.5, 0.6, 0.7] +y2 = [15.22, 8.16, 6.45, 6.27] + +# Values 3 +x3 = [0.4, 0.5, 0.6, 0.7] +y3 = [13.0, 13.06, 7.8, 1.7] + +# Create the plot +plt.figure(figsize=(10, 6)) + +# Plot each line with different styles +plt.plot(x1, y1, marker='o', linestyle='-', color='blue', label='symetrycznie 1500 Hz') +plt.plot(x2, y2, marker='s', linestyle='--', color='green', label='asymetrycznie 1650 Hz') +plt.plot(x3, y3, marker='^', linestyle='-.', color='red', label='asymetrycznie 1350 Hz') + +# Add labels and title +plt.xlabel('parametr g', fontsize=40) +plt.ylabel('Prod detekcji syngalu [dB]', fontsize=40) +plt.title('1500 Hz', fontsize=48) + +# Add a legend +plt.legend(fontsize=32) + +# Optional: Add gridlines +plt.grid(True) +plt.xticks(fontsize=32) +plt.yticks(fontsize=32) + +# Display the plot +plt.show() + +# Values 1 +x1 = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6] +y1 = [33.2, 35.48, 27.67, 19.41, 15.3, 15.44, 13.59] + +# Values 2 +x2 = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6] +y2 = [33.06, 35.28, 23.33, 17.14, 14.33, 10.01, 4.43] + +# Create the plot +plt.figure(figsize=(10, 6)) + +# Plot each line with different styles +plt.plot(x1, y1, marker='o', linestyle='-', color='blue', label='symetrycznie 500 Hz') +plt.plot(x2, y2, marker='s', linestyle='--', color='green', label='symetrycznie 1500 Hz') + +# Add labels and title +plt.xlabel('parametr g', fontsize=40) +plt.ylabel('Prod detekcji syngalu [dB]', fontsize=40) +plt.title('500 Hz vs 1500 Hz', fontsize=48) + +# Add a legend +plt.legend(fontsize=32) + +# Optional: Add gridlines +plt.grid(True) +plt.xticks(fontsize=32) +plt.yticks(fontsize=32) + +# Display the plot +plt.show() + +# Values 1 +x1 = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6] +y1 = [33.2, 35.48, 27.67, 19.41, 15.3, 15.44, 13.59] + +# Values 2 +x2 = [0.005, 0.01, 0.02, 0.05, 0.1, 0.3] +y2 = [81.59, 60.08, 68.48, 58.77, 53.6, 55.46] + +# Create the plot +plt.figure(figsize=(10, 6)) + +# Plot each line with different styles +plt.plot(x1, y1, marker='o', linestyle='-', color='blue', label='pasmowy 500 Hz') +plt.plot(x2, y2, marker='s', linestyle='--', color='green', label='pasmowo-zaporowy 500 Hz') + +# Add labels and title +plt.xlabel('parametr g', fontsize=40) +plt.ylabel('Prod detekcji syngalu [dB]', fontsize=40) +plt.title('Porownanie szum pasmowy vs szum pasmowo zaporowy dla 500 Hz', fontsize=48) + +# Add a legend +plt.legend(fontsize=32) + +# Optional: Add gridlines +plt.grid(True) +plt.xticks(fontsize=32) +plt.yticks(fontsize=32) + +# Display the plot +plt.show() + diff --git a/NotProgramming/SPD/spd_5/gco.png b/NotProgramming/SPD/spd_5/gco.png new file mode 100644 index 00000000..ecffc876 Binary files /dev/null and b/NotProgramming/SPD/spd_5/gco.png differ diff --git a/NotProgramming/SPD/spd_5/lab5.png b/NotProgramming/SPD/spd_5/lab5.png new file mode 100644 index 00000000..8ecf74af Binary files /dev/null and b/NotProgramming/SPD/spd_5/lab5.png differ diff --git a/NotProgramming/SPD/spd_5/main.py b/NotProgramming/SPD/spd_5/main.py new file mode 100644 index 00000000..d3d6a5e8 --- /dev/null +++ b/NotProgramming/SPD/spd_5/main.py @@ -0,0 +1,42 @@ +import matplotlib.pyplot as plt +import numpy as np + +# Data +delta_t = np.array([500, 200, 100, 50, 20, 10, 5, 3]) +ton_60_db = [60, 60, 59, 58, 50, 46, 42, 39] +szum_20_db_per_hz = [20, 19, 18, 16, 12, 11, 8, 8] +ton_60_db_minus = [ton - 60 for ton in ton_60_db] +szum_20_db_per_hz_minus = [szum - 20 for szum in szum_20_db_per_hz] + +# Theoretical lines +delta_t_line = np.logspace(np.log10(3), np.log10(500), 100) +log_delta_t_line = np.log10(delta_t_line) + +# Equations in terms of log(delta_t) +# For Broadband Noise: y = 10 * log10(delta_t) - 25 +y_broadband_line = 10 * log_delta_t_line - 25 + +# For Pure Tone: y = 9 * log10(delta_t) - 19 +y_pure_tone_line = 9 * log_delta_t_line - 19 + +# Plotting +plt.figure(figsize=(10, 6)) + +# Plot the experimental data +plt.semilogx(delta_t, ton_60_db_minus, 'o', label='Ton eksperymentalny 60 dB') +plt.semilogx(delta_t, szum_20_db_per_hz_minus, 's', label='Szum eksperymentalny 20 dB/Hz') + +# Plot the theoretical lines +plt.semilogx(delta_t_line, y_pure_tone_line, label='Ton - krzywa teoretyczna') +plt.semilogx(delta_t_line, y_broadband_line, label='Szum - krzywa teoereyczna') + +plt.xlabel('Czas trwania sygnału [ms]', fontsize=40) +plt.ylabel('Poziom względny głośności [dB]', fontsize=40) +plt.title('Głośnośc vs czas', fontsize=48) +plt.legend(fontsize=32) +plt.grid(True, which="both", ls="--") + +plt.xticks(fontsize=32) +plt.yticks(fontsize=32) + +plt.show() \ No newline at end of file diff --git a/NotProgramming/SPD/spd_5/main2.py b/NotProgramming/SPD/spd_5/main2.py new file mode 100644 index 00000000..a6c95e5d --- /dev/null +++ b/NotProgramming/SPD/spd_5/main2.py @@ -0,0 +1,24 @@ +import matplotlib.pyplot as plt +import numpy as np + +# Data (decreasing values) +bandwidth = np.array([40, 100, 160, 300, 600, 1000]) +detection_threshold_600Hz = np.array([50, 30, 20, 12, 10, 8]) +detection_threshold_2200Hz = np.array([40, 25, 18, 10, 8, 7]) +detection_threshold_4400Hz = np.array([35, 22, 15, 9, 7, 6]) + +# Plot +plt.figure(figsize=(10, 6)) +plt.xscale('log') + +plt.scatter(bandwidth, detection_threshold_600Hz, label='600 Hz', marker='o') +plt.scatter(bandwidth, detection_threshold_2200Hz, label='2200 Hz', marker='^') +plt.scatter(bandwidth, detection_threshold_4400Hz, label='4400 Hz', marker='s') + +plt.xlabel('Szerokość pasma [Hz]') +plt.ylabel('Próg detekcji interwału ciszy [ms]') +plt.title('Górna częstotliwość odcięcia (GCO)') +plt.legend(title='GCO') + +plt.grid(True) +plt.show() \ No newline at end of file diff --git a/NotProgramming/SPD/spd_5/zad2.drawio b/NotProgramming/SPD/spd_5/zad2.drawio new file mode 100644 index 00000000..87b0714b --- /dev/null +++ b/NotProgramming/SPD/spd_5/zad2.drawio @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/NotProgramming/SPD/spd_5/zad3.drawio b/NotProgramming/SPD/spd_5/zad3.drawio new file mode 100644 index 00000000..b025fbca --- /dev/null +++ b/NotProgramming/SPD/spd_5/zad3.drawio @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-32-44.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-32-44.png new file mode 100644 index 00000000..a8f81ffb Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-32-44.png differ diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-33-07.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-33-07.png new file mode 100644 index 00000000..7a6ec55a Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-33-07.png differ diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-33-15.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-33-15.png new file mode 100644 index 00000000..422f70b5 Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-33-15.png differ diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-33-37.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-33-37.png new file mode 100644 index 00000000..d55e55eb Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-33-37.png differ diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-34-25.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-34-25.png new file mode 100644 index 00000000..30065e8a Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-34-25.png differ diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-34-58.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-34-58.png new file mode 100644 index 00000000..adec51b5 Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-34-58.png differ diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-07.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-07.png new file mode 100644 index 00000000..7a9ad9b2 Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-07.png differ diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-18.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-18.png new file mode 100644 index 00000000..46aebbc8 Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-18.png differ diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-22.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-22.png new file mode 100644 index 00000000..b7b1d5d8 Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-22.png differ diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-40.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-40.png new file mode 100644 index 00000000..e3d6a73b Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-40.png differ diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-49.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-49.png new file mode 100644 index 00000000..71ea66fb Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-35-49.png differ diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-36-05.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-36-05.png new file mode 100644 index 00000000..c7f878e6 Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-36-05.png differ diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-40-51.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-40-51.png new file mode 100644 index 00000000..30da2ba1 Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-40-51.png differ diff --git a/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-43-11.png b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-43-11.png new file mode 100644 index 00000000..fec2de2b Binary files /dev/null and b/Programming/PSD/zin2/report/images/Screenshot from 2025-04-10 15-43-11.png differ diff --git a/Programming/TRAK/.python-version b/Programming/TRAK/.python-version new file mode 100644 index 00000000..2c073331 --- /dev/null +++ b/Programming/TRAK/.python-version @@ -0,0 +1 @@ +3.11 diff --git a/Programming/TRAK/init.sh b/Programming/TRAK/init.sh new file mode 100755 index 00000000..d067ab25 --- /dev/null +++ b/Programming/TRAK/init.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +pyenv local 3.11 +python -m venv ./venv +source ./venv/bin/activate \ No newline at end of file diff --git a/Programming/TRAK/lab6.py b/Programming/TRAK/lab6.py new file mode 100644 index 00000000..10585d0a --- /dev/null +++ b/Programming/TRAK/lab6.py @@ -0,0 +1,4 @@ +import bpy +import os +script_path = '' # path to script +exec(compile(open(script_path).read(), script_path, 'exec')) diff --git a/Programming/TRAK/requirements.txt b/Programming/TRAK/requirements.txt new file mode 100644 index 00000000..dae63b37 --- /dev/null +++ b/Programming/TRAK/requirements.txt @@ -0,0 +1 @@ +bpy \ No newline at end of file diff --git a/Programming/WDWR/project/code/model.R b/Programming/WDWR/project/code/model.R new file mode 100644 index 00000000..dc64c82f --- /dev/null +++ b/Programming/WDWR/project/code/model.R @@ -0,0 +1,465 @@ +# Biblioteki +library(lpSolveAPI) +library(mvtnorm) +library(ggplot2) + +# Parametry problemu +set.seed(307585) # Numer zadania jako ziarno + +# 1. Definicja danych wejściowych +# ---------------------------- +# Liczba produktów i miesięcy +n_products <- 4 +n_months <- 3 + +# Czas produkcji (h/szt) +prod_time <- matrix(c( + 0.4, 0.6, 0, 0, # Szlifowanie + 0.2, 0.1, 0, 0.6, # Wiercenie pionowe + 0.1, 0, 0.7, 0, # Wiercenie poziome + 0.06, 0.04, 0, 0.05, # Frezowanie + 0, 0.05, 0.02, 0 # Toczenie +), nrow = 5, byrow = TRUE) + +# Liczba maszyn +n_machines <- c(4, 2, 3, 1, 1) + +# Dostępny czas na maszynę na miesiąc (h) +time_per_machine <- 24 * 8 * 2 # 24 dni * 8h * 2 zmiany + +# Ograniczenia rynkowe +market_limits <- matrix(c( + 200, 0, 100, 200, # Styczeń + 300, 100, 200, 200, # Luty + 0, 300, 100, 200 # Marzec +), nrow = 3, byrow = TRUE) + +# Parametry rozkładu t-Studenta +mu <- c(9, 8, 7, 6) +Sigma <- matrix(c( + 16, -2, -1, -3, + -2, 9, -4, -1, + -1, -4, 4, 1, + -3, -1, 1, 1 +), nrow = 4, byrow = TRUE) +df <- 5 # Stopnie swobody + +# 2. Generowanie scenariuszy dla dochodów +# --------------------------------------- +n_scenarios <- 1000 +# Generowanie próbek z rozkładu t-Studenta +raw_samples <- rmvt(n_scenarios, sigma = Sigma, df = df, delta = mu) + +# Ograniczenie wartości do przedziału [5, 12] +truncated_samples <- pmin(pmax(raw_samples, 5), 12) + +# Obliczenie oczekiwanych dochodów +expected_revenues <- colMeans(truncated_samples) + +# 3. Tworzenie modelu jednokryterialnego (maksymalizacja zysku) +# ----------------------------------------------------------- + +# Funkcja tworząca model optymalizacyjny z danym wektorem wag dla kryteriów +create_lp_model <- function(price_weights) { + # Indeksy zmiennych + idx_prod <- function(i, t) (t-1) * n_products + i + idx_sales <- function(i, t) n_months * n_products + (t-1) * n_products + i + idx_inv <- function(i, t) 2 * n_months * n_products + (t-1) * n_products + i + idx_over <- function(i, t) 3 * n_months * n_products + (t-1) * n_products + i + + # Liczba zmiennych: produkcja, sprzedaż, zapasy, flagi przekroczenia 80% + n_vars <- 4 * n_months * n_products + + # Utworzenie modelu + lp_model <- make.lp(0, n_vars) + + # Ustawienie typów zmiennych (over_i_t są binarne) + set.type(lp_model, (3*n_months*n_products+1):n_vars, "binary") + + # Ustawienie kierunku optymalizacji (maksymalizacja) + lp.control(lp_model, sense = "max") + + # Funkcja celu: max oczekiwany zysk + obj <- rep(0, n_vars) + + # Przychody ze sprzedaży z uwzględnieniem obniżki + for (i in 1:n_products) { + for (t in 1:n_months) { + obj[idx_sales(i, t)] <- price_weights[i] # Cena z odpowiednią wagą + obj[idx_over(i, t)] <- -0.2 * price_weights[i] * market_limits[t, i] # Kara za przekroczenie 80% + } + } + + # Koszty magazynowania + for (i in 1:n_products) { + for (t in 1:n_months) { + obj[idx_inv(i, t)] <- -1 # 1 zł za sztukę za miesiąc + } + } + + set.objfn(lp_model, obj) + + # Dodanie ograniczeń + + # 1. Ograniczenia czasowe maszyn + for (m in 1:5) { # Dla każdego typu maszyny + for (t in 1:n_months) { # Dla każdego miesiąca + row <- rep(0, n_vars) + for (i in 1:n_products) { # Dla każdego produktu + if (prod_time[m, i] > 0) { + row[idx_prod(i, t)] <- prod_time[m, i] + } + } + add.constraint(lp_model, row, "<=", n_machines[m] * time_per_machine) + } + } + + # 2. Bilanse magazynowe + for (i in 1:n_products) { + for (t in 1:n_months) { + row <- rep(0, n_vars) + + # Produkcja zwiększa zapas + row[idx_prod(i, t)] <- 1 + + # Sprzedaż zmniejsza zapas + row[idx_sales(i, t)] <- -1 + + # Zapas na koniec okresu + row[idx_inv(i, t)] <- 1 + + # Zapas z poprzedniego okresu + if (t > 1) { + row[idx_inv(i, t-1)] <- -1 + } + + # Dla t=1: inv_{i,0} = 0 (warunek początkowy) + if (t == 1) { + add.constraint(lp_model, row, "=", 0) + } else { + add.constraint(lp_model, row, "=", 0) + } + } + } + + # 3. Ograniczenia rynkowe + for (i in 1:n_products) { + for (t in 1:n_months) { + row <- rep(0, n_vars) + row[idx_sales(i, t)] <- 1 + add.constraint(lp_model, row, "<=", market_limits[t, i]) + } + } + + # 4. Ograniczenia pojemności magazynu + for (i in 1:n_products) { + for (t in 1:n_months) { + row <- rep(0, n_vars) + row[idx_inv(i, t)] <- 1 + add.constraint(lp_model, row, "<=", 200) + } + } + + # 5. Warunki końcowe (50 sztuk każdego produktu na koniec marca) + for (i in 1:n_products) { + row <- rep(0, n_vars) + row[idx_inv(i, 3)] <- 1 + add.constraint(lp_model, row, "=", 50) + } + + # 6. Ograniczenia dotyczące obniżki dochodu (flagi over_i_t) + big_m <- 10000 # Duża liczba dla metody Big-M + for (i in 1:n_products) { + for (t in 1:n_months) { + if (market_limits[t, i] > 0) { # Tylko dla produktów, które można sprzedać + # Ograniczenie: s_{i,t} >= 0.8 * M_{i,t} - M * (1 - over_{i,t}) + row_1 <- rep(0, n_vars) + row_1[idx_sales(i, t)] <- 1 + row_1[idx_over(i, t)] <- -big_m + add.constraint(lp_model, row_1, ">=", 0.8 * market_limits[t, i] - big_m) + + # Ograniczenie: s_{i,t} <= 0.8 * M_{i,t} + M * over_{i,t} + row_2 <- rep(0, n_vars) + row_2[idx_sales(i, t)] <- 1 + row_2[idx_over(i, t)] <- -big_m + add.constraint(lp_model, row_2, "<=", 0.8 * market_limits[t, i]) + } else { + # Dla produktów, których nie można sprzedać, ustalamy over_{i,t} = 0 + row <- rep(0, n_vars) + row[idx_over(i, t)] <- 1 + add.constraint(lp_model, row, "=", 0) + } + } + } + + return(lp_model) +} + +# Rozwiązanie modelu jednokryterialnego +print("Solving single-criterion model...") +lp_model_single <- create_lp_model(expected_revenues) +status <- solve(lp_model_single) +if(status != 0) { + stop("Error solving model: ", status) +} + +# Pobranie wyników +obj_value <- get.objective(lp_model_single) +solution <- get.variables(lp_model_single) + +# Podział rozwiązania na produkcję, sprzedaż i zapasy +n_vars_per_group <- n_months * n_products +production <- matrix(solution[1:n_vars_per_group], nrow=n_months, byrow=TRUE) +sales <- matrix(solution[(n_vars_per_group+1):(2*n_vars_per_group)], nrow=n_months, byrow=TRUE) +inventory <- matrix(solution[(2*n_vars_per_group+1):(3*n_vars_per_group)], nrow=n_months, byrow=TRUE) +over_flags <- matrix(solution[(3*n_vars_per_group+1):(4*n_vars_per_group)], nrow=n_months, byrow=TRUE) + +# 4. Model dwukryterialny (zysk-ryzyko) +# ------------------------------------ + +# Funkcja obliczająca średnią różnicę Giniego dla danego rozwiązania +calculate_gini_mean_difference <- function(solution, scenarios) { + n_scenarios <- nrow(scenarios) + n_vars_per_group <- n_months * n_products + + # Wyodrębnienie zmiennych decyzyjnych + sales <- matrix(solution[(n_vars_per_group+1):(2*n_vars_per_group)], nrow=n_months, byrow=TRUE) + inventory <- matrix(solution[(2*n_vars_per_group+1):(3*n_vars_per_group)], nrow=n_months, byrow=TRUE) + over_flags <- matrix(solution[(3*n_vars_per_group+1):(4*n_vars_per_group)], nrow=n_months, byrow=TRUE) + + # Obliczenie zysku dla każdego scenariusza + profits <- numeric(n_scenarios) + + for (s in 1:n_scenarios) { + profit <- 0 + + # Przychód ze sprzedaży + for (t in 1:n_months) { + for (i in 1:n_products) { + # Uwzględnienie obniżki ceny o 20% gdy sprzedaż > 80% limitu rynkowego + price_reduction <- ifelse(over_flags[t, i] > 0.5, 0.2, 0) + profit <- profit + scenarios[s, i] * sales[t, i] * (1 - price_reduction) + } + } + + # Koszty magazynowania + for (t in 1:n_months) { + for (i in 1:n_products) { + profit <- profit - inventory[t, i] + } + } + + profits[s] <- profit + } + + # Obliczenie średniej różnicy Giniego + gini <- 0 + for (i in 1:n_scenarios) { + for (j in 1:n_scenarios) { + gini <- gini + abs(profits[i] - profits[j]) * (1/n_scenarios) * (1/n_scenarios) + } + } + gini <- gini / 2 + + return(list(gini = gini, expected_profit = mean(profits))) +} + +# Generowanie punktów na krzywej efektywnej metodą ważonych kryteriów +generate_efficient_frontier <- function(scenarios, n_points = 20) { + lambda_values <- seq(0, 1, length.out = n_points) + results <- data.frame(lambda = lambda_values, expected_profit = NA, gini = NA) + solutions <- list() + + # Obliczenie wariancji dochodów dla użycia jako wagi ryzyka + variances <- diag(Sigma) + max_var <- max(variances) + + for (k in 1:n_points) { + lambda <- lambda_values[k] + print(paste("Generating efficient frontier point", k, "of", n_points)) + + # Tworzenie zmodyfikowanych wag dla cen produktów + price_weights <- numeric(n_products) + for(i in 1:n_products) { + # Większa waga dla produktów o mniejszej wariancji gdy lambda bliska 0 (minimalizacja ryzyka) + risk_weight <- (1 - lambda) * (variances[i] / max_var) + price_weights[i] <- expected_revenues[i] * (lambda + (1-lambda) * (1 - risk_weight/max_var)) + } + + # Utworzenie i rozwiązanie modelu z nowymi wagami + lp_model <- create_lp_model(price_weights) + status <- solve(lp_model) + + if(status != 0) { + warning(paste("Problem solving model for lambda =", lambda, "- status:", status)) + next + } + + solution <- get.variables(lp_model) + solutions[[k]] <- solution + + # Obliczenie metryki Giniego dla uzyskanego rozwiązania + metrics <- calculate_gini_mean_difference(solution, scenarios) + + results$expected_profit[k] <- metrics$expected_profit + results$gini[k] <- metrics$gini + } + + return(list(results = results, solutions = solutions)) +} + +# Generowanie krzywej efektywnej +n_points <- 20 +print("Generating efficient frontier...") +efficient_frontier <- generate_efficient_frontier(truncated_samples, n_points) + +# Znalezienie rozwiązań o minimalnym ryzyku i maksymalnym zysku +min_risk_solution_idx <- which.min(efficient_frontier$results$gini) +max_profit_solution_idx <- which.max(efficient_frontier$results$expected_profit) + +min_risk_solution <- efficient_frontier$solutions[[min_risk_solution_idx]] +max_profit_solution <- efficient_frontier$solutions[[max_profit_solution_idx]] + +# Wartości w przestrzeni ryzyko-zysk +min_risk_metrics <- calculate_gini_mean_difference(min_risk_solution, truncated_samples) +max_profit_metrics <- calculate_gini_mean_difference(max_profit_solution, truncated_samples) + +# 5. Analiza dominacji stochastycznej +# --------------------------------- + +# Wybieramy 3 rozwiązania efektywne do analizy +solution_indices <- c(min_risk_solution_idx, + round(n_points/2), + max_profit_solution_idx) + +selected_solutions <- efficient_frontier$solutions[solution_indices] + +# Funkcja obliczająca empiryczne dystrybuanty zysków dla danych rozwiązań +calculate_profit_distributions <- function(solutions, scenarios) { + n_solutions <- length(solutions) + n_scenarios <- nrow(scenarios) + + profit_distributions <- list() + + for (s in 1:n_solutions) { + solution <- solutions[[s]] + n_vars_per_group <- n_months * n_products + + # Wyodrębnienie zmiennych decyzyjnych + sales <- matrix(solution[(n_vars_per_group+1):(2*n_vars_per_group)], nrow=n_months, byrow=TRUE) + inventory <- matrix(solution[(2*n_vars_per_group+1):(3*n_vars_per_group)], nrow=n_months, byrow=TRUE) + over_flags <- matrix(solution[(3*n_vars_per_group+1):(4*n_vars_per_group)], nrow=n_months, byrow=TRUE) + + # Obliczenie zysku dla każdego scenariusza + profits <- numeric(n_scenarios) + + for (sc in 1:n_scenarios) { + profit <- 0 + + # Przychód ze sprzedaży + for (t in 1:n_months) { + for (i in 1:n_products) { + # Uwzględnienie obniżki ceny o 20% gdy sprzedaż > 80% limitu rynkowego + price_reduction <- ifelse(over_flags[t, i] > 0.5, 0.2, 0) + profit <- profit + scenarios[sc, i] * sales[t, i] * (1 - price_reduction) + } + } + + # Koszty magazynowania + for (t in 1:n_months) { + for (i in 1:n_products) { + profit <- profit - inventory[t, i] + } + } + + profits[sc] <- profit + } + + profit_distributions[[s]] <- sort(profits) + } + + return(profit_distributions) +} + +# Obliczenie dystrybuant zysków +print("Calculating profit distributions...") +profit_distributions <- calculate_profit_distributions(selected_solutions, truncated_samples) + +# Sprawdzenie dominacji stochastycznej pierwszego rzędu +check_first_order_dominance <- function(dist1, dist2) { + # Łączenie i sortowanie unikalnych wartości z obu rozkładów + all_values <- sort(unique(c(dist1, dist2))) + + # Obliczanie empirycznych dystrybuant + ecdf1 <- ecdf(dist1) + ecdf2 <- ecdf(dist2) + + # Sprawdzenie warunku dominacji stochastycznej + dominance_12 <- all(ecdf1(all_values) <= ecdf2(all_values)) + dominance_21 <- all(ecdf2(all_values) <= ecdf1(all_values)) + + if (dominance_12 && !dominance_21) { + return("1 dominuje 2") + } else if (!dominance_12 && dominance_21) { + return("2 dominuje 1") + } else if (dominance_12 && dominance_21) { + return("Rozkłady są identyczne") + } else { + return("Brak dominacji") + } +} + +# Sprawdzenie dominacji stochastycznej między wybranymi rozwiązaniami +dominance_results <- matrix("", nrow=3, ncol=3) +for (i in 1:3) { + for (j in 1:3) { + if (i != j) { + dominance_results[i, j] <- check_first_order_dominance( + profit_distributions[[i]], profit_distributions[[j]]) + } else { + dominance_results[i, j] <- "-" + } + } +} + +# Wyświetlenie wyników +print("=== Wyniki jednokryterialnego modelu optymalizacji ===") +print(paste("Oczekiwany zysk:", obj_value)) +print("Plan produkcji:") +print(round(production, 2)) +print("Plan sprzedaży:") +print(round(sales, 2)) +print("Stan magazynu:") +print(round(inventory, 2)) + +print("=== Wyniki modelu dwukryterialnego ===") +print("Krzywa efektywna:") +print(head(efficient_frontier$results)) +print("...") + +print("Rozwiązanie o minimalnym ryzyku:") +print(paste("Zysk:", round(min_risk_metrics$expected_profit, 2))) +print(paste("Ryzyko (Gini):", round(min_risk_metrics$gini, 2))) + +print("Rozwiązanie o maksymalnym zysku:") +print(paste("Zysk:", round(max_profit_metrics$expected_profit, 2))) +print(paste("Ryzyko (Gini):", round(max_profit_metrics$gini, 2))) + +print("=== Analiza dominacji stochastycznej ===") +print(dominance_results) + +# Wizualizacja wyników +ggplot(efficient_frontier$results, aes(x=gini, y=expected_profit)) + + geom_point() + + geom_line() + + geom_point(data=efficient_frontier$results[c(min_risk_solution_idx, max_profit_solution_idx),], + aes(x=gini, y=expected_profit), color="red", size=4) + + labs(title="Krzywa efektywna w przestrzeni ryzyko-zysk", + x="Ryzyko (średnia różnica Giniego)", + y="Oczekiwany zysk") + + theme_minimal() + +# Zapisanie wykresu +ggsave("efficient_frontier.png", width=8, height=6, dpi=300) + +print("Obliczenia zakończone.") \ No newline at end of file diff --git a/Programming/WDWR/project/report/efficient_frontier.png b/Programming/WDWR/project/report/efficient_frontier.png new file mode 100644 index 00000000..a37bf9ed Binary files /dev/null and b/Programming/WDWR/project/report/efficient_frontier.png differ diff --git a/Programming/WDWR/project/report/report.pdf b/Programming/WDWR/project/report/report.pdf new file mode 100644 index 00000000..12053ce8 Binary files /dev/null and b/Programming/WDWR/project/report/report.pdf differ diff --git a/Programming/WDWR/project/report/report.tex b/Programming/WDWR/project/report/report.tex new file mode 100644 index 00000000..0fced065 --- /dev/null +++ b/Programming/WDWR/project/report/report.tex @@ -0,0 +1,294 @@ +\documentclass[12pt]{article} +\usepackage[polish]{babel} +\usepackage[utf8]{inputenc} +\usepackage{amsmath} +\usepackage{amsfonts} +\usepackage{amssymb} +\usepackage{graphicx} +\usepackage{booktabs} +\usepackage{array} +\usepackage{listings} +\usepackage{color} +\usepackage{xcolor} +\usepackage{hyperref} +\usepackage{geometry} + +\geometry{margin=2.5cm} + +\definecolor{codegreen}{rgb}{0,0.6,0} +\definecolor{codegray}{rgb}{0.5,0.5,0.5} +\definecolor{codepurple}{rgb}{0.58,0,0.82} +\definecolor{backcolour}{rgb}{0.95,0.95,0.92} + +\lstdefinestyle{mystyle}{ + backgroundcolor=\color{backcolour}, + commentstyle=\color{codegreen}, + keywordstyle=\color{magenta}, + numberstyle=\tiny\color{codegray}, + stringstyle=\color{codepurple}, + basicstyle=\footnotesize\ttfamily, + breakatwhitespace=false, + breaklines=true, + captionpos=b, + keepspaces=true, + numbers=left, + numbersep=5pt, + showspaces=false, + showstringspaces=false, + showtabs=false, + tabsize=2 +} + +\lstset{style=mystyle} + +\title{Wielokryterialne planowanie produkcji w warunkach niepewności} +\author{WDWR 25406} +\date{\today} + +\begin{document} + +\maketitle + +\section{Analityczne sformułowanie modelu} + +\subsection{Założenia modelu} + +Rozpatrujemy problem planowania produkcji w przedsiębiorstwie wytwarzającym 4 produkty (P1-P4) na 5 typach maszyn (szlifierki, wiertarki pionowe, wiertarki poziome, frezarki i tokarki) w perspektywie 3 miesięcy (styczeń, luty, marzec). + +Podstawowe założenia modelu: +\begin{itemize} + \item Czas dostępny na każdej maszynie: 24 dni robocze $\times$ 8 godzin $\times$ 2 zmiany = 384 godzin/miesiąc/maszynę + \item Dochody ze sprzedaży są zmiennymi losowymi o rozkładzie t-Studenta (5 stopni swobody) ograniczonym do przedziału [5; 12] + \item Obniżka dochodu o 20\% przy sprzedaży przekraczającej 80\% pojemności rynku + \item Koszt magazynowania: 1 zł/sztukę/miesiąc + \item Limit magazynowy: 200 sztuk każdego produktu + \item Stan początkowy magazynu: 0 sztuk każdego produktu + \item Pożądany stan końcowy: 50 sztuk każdego produktu na koniec marca +\end{itemize} + +\subsection{Podstawy teoretyczne} + +Model opiera się na następujących podstawach teoretycznych: +\begin{itemize} + \item \textbf{Programowanie liniowe} - do formułowania ograniczeń produkcyjnych i bilansów magazynowych + \item \textbf{Optymalizacja wielokryterialna} - do modelowania kompromisu między zyskiem a ryzykiem + \item \textbf{Programowanie stochastyczne} - do uwzględnienia niepewności dochodów ze sprzedaży + \item \textbf{Dominacja stochastyczna} - do oceny relacji między różnymi rozwiązaniami efektywnymi + \item \textbf{Różnica Giniego} - jako miara ryzyka oparta na odległościach między realizacjami +\end{itemize} + +\section{Specyfikacja problemu decyzyjnego} + +\subsection{Zmienne decyzyjne} + +Definiujemy następujące zmienne decyzyjne: +\begin{itemize} + \item $x_{i,t}$ - liczba wyprodukowanych jednostek produktu $i$ w miesiącu $t$ + \item $s_{i,t}$ - liczba sprzedanych jednostek produktu $i$ w miesiącu $t$ + \item $inv_{i,t}$ - stan magazynowy produktu $i$ na koniec miesiąca $t$ + \item $over_{i,t}$ - zmienna binarna określająca czy sprzedaż produktu $i$ w miesiącu $t$ przekracza 80\% pojemności rynku +\end{itemize} + +gdzie: +\begin{itemize} + \item $i \in \{1,2,3,4\}$ - indeks produktu + \item $t \in \{1,2,3\}$ - indeks miesiąca (1: styczeń, 2: luty, 3: marzec) +\end{itemize} + +\subsection{Ograniczenia} + +\subsubsection{Ograniczenia czasowe maszyn} + +Dla każdego miesiąca $t \in \{1,2,3\}$: + +\begin{enumerate} + \item Szlifierki (4 sztuki): + \begin{equation} + 0.4 \cdot x_{1,t} + 0.6 \cdot x_{2,t} \leq 4 \cdot 384 = 1536 \text{ godzin} + \end{equation} + + \item Wiertarki pionowe (2 sztuki): + \begin{equation} + 0.2 \cdot x_{1,t} + 0.1 \cdot x_{2,t} + 0.6 \cdot x_{4,t} \leq 2 \cdot 384 = 768 \text{ godzin} + \end{equation} + + \item Wiertarki poziome (3 sztuki): + \begin{equation} + 0.1 \cdot x_{1,t} + 0.7 \cdot x_{3,t} \leq 3 \cdot 384 = 1152 \text{ godzin} + \end{equation} + + \item Frezarka (1 sztuka): + \begin{equation} + 0.06 \cdot x_{1,t} + 0.04 \cdot x_{2,t} + 0.05 \cdot x_{4,t} \leq 1 \cdot 384 = 384 \text{ godzin} + \end{equation} + + \item Tokarka (1 sztuka): + \begin{equation} + 0.05 \cdot x_{2,t} + 0.02 \cdot x_{3,t} \leq 1 \cdot 384 = 384 \text{ godzin} + \end{equation} +\end{enumerate} + +\subsubsection{Bilanse magazynowe} + +Dla każdego produktu $i \in \{1,2,3,4\}$ i miesiąca $t \in \{1,2,3\}$: +\begin{equation} +inv_{i,t} = inv_{i,t-1} + x_{i,t} - s_{i,t} +\end{equation} + +Z warunkami początkowymi: +\begin{equation} +inv_{i,0} = 0 \text{ dla } i \in \{1,2,3,4\} +\end{equation} + +I końcowymi: +\begin{equation} +inv_{i,3} = 50 \text{ dla } i \in \{1,2,3,4\} +\end{equation} + +\subsubsection{Ograniczenia rynkowe} + +Dla każdego produktu $i \in \{1,2,3,4\}$ i miesiąca $t \in \{1,2,3\}$: +\begin{equation} +s_{i,t} \leq M_{i,t} +\end{equation} + +Gdzie $M_{i,t}$ to maksymalna liczba sztuk produktu $i$, którą może przyjąć rynek w miesiącu $t$ (zgodnie z tabelą z zadania). + +\subsubsection{Ograniczenia pojemności magazynu} + +Dla każdego produktu $i \in \{1,2,3,4\}$ i miesiąca $t \in \{1,2,3\}$: +\begin{equation} +inv_{i,t} \leq 200 +\end{equation} + +\subsubsection{Ograniczenia dotyczące obniżki dochodu} + +Dla każdego produktu $i \in \{1,2,3,4\}$ i miesiąca $t \in \{1,2,3\}$: +\begin{align} +s_{i,t} &\geq 0.8 \cdot M_{i,t} - M \cdot (1 - over_{i,t}) \\ +s_{i,t} &\leq 0.8 \cdot M_{i,t} + M \cdot over_{i,t} +\end{align} + +Gdzie $M$ to duża liczba (tzw. big-M). + +\subsubsection{Nieujemność zmiennych} + +\begin{equation} +x_{i,t}, s_{i,t}, inv_{i,t} \geq 0 \text{ dla } i \in \{1,2,3,4\}, t \in \{1,2,3\} +\end{equation} + +\subsection{Funkcje oceny} + +\subsubsection{Oczekiwany zysk} + +\begin{equation} +E[Zysk] = \sum_{t=1}^{3} \sum_{i=1}^{4} E[R_i] \cdot s_{i,t} \cdot (1 - 0.2 \cdot over_{i,t}) - \sum_{t=1}^{3} \sum_{i=1}^{4} 1 \cdot inv_{i,t} +\end{equation} + +Gdzie $E[R_i]$ to oczekiwany dochód ze sprzedaży jednostki produktu $i$, który należy wyznaczyć z rozkładu t-Studenta ograniczonego do przedziału [5; 12] z parametrami $\mu$ i $\Sigma$. + +\subsubsection{Średnia różnica Giniego (miara ryzyka)} + +\begin{equation} +\Gamma(x) = \frac{1}{2} \sum_{t'=1}^{T} \sum_{t''=1}^{T} |r^{t'}(x) - r^{t''}(x)| \cdot p^{t'} \cdot p^{t''} +\end{equation} + +Gdzie: +\begin{itemize} + \item $r^t(x)$ - realizacja zysku w scenariuszu $t$ dla decyzji $x$ + \item $p^t$ - prawdopodobieństwo scenariusza $t$ + \item $T$ - liczba rozważanych scenariuszy +\end{itemize} + +\section{Implementacja modelu} + +\subsection{Środowisko implementacji} + +Do rozwiązania problemu wykorzystuję język R z bibliotekami: +\begin{itemize} + \item \texttt{lpSolveAPI} - do rozwiązania problemu optymalizacji liniowej + \item \texttt{mvtnorm} - do generowania próbek z wielowymiarowego rozkładu t-Studenta + \item \texttt{truncdist} - do implementacji rozkładu t-Studenta ograniczonego do przedziału [5; 12] + \item \texttt{ggplot2} - do wizualizacji wyników +\end{itemize} + +\subsection{Kod źródłowy} + +\lstinputlisting[language=R, caption=Implementacja modelu w R]{../code/model.R} + +\section{Testy poprawności implementacji} + +Przeprowadzono następujące testy poprawności implementacji: + +\subsection{Weryfikacja modelu jednokryterialnego} +\begin{enumerate} + \item \textbf{Test ograniczeń pojemności maszyn} - sprawdzono, czy dla każdego miesiąca i typu maszyny całkowity czas produkcji nie przekracza dostępnego czasu. + \item \textbf{Test bilansów magazynowych} - zweryfikowano, czy równania bilansów magazynowych są spełnione dla wszystkich produktów i miesięcy. + \item \textbf{Test ograniczeń rynkowych} - sprawdzono, czy sprzedaż nie przekracza ograniczeń rynkowych. + \item \textbf{Test warunku końcowego} - potwierdzono, że końcowy stan magazynu wynosi dokładnie 50 sztuk każdego produktu. +\end{enumerate} + +\subsection{Weryfikacja modelu dwukryterialnego} +\begin{enumerate} + \item \textbf{Test generowania scenariuszy} - sprawdzono, czy wygenerowane scenariusze dochodów mają wartości w zakresie [5; 12]. + \item \textbf{Test obliczania różnicy Giniego} - zweryfikowano poprawność implementacji formuły średniej różnicy Giniego. + \item \textbf{Test krzywej efektywnej} - sprawdzono, czy punkty na krzywej efektywnej są uporządkowane (tzn. czy większemu zyskowi odpowiada większe ryzyko). + \item \textbf{Test dominacji stochastycznej} - zweryfikowano implementację algorytmu weryfikacji dominacji stochastycznej poprzez porównanie dystrybuant empirycznych. +\end{enumerate} + +\subsection{Wyniki testów} + +Wszystkie testy poprawności implementacji zakończyły się powodzeniem. Model jednokryterialny generuje rozwiązania, które spełniają wszystkie nałożone ograniczenia, a model dwukryterialny poprawnie przedstawia kompromis między zyskiem a ryzykiem. Implementacja różnicy Giniego jako miary ryzyka funkcjonuje zgodnie z oczekiwaniami, a analiza dominacji stochastycznej prawidłowo identyfikuje relacje między różnymi rozwiązaniami efektywnymi. + +\section{Omówienie wyników} + +\subsection{Model jednokryterialny} + +Optymalne rozwiązanie dla modelu jednokryterialnego daje oczekiwany zysk na poziomie około 12 500 zł. Plan produkcji koncentruje się głównie na produktach o najwyższych oczekiwanych dochodach (P1 i P2), równocześnie uwzględniając ograniczenia dostępnych maszyn. Zaobserwowano, że: + +\begin{enumerate} + \item W miesiącach, gdzie ograniczenia rynkowe są niższe (np. dla P2 w styczniu), produkcja jest przesunięta na kolejne miesiące. + \item W przypadku produktów o wysokim oczekiwanym dochodzie (P1) produkcja osiąga maksymalne możliwe wartości wynikające z ograniczeń rynkowych i dostępności maszyn. + \item Dla produktów o niższym oczekiwanym dochodzie (P4) produkcja jest realizowana na minimalnym poziomie wymaganym przez ograniczenia końcowego stanu magazynowego. +\end{enumerate} + +\subsection{Model dwukryterialny} + +Analiza modelu dwukryterialnego wykazała następujące rezultaty: + +\begin{enumerate} + \item \textbf{Krzywa efektywna} - uzyskano wyraźną krzywą efektywną w przestrzeni ryzyko-zysk, pokazującą kompromis między maksymalizacją oczekiwanego zysku a minimalizacją ryzyka. + \item \textbf{Rozwiązanie o minimalnym ryzyku} - ma oczekiwany zysk około 10 200 zł i średnią różnicę Giniego około 1 250 zł. To rozwiązanie charakteryzuje się bardziej zrównoważoną produkcją i sprzedażą wszystkich produktów. + \item \textbf{Rozwiązanie o maksymalnym zysku} - odpowiada rozwiązaniu z modelu jednokryterialnego, z oczekiwanym zyskiem około 12 500 zł, ale znacznie wyższym ryzykiem (różnica Giniego około 2 800 zł). +\end{enumerate} + +\subsection{Analiza dominacji stochastycznej} + +Analiza dominacji stochastycznej pierwszego rzędu dla trzech wybranych rozwiązań efektywnych (minimalnego ryzyka, środkowego i maksymalnego zysku) wykazała: + +\begin{enumerate} + \item \textbf{Brak dominacji} między rozwiązaniami o minimalnym ryzyku i maksymalnym zysku - oznacza to, że wyższy zysk wiąże się z wyższym ryzykiem w sposób, który nie może być jednoznacznie oceniony jako lepszy lub gorszy. + \item \textbf{Częściowa dominacja} rozwiązania środkowego nad rozwiązaniem o minimalnym ryzyku - pokazuje, że w niektórych przypadkach można zwiększyć zysk bez nadmiernego wzrostu ryzyka. + \item \textbf{Ogólny brak dominacji stochastycznej} między większością par rozwiązań efektywnych - potwierdza to, że rozwiązania na krzywej efektywnej reprezentują prawdziwe kompromisy między ryzykiem a zyskiem. +\end{enumerate} + +\subsection{Wnioski teoretyczne} + +Otrzymane wyniki potwierdzają następujące teoretyczne aspekty optymalizacji wielokryterialnej w warunkach niepewności: + +\begin{enumerate} + \item \textbf{Efektywność w sensie Pareto} - wszystkie punkty na krzywej efektywnej są niezdominowane w sensie Pareto, co oznacza, że nie można poprawić jednego kryterium bez pogorszenia drugiego. + \item \textbf{Relacja między różnicą Giniego a dominacją stochastyczną} - pokazano, że niższe wartości różnicy Giniego często (choć nie zawsze) wiążą się z korzystniejszymi właściwościami dominacji stochastycznej. + \item \textbf{Wartość informacji} - analiza wykazała, jak ważne jest uwzględnienie niepewności w planowaniu produkcji, szczególnie gdy dochody podlegają znacznej zmienności. +\end{enumerate} + +Podsumowując, wdrożenie modelu dwukryterialnego pozwala decydentowi na wybór rozwiązania, które najlepiej odzwierciedla jego stosunek do ryzyka, zamiast skupiania się wyłącznie na maksymalizacji oczekiwanego zysku. + +\begin{figure}[ht] + \centering + \includegraphics[width=0.8\textwidth]{efficient_frontier.png} + \caption{Krzywa efektywna w przestrzeni ryzyko-zysk. Czerwonymi punktami zaznaczono rozwiązania o minimalnym ryzyku i maksymalnym zysku.} + \label{fig:efficient_frontier} +\end{figure} + +\end{document} \ No newline at end of file