RegularityConditions.java

  1. package org.drip.optimization.constrained;

  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>RegularityConditions</i> holds the Results of the Verification of the Regularity Conditions/Constraint
  79.  * Qualifications at the specified (possibly) Optimal Variate and the corresponding Fritz John Multipliers.
  80.  * The References are:
  81.  *
  82.  * <br><br>
  83.  *  <ul>
  84.  *      <li>
  85.  *          Boyd, S., and L. van den Berghe (2009): <i>Convex Optimization</i> <b>Cambridge University
  86.  *              Press</b> Cambridge UK
  87.  *      </li>
  88.  *      <li>
  89.  *          Eustaquio, R., E. Karas, and A. Ribeiro (2008): <i>Constraint Qualification for Nonlinear
  90.  *              Programming</i> <b>Federal University of Parana</b>
  91.  *      </li>
  92.  *      <li>
  93.  *          Karush, A. (1939): <i>Minima of Functions of Several Variables with Inequalities as Side
  94.  *          Constraints</i> <b>University of Chicago</b> Chicago IL
  95.  *      </li>
  96.  *      <li>
  97.  *          Kuhn, H. W., and A. W. Tucker (1951): Nonlinear Programming <i>Proceedings of the Second Berkeley
  98.  *              Symposium</i> <b>University of California</b> Berkeley CA 481-492
  99.  *      </li>
  100.  *      <li>
  101.  *          Ruszczynski, A. (2006): <i>Nonlinear Optimization</i> <b>Princeton University Press</b> Princeton
  102.  *              NJ
  103.  *      </li>
  104.  *  </ul>
  105.  *
  106.  *  <br><br>
  107.  *  <ul>
  108.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  109.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalOptimizerLibrary.md">Numerical Optimizer Library</a></li>
  110.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/optimization/README.md">Necessary, Sufficient, and Regularity Checks for Gradient Descent in a Constrained Optimization Setup</a></li>
  111.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/optimization/constrained/README.md">KKT Fritz-John Constrained Optimizer</a></li>
  112.  *  </ul>
  113.  *
  114.  * @author Lakshmi Krishnamurthy
  115.  */

  116. public class RegularityConditions {
  117.     private double[] _adblVariate = null;
  118.     private org.drip.optimization.constrained.FritzJohnMultipliers _fjm = null;
  119.     private org.drip.optimization.regularity.ConstraintQualifierLCQ _cqLCQ = null;
  120.     private org.drip.optimization.regularity.ConstraintQualifierCRCQ _cqCRCQ = null;
  121.     private org.drip.optimization.regularity.ConstraintQualifierLICQ _cqLICQ = null;
  122.     private org.drip.optimization.regularity.ConstraintQualifierMFCQ _cqMFCQ = null;
  123.     private org.drip.optimization.regularity.ConstraintQualifierQNCQ _cqQNCQ = null;
  124.     private org.drip.optimization.regularity.ConstraintQualifierSCCQ _cqSCCQ = null;
  125.     private org.drip.optimization.regularity.ConstraintQualifierCPLDCQ _cqCPLDCQ = null;

  126.     /**
  127.      * Construct a Standard Instance of RegularityConditions
  128.      *
  129.      * @param adblVariate The Candidate Variate Array
  130.      * @param fjm The Fritz John Multipliers
  131.      * @param bValidLCQ The LCQ Validity Flag
  132.      * @param bValidLICQ The LICQ Validity Flag
  133.      * @param bValidMFCQ The MFCQ Validity Flag
  134.      * @param bValidCRCQ The CRCQ Validity Flag
  135.      * @param bValidCPLDCQ The CPLDCQ Validity Flag
  136.      * @param bValidQNCQ The QNCQ Validity Flag
  137.      * @param bValidSCCQ The SCCQ Validity Flag
  138.      *
  139.      * @return The Standard Instance of CandidateRegularity
  140.      */

  141.     public static final RegularityConditions Standard (
  142.         final double[] adblVariate,
  143.         final org.drip.optimization.constrained.FritzJohnMultipliers fjm,
  144.         final boolean bValidLCQ,
  145.         final boolean bValidLICQ,
  146.         final boolean bValidMFCQ,
  147.         final boolean bValidCRCQ,
  148.         final boolean bValidCPLDCQ,
  149.         final boolean bValidQNCQ,
  150.         final boolean bValidSCCQ)
  151.     {
  152.         try {
  153.             return new RegularityConditions (adblVariate, fjm, new
  154.                 org.drip.optimization.regularity.ConstraintQualifierLCQ (bValidLCQ), new
  155.                     org.drip.optimization.regularity.ConstraintQualifierLICQ (bValidLICQ), new
  156.                         org.drip.optimization.regularity.ConstraintQualifierMFCQ (bValidMFCQ), new
  157.                             org.drip.optimization.regularity.ConstraintQualifierCRCQ (bValidCRCQ), new
  158.                                 org.drip.optimization.regularity.ConstraintQualifierCPLDCQ (bValidCPLDCQ),
  159.                                     new org.drip.optimization.regularity.ConstraintQualifierQNCQ
  160.                                         (bValidQNCQ), new
  161.                                             org.drip.optimization.regularity.ConstraintQualifierSCCQ
  162.                                                 (bValidSCCQ));
  163.         } catch (java.lang.Exception e) {
  164.             e.printStackTrace();
  165.         }

  166.         return null;
  167.     }

  168.     /**
  169.      * RegularityConditions Constructor
  170.      *
  171.      * @param adblVariate The Candidate Variate Array
  172.      * @param fjm The Fritz John Multipliers
  173.      * @param cqLCQ LCQ Constraint Qualifier Instance
  174.      * @param cqLICQ LICQ Constraint Qualifier Instance
  175.      * @param cqMFCQ MFCQ Constraint Qualifier Instance
  176.      * @param cqCRCQ CRCQ Constraint Qualifier Instance
  177.      * @param cqCPLDCQ CPLDCQ Constraint Qualifier Instance
  178.      * @param cqQNCQ QNCQ Constraint Qualifier Instance
  179.      * @param cqSCCQ SCCQ Constraint Qualifier Instance
  180.      *
  181.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  182.      */

  183.     public RegularityConditions (
  184.         final double[] adblVariate,
  185.         final org.drip.optimization.constrained.FritzJohnMultipliers fjm,
  186.         final org.drip.optimization.regularity.ConstraintQualifierLCQ cqLCQ,
  187.         final org.drip.optimization.regularity.ConstraintQualifierLICQ cqLICQ,
  188.         final org.drip.optimization.regularity.ConstraintQualifierMFCQ cqMFCQ,
  189.         final org.drip.optimization.regularity.ConstraintQualifierCRCQ cqCRCQ,
  190.         final org.drip.optimization.regularity.ConstraintQualifierCPLDCQ cqCPLDCQ,
  191.         final org.drip.optimization.regularity.ConstraintQualifierQNCQ cqQNCQ,
  192.         final org.drip.optimization.regularity.ConstraintQualifierSCCQ cqSCCQ)
  193.         throws java.lang.Exception
  194.     {
  195.         if (null == (_adblVariate = adblVariate) || 0 == _adblVariate.length || null == (_fjm = fjm) || null
  196.             == (_cqLCQ = cqLCQ) || null == (_cqLICQ = cqLICQ) || null == (_cqMFCQ = cqMFCQ) || null ==
  197.                 (_cqCRCQ = cqCRCQ) || null == (_cqCPLDCQ = cqCPLDCQ) || null == (_cqQNCQ = cqQNCQ) || null ==
  198.                     (_cqSCCQ = cqSCCQ))
  199.             throw new java.lang.Exception ("RegularityConditions Constructor => Invalid Inputs");
  200.     }

  201.     /**
  202.      * Retrieve the Candidate Variate Array
  203.      *
  204.      * @return The Candidate Variate Array
  205.      */

  206.     public double[] variate()
  207.     {
  208.         return _adblVariate;
  209.     }

  210.     /**
  211.      * Retrieve the Fritz John Mutipliers
  212.      *
  213.      * @return The Fritz John Mutipliers
  214.      */

  215.     public org.drip.optimization.constrained.FritzJohnMultipliers fjm()
  216.     {
  217.         return _fjm;
  218.     }

  219.     /**
  220.      * Retrieve the LCQ Constraint Qualifier
  221.      *
  222.      * @return The LCQ Constraint Qualifier
  223.      */

  224.     public org.drip.optimization.regularity.ConstraintQualifierLCQ lcq()
  225.     {
  226.         return _cqLCQ;
  227.     }

  228.     /**
  229.      * Retrieve the LICQ Constraint Qualifier
  230.      *
  231.      * @return The LICQ Constraint Qualifier
  232.      */

  233.     public org.drip.optimization.regularity.ConstraintQualifierLICQ licq()
  234.     {
  235.         return _cqLICQ;
  236.     }

  237.     /**
  238.      * Retrieve the MFCQ Constraint Qualifier
  239.      *
  240.      * @return The MFCQ Constraint Qualifier
  241.      */

  242.     public org.drip.optimization.regularity.ConstraintQualifierMFCQ mfcq()
  243.     {
  244.         return _cqMFCQ;
  245.     }

  246.     /**
  247.      * Retrieve the CRCQ Constraint Qualifier
  248.      *
  249.      * @return The CRCQ Constraint Qualifier
  250.      */

  251.     public org.drip.optimization.regularity.ConstraintQualifierCRCQ crcq()
  252.     {
  253.         return _cqCRCQ;
  254.     }

  255.     /**
  256.      * Retrieve the CPLDCQ Constraint Qualifier
  257.      *
  258.      * @return The CPLDCQ Constraint Qualifier
  259.      */

  260.     public org.drip.optimization.regularity.ConstraintQualifierCPLDCQ cpldcq()
  261.     {
  262.         return _cqCPLDCQ;
  263.     }

  264.     /**
  265.      * Retrieve the QNCQ Constraint Qualifier
  266.      *
  267.      * @return The QNCQ Constraint Qualifier
  268.      */

  269.     public org.drip.optimization.regularity.ConstraintQualifierQNCQ qncq()
  270.     {
  271.         return _cqQNCQ;
  272.     }

  273.     /**
  274.      * Retrieve the SCCQ Constraint Qualifier
  275.      *
  276.      * @return The SCCQ Constraint Qualifier
  277.      */

  278.     public org.drip.optimization.regularity.ConstraintQualifierSCCQ sccq()
  279.     {
  280.         return _cqSCCQ;
  281.     }

  282.     /**
  283.      * Indicate the Ordered Gross Regularity Validity across all the Constraint Qualifiers
  284.      *
  285.      * @return TRUE - The Ordered Regularity Criteria is satisfied across all the Constraint Qualifiers
  286.      */

  287.     public boolean valid()
  288.     {
  289.         return _cqLICQ.valid() && _cqCRCQ.valid() && _cqMFCQ.valid() && _cqCPLDCQ.valid() && _cqQNCQ.valid();
  290.     }

  291.     /**
  292.      * Retrieve the Array of Strength Orders as specified in Eustaquio, Karas, and Ribeiro (2008)
  293.      *
  294.      * @return The Array of Strength Orders as specified in Eustaquio, Karas, and Ribeiro (2008)
  295.      */

  296.     public java.lang.String[] strengthOrder()
  297.     {
  298.         return new java.lang.String[] {"EUSTAQUIO KARAS RIBEIRO STRENGTH ORDER #1: " + _cqLICQ.display() +
  299.             " >> " + _cqMFCQ.display() + " >> " + _cqCPLDCQ.display() + " >> " + _cqQNCQ.display(),
  300.                 "EUSTAQUIO KARAS RIBEIRO STRENGTH ORDER #2: " + _cqLICQ.display() + " >> " +
  301.                     _cqCRCQ.display() + " >> " + _cqCPLDCQ.display() + " >> " + _cqQNCQ.display(),
  302.                         "EUSTAQUIO KARAS RIBEIRO STRENGTH ORDER #3: " + _cqLCQ.display() + " >> " +
  303.                             _cqLICQ.display() + " >> " + _cqMFCQ.display() + " >> " + _cqCRCQ.display() +
  304.                                 " >> " + _cqCPLDCQ.display() + " >> " + _cqQNCQ.display() + " >> " + " >> " +
  305.                                     _cqSCCQ.display()};
  306.     }
  307. }