\doxysection{Stats.\+hpp}
\hypertarget{Stats_8hpp_source}{}\label{Stats_8hpp_source}\index{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/RL/Stats.hpp@{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/RL/Stats.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#ifndef\ GYM\_PCB\_RL\_STATS\_H}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#define\ GYM\_PCB\_RL\_STATS\_H}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ "{}RL/Action.hpp"{}}}
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ <vector>}}
\DoxyCodeLine{00006\ }
\DoxyCodeLine{00007\ \textcolor{keyword}{class\ }\mbox{\hyperlink{classAgent}{Agent}};}
\DoxyCodeLine{00008\ }
\DoxyCodeLine{00009\ \textcolor{keyword}{struct\ }ResultRecord}
\DoxyCodeLine{00010\ \{}
\DoxyCodeLine{00011\ \ \ \ \ ResultRecord()\ \{\ \}}
\DoxyCodeLine{00012\ \ \ \ \ ResultRecord(\textcolor{keyword}{const}\ \mbox{\hyperlink{classAgent}{Agent}}\&,\ \textcolor{keyword}{const}\ \mbox{\hyperlink{structAction_1_1Result}{Action::Result}}\&);}
\DoxyCodeLine{00013\ \ \ \ \ ResultRecord(\textcolor{keyword}{const}\ \mbox{\hyperlink{classAgent}{Agent}}\&);}
\DoxyCodeLine{00014\ \ \ \ \ \mbox{\hyperlink{structAction_1_1Result}{Action::Result}}\ asResult()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{structAction_1_1Result}{Action::Result}}(RewardSum,\ Success,\ \textcolor{keyword}{true});\ \}}
\DoxyCodeLine{00015\ }
\DoxyCodeLine{00016\ \ \ \ \ Reward\ RewardSum;}
\DoxyCodeLine{00017\ \ \ \ \ \textcolor{keywordtype}{bool}\ Success;}
\DoxyCodeLine{00018\ \ \ \ \ \mbox{\hyperlink{structRouterResult}{RouterResult}}\ Router;}
\DoxyCodeLine{00019\ \ \ \ \ uint64\_t\ TimeMicroseconds;}
\DoxyCodeLine{00020\ \ \ \ \ uint64\_t\ TimeStep;}
\DoxyCodeLine{00021\ \ \ \ \ uint64\_t\ Iteration;}
\DoxyCodeLine{00022\ }
\DoxyCodeLine{00023\ \ \ \ \ \textcolor{keywordtype}{void}\ reset(\textcolor{keywordtype}{bool}\ success,\ Reward\ r\ =\ std::numeric\_limits<Reward>::infinity());}
\DoxyCodeLine{00024\ \ \ \ \ std::string\ str()\ \textcolor{keyword}{const};}
\DoxyCodeLine{00025\ \ \ \ \ PyObject\ *getPy()\ \textcolor{keyword}{const};}
\DoxyCodeLine{00026\ \};}
\DoxyCodeLine{00027\ }
\DoxyCodeLine{00028\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{structResultCollection}{ResultCollection}}}
\DoxyCodeLine{00029\ \{}
\DoxyCodeLine{00030\ \ \ \ \ std::vector<ResultRecord>\ TimeLine;}
\DoxyCodeLine{00031\ \ \ \ \ \mbox{\hyperlink{structResultRecord}{ResultRecord}}\ WorstSuccess;}
\DoxyCodeLine{00032\ \ \ \ \ \mbox{\hyperlink{structResultRecord}{ResultRecord}}\ Worst;}
\DoxyCodeLine{00033\ \ \ \ \ std::map<std::string,\ float>\ F32;}
\DoxyCodeLine{00034\ \ \ \ \ std::map<std::string,\ int64\_t>\ I64;}
\DoxyCodeLine{00035\ }
\DoxyCodeLine{00036\ \ \ \ \ \textcolor{keywordtype}{bool}\ shouldAdd(\textcolor{keyword}{const}\ \mbox{\hyperlink{structAction_1_1Result}{Action::Result}}\&)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00037\ \ \ \ \ \textcolor{keywordtype}{void}\ add(\mbox{\hyperlink{structResultRecord}{ResultRecord}}\&\&);}
\DoxyCodeLine{00038\ \ \ \ \ \textcolor{keywordtype}{void}\ reset();}
\DoxyCodeLine{00039\ \ \ \ \ PyObject\ *getPy()\ \textcolor{keyword}{const};}
\DoxyCodeLine{00040\ \};}
\DoxyCodeLine{00041\ }
\DoxyCodeLine{00042\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ ResultRecord::reset(\textcolor{keywordtype}{bool}\ success,\ Reward\ r)}
\DoxyCodeLine{00043\ \{}
\DoxyCodeLine{00044\ \ \ \ \ Success\ =\ success;}
\DoxyCodeLine{00045\ \ \ \ \ RewardSum\ =\ r;}
\DoxyCodeLine{00046\ \ \ \ \ Iteration\ =\ 0;}
\DoxyCodeLine{00047\ \ \ \ \ TimeMicroseconds\ =\ 0;}
\DoxyCodeLine{00048\ \ \ \ \ TimeStep\ =\ 0;}
\DoxyCodeLine{00049\ \}}
\DoxyCodeLine{00050\ }
\DoxyCodeLine{00051\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ ResultCollection::reset()}
\DoxyCodeLine{00052\ \{}
\DoxyCodeLine{00053\ \ \ \ \ TimeLine.clear();}
\DoxyCodeLine{00054\ \ \ \ \ WorstSuccess.reset(\textcolor{keyword}{false});}
\DoxyCodeLine{00055\ \ \ \ \ Worst.reset(\textcolor{keyword}{true});}
\DoxyCodeLine{00056\ \ \ \ \ F32.clear();}
\DoxyCodeLine{00057\ \ \ \ \ I64.clear();}
\DoxyCodeLine{00058\ \}}
\DoxyCodeLine{00059\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{bool}\ ResultCollection::shouldAdd(\textcolor{keyword}{const}\ \mbox{\hyperlink{structAction_1_1Result}{Action::Result}}\ \&res)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00060\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00061\ \ \ \ \ \textcolor{keywordflow}{return}\ TimeLine.empty()\ ||}
\DoxyCodeLine{00062\ \ \ \ \ \ \ \ \ (res\ >\ TimeLine.back().asResult())\ ||}
\DoxyCodeLine{00063\ \ \ \ \ \ \ \ \ (res\ <\ Worst.asResult())\ ||}
\DoxyCodeLine{00064\ \ \ \ \ \ \ \ \ (res.Success\ \&\&\ res\ <\ WorstSuccess.asResult());}
\DoxyCodeLine{00065\ \}}
\DoxyCodeLine{00066\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ ResultCollection::add(\mbox{\hyperlink{structResultRecord}{ResultRecord}}\ \&\&rr)}
\DoxyCodeLine{00067\ \{}
\DoxyCodeLine{00068\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ res\ =\ rr.asResult();}
\DoxyCodeLine{00069\ \ \ \ \ \textcolor{keywordflow}{if}\ (TimeLine.empty()\ ||\ res\ >\ TimeLine.back().asResult())}
\DoxyCodeLine{00070\ \ \ \ \ \ \ \ \ TimeLine.emplace\_back(rr);}
\DoxyCodeLine{00071\ \ \ \ \ \textcolor{keywordflow}{if}\ (rr.Success\ \&\&\ res\ <\ WorstSuccess.asResult())}
\DoxyCodeLine{00072\ \ \ \ \ \ \ \ \ WorstSuccess\ =\ rr;}
\DoxyCodeLine{00073\ \ \ \ \ \textcolor{keywordflow}{if}\ (res\ <\ Worst.asResult())}
\DoxyCodeLine{00074\ \ \ \ \ \ \ \ \ Worst\ =\ rr;}
\DoxyCodeLine{00075\ \}}
\DoxyCodeLine{00076\ }
\DoxyCodeLine{00077\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ GYM\_PCB\_RL\_STATS\_H}}

\end{DoxyCode}
