LineStepEvolutionControl.java

  1. package org.drip.function.rdtor1descent;

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

  77. /**
  78.  * <i>LineStepEvolutionControl</i> contains the Parameters required to compute the Valid a Line Step. The
  79.  * References are:
  80.  * <br><br>
  81.  *  <ul>
  82.  *      <li>
  83.  *          Armijo, L. (1966): Minimization of Functions having Lipschitz-Continuous First Partial
  84.  *              Derivatives <i>Pacific Journal of Mathematics</i> <b>16 (1)</b> 1-3
  85.  *      </li>
  86.  *      <li>
  87.  *          Nocedal, J., and S. Wright (1999): <i>Numerical Optimization</i> <b>Wiley</b>
  88.  *      </li>
  89.  *      <li>
  90.  *          Wolfe, P. (1969): Convergence Conditions for Ascent Methods <i>SIAM Review</i> <b>11 (2)</b>
  91.  *              226-235
  92.  *      </li>
  93.  *      <li>
  94.  *          Wolfe, P. (1971): Convergence Conditions for Ascent Methods; II: Some Corrections <i>SIAM
  95.  *              Review</i> <b>13 (2)</b> 185-188
  96.  *      </li>
  97.  *  </ul>
  98.  *
  99.  *  <br><br>
  100.  *  <ul>
  101.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  102.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalAnalysisLibrary.md">Numerical Analysis Library</a></li>
  103.  *      <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>
  104.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/function/rdtor1descent/README.md">R<sup>d</sup> To R<sup>1</sup> Gradient Descent Techniques</a></li>
  105.  *  </ul>
  106.  *
  107.  * @author Lakshmi Krishnamurthy
  108.  */

  109. public class LineStepEvolutionControl
  110. {
  111.     private int _reductionStepCount = -1;
  112.     private double _reductionFactor = java.lang.Double.NaN;
  113.     private org.drip.function.rdtor1descent.LineEvolutionVerifier _lineEvolutionVerifier = null;

  114.     /**
  115.      * Retrieve the Nocedal-Wright-Armijo Verifier Based Standard LineStepEvolutionControl Instance
  116.      *
  117.      * @param maximizerCheck TRUE - Perform a Check for the Function Maxima
  118.      *
  119.      * @return The Nocedal-Wright-Armijo Verifier Based Standard LineStepEvolutionControl Instance
  120.      */

  121.     public static final LineStepEvolutionControl NocedalWrightArmijo (
  122.         final boolean maximizerCheck)
  123.     {
  124.         try
  125.         {
  126.             return new LineStepEvolutionControl (
  127.                 org.drip.function.rdtor1descent.ArmijoEvolutionVerifier.NocedalWrightStandard (
  128.                     maximizerCheck
  129.                 ),
  130.                 0.75,
  131.                 1
  132.             );
  133.         }
  134.         catch (java.lang.Exception e)
  135.         {
  136.             e.printStackTrace();
  137.         }

  138.         return null;
  139.     }

  140.     /**
  141.      * Retrieve the Nocedal-Wright-Weak Curvature Verifier Based Standard LineStepEvolutionControl Instance
  142.      *
  143.      * @return The Nocedal-Wright-Weak Curvature Verifier Based Standard LineStepEvolutionControl Instance
  144.      */

  145.     public static final LineStepEvolutionControl NocedalWrightWeakCurvature()
  146.     {
  147.         try
  148.         {
  149.             return new LineStepEvolutionControl (
  150.                 org.drip.function.rdtor1descent.CurvatureEvolutionVerifier.NocedalWrightStandard (
  151.                     false
  152.                 ),
  153.                 0.75,
  154.                 1
  155.             );
  156.         }
  157.         catch (java.lang.Exception e)
  158.         {
  159.             e.printStackTrace();
  160.         }

  161.         return null;
  162.     }

  163.     /**
  164.      * Retrieve the Nocedal-Wright-Strong Curvature Verifier Based Standard LineStepEvolutionControl Instance
  165.      *
  166.      * @return The Nocedal-Wright-Strong Curvature Verifier Based Standard LineStepEvolutionControl Instance
  167.      */

  168.     public static final LineStepEvolutionControl NocedalWrightStrongCurvature()
  169.     {
  170.         try
  171.         {
  172.             return new LineStepEvolutionControl (
  173.                 org.drip.function.rdtor1descent.CurvatureEvolutionVerifier.NocedalWrightStandard (
  174.                     true
  175.                 ),
  176.                 0.75,
  177.                 1
  178.             );
  179.         }
  180.         catch (java.lang.Exception e)
  181.         {
  182.             e.printStackTrace();
  183.         }

  184.         return null;
  185.     }

  186.     /**
  187.      * Retrieve the Nocedal-Wright-Weak Wolfe Verifier Based Standard LineStepEvolutionControl Instance
  188.      *
  189.      * @param maximizerCheck TRUE - Perform a Check for the Function Maxima
  190.      *
  191.      * @return The Nocedal-Wright-Weak Wolfe Verifier Based Standard LineStepEvolutionControl Instance
  192.      */

  193.     public static final LineStepEvolutionControl NocedalWrightWeakWolfe (
  194.         final boolean maximizerCheck)
  195.     {
  196.         try
  197.         {
  198.             return new LineStepEvolutionControl (
  199.                 org.drip.function.rdtor1descent.WolfeEvolutionVerifier.NocedalWrightStandard (
  200.                     maximizerCheck,
  201.                     false
  202.                 ),
  203.                 0.75,
  204.                 1
  205.             );
  206.         }
  207.         catch (java.lang.Exception e)
  208.         {
  209.             e.printStackTrace();
  210.         }

  211.         return null;
  212.     }

  213.     /**
  214.      * Retrieve the Nocedal-Wright-Strong Wolfe Verifier Based Standard LineStepEvolutionControl Instance
  215.      *
  216.      * @param maximizerCheck TRUE - Perform a Check for the Function Maxima
  217.      *
  218.      * @return The Nocedal-Wright-Strong Wolfe Verifier Based Standard LineStepEvolutionControl Instance
  219.      */

  220.     public static final LineStepEvolutionControl NocedalWrightStrongWolfe (
  221.         final boolean maximizerCheck)
  222.     {
  223.         try
  224.         {
  225.             return new LineStepEvolutionControl (
  226.                 org.drip.function.rdtor1descent.WolfeEvolutionVerifier.NocedalWrightStandard (
  227.                     maximizerCheck,
  228.                     true
  229.                 ),
  230.                 0.75,
  231.                 1
  232.             );
  233.         }
  234.         catch (java.lang.Exception e)
  235.         {
  236.             e.printStackTrace();
  237.         }

  238.         return null;
  239.     }

  240.     /**
  241.      * LineStepEvolutionControl Constructor
  242.      *
  243.      * @param lineEvolutionVerifier The Line Evolution Verifier Instance
  244.      * @param reductionFactor The Per-Step Reduction Factor
  245.      * @param reductionStepCount Count of Reduction Steps
  246.      *
  247.      * @throws java.lang.Exception Thrown if Inputs are Invalid
  248.      */

  249.     public LineStepEvolutionControl (
  250.         final org.drip.function.rdtor1descent.LineEvolutionVerifier lineEvolutionVerifier,
  251.         final double reductionFactor,
  252.         final int reductionStepCount)
  253.         throws java.lang.Exception
  254.     {
  255.         if (null == (_lineEvolutionVerifier = lineEvolutionVerifier) ||
  256.             !org.drip.numerical.common.NumberUtil.IsValid (_reductionFactor = reductionFactor) ||
  257.                 1. <= _reductionFactor ||
  258.             0 >= (_reductionStepCount = reductionStepCount))
  259.         {
  260.             throw new java.lang.Exception ("LineStepEvolutionControl Constructor => Invalid Inputs");
  261.         }
  262.     }

  263.     /**
  264.      * Retrieve the Line Evolution Verifier Instance
  265.      *
  266.      * @return The Line Evolution Verifier Instance
  267.      */

  268.     public org.drip.function.rdtor1descent.LineEvolutionVerifier lineEvolutionVerifier()
  269.     {
  270.         return _lineEvolutionVerifier;
  271.     }

  272.     /**
  273.      * Retrieve the Reduction Factor per Step
  274.      *
  275.      * @return The Reduction Factor per Step
  276.      */

  277.     public double reductionFactor()
  278.     {
  279.         return _reductionFactor;
  280.     }

  281.     /**
  282.      * Retrieve the Count of Reduction Steps
  283.      *
  284.      * @return The Count of Reduction Steps
  285.      */

  286.     public int reductionStepCount()
  287.     {
  288.         return _reductionStepCount;
  289.     }
  290. }