ExecutionControlParams.java

  1. package org.drip.function.r1tor1solver;

  2. /*
  3.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  4.  */

  5. /*!
  6.  * Copyright (C) 2020 Lakshmi Krishnamurthy
  7.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  8.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  9.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  10.  * Copyright (C) 2016 Lakshmi Krishnamurthy
  11.  * Copyright (C) 2015 Lakshmi Krishnamurthy
  12.  * Copyright (C) 2014 Lakshmi Krishnamurthy
  13.  * Copyright (C) 2013 Lakshmi Krishnamurthy
  14.  * Copyright (C) 2012 Lakshmi Krishnamurthy
  15.  *
  16.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  17.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  18.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  19.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  20.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  21.  *      and computational support.
  22.  *  
  23.  *      https://lakshmidrip.github.io/DROP/
  24.  *  
  25.  *  DROP is composed of three modules:
  26.  *  
  27.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  28.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  29.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  30.  *
  31.  *  DROP Product Core implements libraries for the following:
  32.  *  - Fixed Income Analytics
  33.  *  - Loan Analytics
  34.  *  - Transaction Cost Analytics
  35.  *
  36.  *  DROP Portfolio Core implements libraries for the following:
  37.  *  - Asset Allocation Analytics
  38.  *  - Asset Liability Management Analytics
  39.  *  - Capital Estimation Analytics
  40.  *  - Exposure Analytics
  41.  *  - Margin Analytics
  42.  *  - XVA Analytics
  43.  *
  44.  *  DROP Computational Core implements libraries for the following:
  45.  *  - Algorithm Support
  46.  *  - Computation Support
  47.  *  - Function Analysis
  48.  *  - Model Validation
  49.  *  - Numerical Analysis
  50.  *  - Numerical Optimizer
  51.  *  - Spline Builder
  52.  *  - Statistical Learning
  53.  *
  54.  *  Documentation for DROP is Spread Over:
  55.  *
  56.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  57.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  58.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  59.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  60.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  61.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  62.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  63.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  64.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  65.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  66.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  67.  *
  68.  *  Licensed under the Apache License, Version 2.0 (the "License");
  69.  *      you may not use this file except in compliance with the License.
  70.  *  
  71.  *  You may obtain a copy of the License at
  72.  *      http://www.apache.org/licenses/LICENSE-2.0
  73.  *  
  74.  *  Unless required by applicable law or agreed to in writing, software
  75.  *      distributed under the License is distributed on an "AS IS" BASIS,
  76.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  77.  *  
  78.  *  See the License for the specific language governing permissions and
  79.  *      limitations under the License.
  80.  */

  81. /**
  82.  * <i>ExecutionControlParams</i> holds the parameters needed for controlling the execution of the fixed point
  83.  * finder.
  84.  * <br><br>
  85.  * ExecutionControlParams fields control the fixed point search in one of the following ways:
  86.  * <br>
  87.  * <ul>
  88.  *  <li>
  89.  *      Number of iterations after which the search is deemed to have failed
  90.  *  </li>
  91.  *  <li>
  92.  *      Relative Objective Function Tolerance Factor which, when reached by the objective function, will
  93.  *          indicate that the fixed point has been reached
  94.  *  </li>
  95.  *  <li>
  96.  *      Variate Convergence Factor, factor applied to the initial variate to determine the absolute
  97.  *          convergence
  98.  *  </li>
  99.  *  <li>
  100.  *      Absolute Tolerance fall-back, which is used to determine that the fixed point has been reached when
  101.  *          the relative tolerance factor becomes zero
  102.  *  </li>
  103.  *  <li>
  104.  *      Absolute Variate Convergence Fall-back, fall-back used to determine if the variate has converged.
  105.  *  </li>
  106.  * </ul>
  107.  *
  108.  *  <br><br>
  109.  *  <ul>
  110.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  111.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalAnalysisLibrary.md">Numerical Analysis Library</a></li>
  112.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/function/README.md">R<sup>d</sup> To R<sup>d</sup> Function Analysis</a></li>
  113.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/function/r1tor1solver/README.md">Built-in R<sup>1</sup> To R<sup>1</sup> Solvers</a></li>
  114.  *  </ul>
  115.  *
  116.  * @author Lakshmi Krishnamurthy
  117.  */

  118. public class ExecutionControlParams {
  119.     private int _iNumIterations = 0;
  120.     private boolean _bIsVariateConvergenceCheckEnabled = false;
  121.     private double _dblOFGoalToleranceFactor = java.lang.Double.NaN;
  122.     private double _dblVariateConvergenceFactor = java.lang.Double.NaN;
  123.     private double _dblAbsoluteOFToleranceFallback = java.lang.Double.NaN;
  124.     private double _dblAbsoluteVariateConvergenceFallback = java.lang.Double.NaN;

  125.     /**
  126.      * Default Execution Control Parameters constructor
  127.      */

  128.     public ExecutionControlParams()
  129.     {
  130.         _iNumIterations = 200;
  131.         _dblOFGoalToleranceFactor = 1.0e-07;
  132.         _dblVariateConvergenceFactor = 1.0e-07;
  133.         _dblAbsoluteOFToleranceFallback = 1.0e-08;
  134.         _dblAbsoluteVariateConvergenceFallback = 1.0e-08;
  135.     }

  136.     /**
  137.      * Execution Control Parameters constructor
  138.      *
  139.      * @param iNumIterations Number of Iterations
  140.      * @param bIsVariateConvergenceCheckEnabled Flag indicating if the variate convergence check is on
  141.      * @param dblOFGoalToleranceFactor Tolerance factor for the OF Goal
  142.      * @param dblVariateConvergenceFactor Variate Convergence Factor
  143.      * @param dblAbsoluteOFToleranceFallback Absolute Tolerance Fall-back
  144.      * @param dblAbsoluteVariateConvergenceFallback Absolute Variate Convergence fall-back
  145.      *
  146.      * @throws java.lang.Exception Thrown if the inputs are invalid
  147.      */

  148.     public ExecutionControlParams (
  149.         final int iNumIterations,
  150.         final boolean bIsVariateConvergenceCheckEnabled,
  151.         final double dblOFGoalToleranceFactor,
  152.         final double dblVariateConvergenceFactor,
  153.         final double dblAbsoluteOFToleranceFallback,
  154.         final double dblAbsoluteVariateConvergenceFallback)
  155.         throws java.lang.Exception
  156.     {
  157.         if (!org.drip.numerical.common.NumberUtil.IsValid (_dblOFGoalToleranceFactor = dblOFGoalToleranceFactor)
  158.             || !org.drip.numerical.common.NumberUtil.IsValid (_dblVariateConvergenceFactor =
  159.                 dblVariateConvergenceFactor) || !org.drip.numerical.common.NumberUtil.IsValid
  160.                     (_dblAbsoluteOFToleranceFallback = dblAbsoluteOFToleranceFallback) ||
  161.                         !org.drip.numerical.common.NumberUtil.IsValid (_dblAbsoluteVariateConvergenceFallback =
  162.                             dblAbsoluteVariateConvergenceFallback) || 0 >= (_iNumIterations =
  163.                                 iNumIterations))
  164.             throw new java.lang.Exception ("ExecutionControlParams constructor: Invalid inputs");

  165.         _bIsVariateConvergenceCheckEnabled = bIsVariateConvergenceCheckEnabled;
  166.     }

  167.     /**
  168.      * Return the number of iterations allowed
  169.      *
  170.      * @return Number of iterations
  171.      */

  172.     public int getNumIterations()
  173.     {
  174.         return _iNumIterations;
  175.     }

  176.     /**
  177.      * Return the tolerance factor for the OF Goal
  178.      *
  179.      * @return Tolerance factor for the OF Goal
  180.      */

  181.     public double getOFGoalToleranceFactor()
  182.     {
  183.         return _dblOFGoalToleranceFactor;
  184.     }

  185.     /**
  186.      * Return the Variate Convergence Factor
  187.      *
  188.      * @return Variate Convergence Factor
  189.      */

  190.     public double getVariateConvergenceFactor()
  191.     {
  192.         return _dblVariateConvergenceFactor;
  193.     }

  194.     /**
  195.      * Return the Fall-back absolute tolerance for the OF
  196.      *
  197.      * @return Fall-back absolute tolerance for the OF
  198.      */

  199.     public double getAbsoluteOFToleranceFallback()
  200.     {
  201.         return _dblAbsoluteOFToleranceFallback;
  202.     }

  203.     /**
  204.      * Return the fall-back absolute variate convergence
  205.      *
  206.      * @return Fall-back absolute variate convergence
  207.      */

  208.     public double getAbsoluteVariateConvergenceFallback()
  209.     {
  210.         return _dblAbsoluteVariateConvergenceFallback;
  211.     }

  212.     /**
  213.      * Indicate if the variate convergence check has been turned on
  214.      *
  215.      * @return TRUE - Variate convergence check has been turned on
  216.      */

  217.     public boolean isVariateConvergenceCheckEnabled()
  218.     {
  219.         return _bIsVariateConvergenceCheckEnabled;
  220.     }
  221. }