BracketingControlParams.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>BracketingControlParams</i> implements the control parameters for bracketing solutions.
  83.  * <br><br>
  84.  * BracketingControlParams provides the following parameters:
  85.  * <ul>
  86.  *  <li>
  87.  *          The starting variate from which the search for bracketing begins
  88.  *  </li>
  89.  *  <li>
  90.  *          The initial width for the brackets
  91.  *  </li>
  92.  *  <li>
  93.  *          The factor by which the width expands with each iterative search
  94.  *  </li>
  95.  *  <li>
  96.  *          The number of such iterations.
  97.  *  </li>
  98.  * </ul>
  99.  *
  100.  *  <br><br>
  101.  *  <ul>
  102.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  103.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalAnalysisLibrary.md">Numerical Analysis Library</a></li>
  104.  *      <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>
  105.  *      <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>
  106.  *  </ul>
  107.  *
  108.  * @author Lakshmi Krishnamurthy
  109.  */

  110. public class BracketingControlParams {

  111.     /*
  112.      * Bracket Determination Parameters
  113.      */

  114.     private int _iNumExpansions = 0;
  115.     private double _dblVariateStart = java.lang.Double.NaN;
  116.     private double _dblBracketStartingWidth = java.lang.Double.NaN;
  117.     private double _dblBracketWidthExpansionFactor = java.lang.Double.NaN;

  118.     /**
  119.      * Default BracketingControlParams constructor
  120.      */

  121.     public BracketingControlParams()
  122.     {
  123.         _dblVariateStart = 0.;
  124.         _iNumExpansions = 100;
  125.         _dblBracketStartingWidth = 1.e-06;
  126.         _dblBracketWidthExpansionFactor = 2.;
  127.     }

  128.     /**
  129.      * BracketingControlParams constructor
  130.      *
  131.      * @param iNumExpansions Number of bracket expansions to determine the bracket
  132.      * @param dblVariateStart Variate start for the bracket determination
  133.      * @param dblBracketStartingWidth Base Bracket Width
  134.      * @param dblBracketWidthExpansionFactor Bracket width expansion factor
  135.      *
  136.      * @throws java.lang.Exception Thrown if inputs are invalid
  137.      */

  138.     public BracketingControlParams (
  139.         final int iNumExpansions,
  140.         final double dblVariateStart,
  141.         final double dblBracketStartingWidth,
  142.         final double dblBracketWidthExpansionFactor)
  143.         throws java.lang.Exception
  144.     {
  145.         if (0 >= (_iNumExpansions = iNumExpansions) || !org.drip.numerical.common.NumberUtil.IsValid
  146.             (_dblVariateStart = dblVariateStart) || !org.drip.numerical.common.NumberUtil.IsValid
  147.                 (_dblBracketStartingWidth = dblBracketStartingWidth) ||
  148.                     !org.drip.numerical.common.NumberUtil.IsValid (_dblBracketWidthExpansionFactor =
  149.                         dblBracketWidthExpansionFactor))
  150.             throw new java.lang.Exception ("BracketingControlParams constructor: Invalid inputs!");
  151.     }

  152.     /**
  153.      * Return the number of expansions
  154.      *
  155.      * @return Number of expansions
  156.      */

  157.     public int getNumExpansions()
  158.     {
  159.         return _iNumExpansions;
  160.     }

  161.     /**
  162.      * Return the starting point of bracketing determination
  163.      *
  164.      * @return Starting point of bracketing determination
  165.      */

  166.     public double getVariateStart()
  167.     {
  168.         return _dblVariateStart;
  169.     }

  170.     /**
  171.      * Return the initial bracket width
  172.      *
  173.      * @return Initial bracket width
  174.      */

  175.     public double getStartingBracketWidth()
  176.     {
  177.         return _dblBracketStartingWidth;
  178.     }

  179.     /**
  180.      * Return the bracket width expansion factor
  181.      *
  182.      * @return Bracket width expansion factor
  183.      */

  184.     public double getBracketWidthExpansionFactor()
  185.     {
  186.         return _dblBracketWidthExpansionFactor;
  187.     }
  188. }