Skip to content

Commit c3a0aeb

Browse files
committed
Merge branch 'master' into ore_master_into_ore-github
2 parents dc722d3 + 7f63788 commit c3a0aeb

2,304 files changed

Lines changed: 199020 additions & 76610 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[submodule "QuantLib"]
22
path = QuantLib
3-
url = https://github.com/OpenSourceRisk/QuantLib.git
3+
url = git@gitlab.acadiasoft.net:qs/quantlib.git
44
branch = master
55
ignore = dirty

App/ore.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include <orea/app/oreapp.hpp>
2929

30-
#include <ored/utilities/initbuilders.hpp>
30+
#include <orea/app/initbuilders.hpp>
3131

3232
#include <qle/version.hpp>
3333

@@ -71,12 +71,12 @@ int main(int argc, char** argv) {
7171
return -1;
7272
}
7373

74-
ore::data::initBuilders();
74+
ore::analytics::initBuilders();
7575

7676
string inputFile(argv[1]);
7777

7878
try {
79-
auto params = boost::make_shared<Parameters>();
79+
auto params = QuantLib::ext::make_shared<Parameters>();
8080
params->fromFile(inputFile);
8181
OREApp ore(params, true);
8282
ore.run();

Docker/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ DEBIAN_TAG=11.7
33
# it's recommended to include CMAKE_BUILD_TYPE and BOOST_VARIANT in QL_TAG, ORE_TAG, BOOST_TAG
44
# to distinguish a release build from a debug build
55

6-
QL_TAG=1.31.1_0fd143ce3
6+
QL_TAG=1.31.1_f8955cf0
77
ORE_TAG=latest
88

99
# debug or release

Docs/AMC/amc.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ \section*{Document Change History}
113113
\hline
114114
na & 25 February 2019 & Peter Caspers & initial version\\
115115
na & 23 October 2023 & Peter Caspers & add parameter RegressorModel\\
116+
na & 4 April 2024 & Peter Caspers & add parameter RegressionVarianceCutoff\\
116117
\hline
117118
\end{supertabular}
118119
\end{center}
@@ -247,6 +248,7 @@ \subsection{Pricing Engine Configuration}\label{sec:pricing_engine_config}
247248
<Parameter name="SobolDirectionIntegers">JoeKuoD7</Parameter>
248249
<Parameter name="MinObsDate">true</Parameter>
249250
<Parameter name="RegressorModel">Simple</Parameter>
251+
<Parameter name="RegressionVarianceCutoff">1E-5</Parameter>
250252
</EngineParameters>
251253
</Product>
252254
\end{minted}
@@ -286,6 +288,9 @@ \subsection{Pricing Engine Configuration}\label{sec:pricing_engine_config}
286288
addition, past FX states that are relevant for future cashflows are included. For example, for a FX resettable
287289
cashflow the FX state observed on the FX reset date is included.
288290
\end{itemize}
291+
\item \verb+RegressionVarianceCutoff+: Optional. If given, a coordinate transform and (possibly) a factor reduction is
292+
applied to the regressors, such that $1-\epsilon$ of the total variance of regressors is kept, where $\epsilon$ the
293+
given parameter. This helps dealing with collinearity and also reducing the dimnensionality of the regression model.
289294
\end{enumerate}
290295
291296
\begin{table}[hbt]

Docs/ComputeEnvironment/computeenvironment.tex

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ \section*{Document History}
8989
Date & Author & Comment \\
9090
\hline
9191
19 June 2023 & Acadia & initial release\\
92+
15 April 2024 & Acadia & refactor context settings, add supportsDoublePrecision()\\
9293
\hline
9394
\end{supertabular}
9495
\end{flushleft}
@@ -222,7 +223,7 @@ \subsection{Implementation of the ComputeFramework interface}\label{implComputeF
222223
Notice that the same device can appear under several frameworks, e.g. a GPU could be accessed both via an OpenCL
223224
driver or via a CUDA driver.
224225
\item \verb+getContext()+ should return a raw pointer to a \verb+ComputeContext+ implementation for a given device label
225-
or throw an erro if the device label is not valid. See \ref{implComputeContext} for more details.
226+
or throw an error if the device label is not valid. See \ref{implComputeContext} for more details.
226227
\item \verb+Destructor+ The destructor of \verb+ComputeFramework+ is virtual and has an empty default implementation. It
227228
can be override in implementations to free ressources. For example, the \verb+OpenClFramework+ implementation stores
228229
raw pointers for each compute contexts that need to be deleted on destruction of the \verb+OpenClFramework+ instance.
@@ -251,9 +252,19 @@ \subsection{Implementation of the ComputeContext interface}\label{implComputeCon
251252
previous calculation. In this case only the input variables and random variates (see below) need to be set to
252253
retrieve the results of the calculation calling \verb+finalizeCalculation()+. If \verb+id+ is \verb+0+ on the other
253254
hand, a new calculation \verb+id+ will be generated and returned.
254-
\item \verb+version+: The version of a calculation.
255-
\item \verb+debug+: A flag indicating whether debug information on the number of performed operations and timings for
256-
data copying, kernel building and calculations should be collected.
255+
\item \verb+version+: The version of a calculation. This is a freely choosable integer, which is only used to identify
256+
different versions. Usually the first version of a calculation will be $0$, then next $1$, etc.
257+
\item \verb+Settings+: A struct summarizing settings for the compute environment:
258+
\begin{itemize}
259+
\item debug: a flag indicating whether debug information on the number of performed operations and timings for
260+
data copying, kernel building and calculations should be collected. Defaults to false.
261+
\item useDoublePrecision: a flag indicating whether double precision should be used for calculations. Defaults to
262+
false.
263+
\item rngSequenceType: the sequence type for random number generation. One of MersenneTwister,
264+
MersenneTwisterAntithetic, Sobol, Burley2020Sobol, SobolBrownianBridge, Burley2020SobolBrownianBridge
265+
\item seed: the seed for the random number generator
266+
\item regressionOrder: the regression order to be used within regression models
267+
\end{itemize}
257268
\end{itemize}
258269
The output parameter is a pair consisting of
259270
\begin{itemize}
@@ -268,19 +279,19 @@ \subsection{Implementation of the ComputeContext interface}\label{implComputeCon
268279
\begin{itemize}
269280
\item \verb+dim+ the dimension (typically the number of assets in a MC simulation)
270281
\item \verb+steps+ the number of steps (typically the number of time steps in a MC simulation)
271-
\item \verb+seed+ the seed of the random number generation, equal seeds must generate identical variates, different
272-
seeds might or might not generate different variates
273282
\end{itemize}
274283
The output parameter is a vector of a vector of ids for the generated variates. The inner vector loops of the steps,
275284
the outer vector over the dimensions.
276285
\item \verb+applyOperation()+: apply an operation to a list of arguments and return the id of the result. The list of
277286
operations is described in \ref{randomVariableOpCodes}
278287
\item \verb+freeVariable()+: indicate that the variable with the given id will no longer be referenced in subsequent
279288
calculations. The variable id can be reused as a new variable.
280-
\item \verb+declareOutputVariable()+: declare a variable with given id as part of the output vector
289+
\item \verb+declareOutputVariable()+: declare a variable with given id as part of the output vector.
281290
\item \verb+finalizeCalculation()+: execute the calculation and populate the given vector of vector of floats with the
282291
result. The inner vector is given as a raw pointer and must have the size of the calculation. The outer vector matches
283292
the output variables in the order they were declared before.
293+
\item \verb+deviceInfo()+: provide key-value pairs that describes the device, only used for information purposes
294+
\item \verb+supportsDoublePreicions()+: should return true if doule precision is supported, otherwise false
284295
\item \verb+debugInfo()+: provide info on the number of elementary operations and timings on data copying, program build
285296
and calculations. This info is collected if a new calculation is started with flag debug set to true
286297
\end{itemize}
@@ -289,12 +300,17 @@ \subsection{Implementation of the ComputeContext interface}\label{implComputeCon
289300

290301
\begin{enumerate}
291302
\item \verb+initiateCalculation()+: once
292-
\item \verb+createInputVariable()+: never, once, or several times
293-
\item \verb+createInputVariates()+: never, once, or several times
294-
\item \verb+applyOperation()+: only called if the current calculation is not replayed from a previous calculation, then can be called never, once, or several times
295-
\item \verb+freeVariable()+: only called if the current calculation is not replayed, then can be called never, once, or several times
296-
\item \verb+declareOutputVariable()+: only called if the current calculation is not replayed, then can be called never, once, or several times
297-
\item \verb+finalizeCalculation()+: never or once
303+
\item \verb+createInputVariable()+: never, once, or several times, if a calc is replayed, the same number and type of
304+
input variables must be created (just with possibly different values)
305+
\item \verb+createInputVariates()+: called if the current calculation is not replayed from a previous calculation, then
306+
can be called never, once or several times
307+
\item \verb+applyOperation()+: only called if the current calculation is not replayed from a previous calculation, then
308+
can be called never, once, or several times
309+
\item \verb+freeVariable()+: only called if the current calculation is not replayed, then can be called never, once, or
310+
several times
311+
\item \verb+declareOutputVariable()+: only called if the current calculation is not replayed, then can be called never,
312+
once, or several times
313+
\item \verb+finalizeCalculation()+: once
298314
\end{enumerate}
299315

300316
\subsection{Random Variable Op Codes}\label{randomVariableOpCodes}
@@ -373,7 +389,7 @@ \subsection{Initiation of a calculation}
373389
\begin{minted}[fontsize=\footnotesize]{xml}
374390
std::tie(externalCalculationId_, newExternalCalc) =
375391
ComputeEnvironment::instance().context()
376-
.initiateCalculation(model_->size(), externalCalculationId_, cgVersion_);
392+
.initiateCalculation(model_->size(), externalCalculationId_, cgVersion_, settings);
377393
\end{minted}
378394

379395
providing
@@ -384,6 +400,8 @@ \subsection{Initiation of a calculation}
384400
to get a new id and for subsequent calculations of the same trade this id is reused
385401
\item \verb+cgVersion_+: a version number (initially zero). The version is incremented whenever a repricing requires a
386402
different sequence of operations to be performed, which is the case when the evaluation date changes
403+
\item \verb+settings+: the settings to be used, see \ref{implComputeFramework} for details. Notice that for a replayed
404+
calculation the settings must match the ones from the initial calculation.
387405
\end{itemize}
388406

389407
and retrieving the external calc id and a flag indicating whether the calculation requires a resubmission of an
@@ -417,16 +435,17 @@ \subsection{Populating the input variables}
417435

418436
\subsection{Populating the input variates}
419437

420-
The next step is the creating of random variates
438+
The next step is the creating of random variates (if this is a new calculation and not replayed):
421439

422440
\begin{minted}[fontsize=\footnotesize]{xml}
423-
auto gen = ComputeEnvironment::instance().context()
424-
.createInputVariates(rv.size(),
425-
rv.front().size(),
426-
42);
427-
for (Size k = 0; k < rv.size(); ++k) {
428-
for (Size j = 0; j < rv.front().size(); ++j)
429-
valuesExternal[rv[k][j]] = ExternalRandomVariable(gen[k][j]);
441+
if (useExternalComputeFramework_ && newExternalCalc) {
442+
auto gen =
443+
ComputeEnvironment::instance().context().
444+
createInputVariates(rv.size(), rv.front().size());
445+
for (Size k = 0; k < rv.size(); ++k) {
446+
for (Size j = 0; j < rv.front().size(); ++j)
447+
valuesExternal[rv[k][j]] = ExternalRandomVariable(gen[k][j]);
448+
}
430449
}
431450
\end{minted}
432451

Docs/Design/data/notebook.pdf

236 KB
Binary file not shown.

0 commit comments

Comments
 (0)