Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
Bug Fixes/Re-organization:

Samples:

	- Spline Params Stretch Best Fit Response - Create (1, 2, 3)
	- Spline Params Stretch Best Fit Response - Constructor (4, 5, 6)
	- Spline Params Stretch Best Fit Response - Normalize Weights (7, 8, 9)
	- Spline Params Stretch Best Fit Response - Weights (10, 11)
	- Spline Params Stretch Best Fit Response - Predictor Ordinate (12, 13, 14)
	- Spline Params Stretch Best Fit Response - Response Array (15, 16, 17)
	- Spline Params Stretch Best Fit Response - Point Count (18)
	- Spline Params Stretch Best Fit Response - Size To Segment (19, 20, 21)
	- Segment Flexure Penalty Control (22, 23, 24)
	- Segment Flexure Penalty Control - Derivative Order (25, 26)
	- Segment Flexure Penalty Control - Amplitude (27, 28)
	- Segment Flexure Penalty Control - Constructor (29, 30)
	- Spline Params Segment State Calibration Inputs (31, 32)
	- Spline Params Segment State Calibration Inputs - Response Value Array (33, 34)
	- Spline Params Segment State Calibration Inputs - Left Edge Derivative Array (35, 36)
	- Spline Params Segment State Calibration Inputs - Right Edge Derivative Array (37, 38)
	- Spline Params Segment State Calibration Inputs - Predictor Ordinate Array (39, 40)
	- Spline Params Segment State Calibration Inputs - Segment Best Fit Response (41, 42)
	- Spline Params Segment State Calibration Inputs - Segment Basis Flexure Constraint Array (43, 44)
	- Spline Params Segment State Calibration Inputs - Constructor (45, 46, 47)
	- Spline Params Segment Response Value Constraint (48, 49, 50)
	- Spline Params Segment Response Value Constraint - Left Of (51)
	- Spline Params Segment Response Value Constraint - Right Of (52)
	- Spline Params Segment Response Value Constraint - Splits (53)
	- Spline Params Segment Response Value Constraint - Predictor Ordinate Array (54, 55)
	- Spline Params Segment Response Value Constraint - Weight Array (56, 57)
	- Spline Params Segment Response Value Constraint - Weighted (58, 59)
	- Spline Params Segment Response Value Constraint - From Predictor Pair (60)


IdeaDRIP:
  • Loading branch information
Lakshmik committed Jan 7, 2024
1 parent 7b3dfad commit 0a229c7
Show file tree
Hide file tree
Showing 6 changed files with 311 additions and 226 deletions.
38 changes: 38 additions & 0 deletions ReleaseNotes/04_18_2023.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

Features:

Bug Fixes/Re-organization:

Samples:

- Spline Params Stretch Best Fit Response - Create (1, 2, 3)
- Spline Params Stretch Best Fit Response - Constructor (4, 5, 6)
- Spline Params Stretch Best Fit Response - Normalize Weights (7, 8, 9)
- Spline Params Stretch Best Fit Response - Weights (10, 11)
- Spline Params Stretch Best Fit Response - Predictor Ordinate (12, 13, 14)
- Spline Params Stretch Best Fit Response - Response Array (15, 16, 17)
- Spline Params Stretch Best Fit Response - Point Count (18)
- Spline Params Stretch Best Fit Response - Size To Segment (19, 20, 21)
- Segment Flexure Penalty Control (22, 23, 24)
- Segment Flexure Penalty Control - Derivative Order (25, 26)
- Segment Flexure Penalty Control - Amplitude (27, 28)
- Segment Flexure Penalty Control - Constructor (29, 30)
- Spline Params Segment State Calibration Inputs (31, 32)
- Spline Params Segment State Calibration Inputs - Response Value Array (33, 34)
- Spline Params Segment State Calibration Inputs - Left Edge Derivative Array (35, 36)
- Spline Params Segment State Calibration Inputs - Right Edge Derivative Array (37, 38)
- Spline Params Segment State Calibration Inputs - Predictor Ordinate Array (39, 40)
- Spline Params Segment State Calibration Inputs - Segment Best Fit Response (41, 42)
- Spline Params Segment State Calibration Inputs - Segment Basis Flexure Constraint Array (43, 44)
- Spline Params Segment State Calibration Inputs - Constructor (45, 46, 47)
- Spline Params Segment Response Value Constraint (48, 49, 50)
- Spline Params Segment Response Value Constraint - Left Of (51)
- Spline Params Segment Response Value Constraint - Right Of (52)
- Spline Params Segment Response Value Constraint - Splits (53)
- Spline Params Segment Response Value Constraint - Predictor Ordinate Array (54, 55)
- Spline Params Segment Response Value Constraint - Weight Array (56, 57)
- Spline Params Segment Response Value Constraint - Weighted (58, 59)
- Spline Params Segment Response Value Constraint - From Predictor Pair (60)


IdeaDRIP:
Binary file modified ScheduleSheet.xlsx
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

package org.drip.spline.params;

import org.drip.numerical.common.NumberUtil;

/*
* -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*/
Expand Down Expand Up @@ -84,42 +86,56 @@

/**
* <i>SegmentFlexurePenaltyControl</i> implements basis per-segment Flexure Penalty Parameter Set. Currently
* it contains the Flexure Penalty Derivative Order and the Roughness Coefficient Amplitude. Flexure Penalty
* Control may be used to implement Segment Curvature Control and/or Segment Length Control.
* it contains the Flexure Penalty Derivative Order and the Roughness Coefficient Amplitude. Flexure Penalty
* Control may be used to implement Segment Curvature Control and/or Segment Length Control.
*
* <br><br>
* <br>
* <ul>
* <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
* <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/SplineBuilderLibrary.md">Spline Builder Library</a></li>
* <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/spline/README.md">Basis Splines and Linear Compounders across a Broad Family of Spline Basis Functions</a></li>
* <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/spline/params/README.md">Spline Segment Construction Control Parameters</a></li>
* <li><i>SegmentFlexurePenaltyControl</i> constructor</li>
* <li>Retrieve the Derivative Order</li>
* <li>Retrieve the Roughness Curvature Penalty Amplitude</li>
* </ul>
* <br><br>
*
* <br>
* <style>table, td, th {
* padding: 1px; border: 2px solid #008000; border-radius: 8px; background-color: #dfff00;
* text-align: center; color: #0000ff;
* }
* </style>
*
* <table style="border:1px solid black;margin-left:auto;margin-right:auto;">
* <tr><td><b>Module </b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></td></tr>
* <tr><td><b>Library</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></td></tr>
* <tr><td><b>Project</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/spline/README.md">Basis Splines and Linear Compounders across a Broad Family of Spline Basis Functions</a></td></tr>
* <tr><td><b>Package</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/spline/params/README.md">Spline Segment Construction Control Parameters</a></td></tr>
* </table>
* <br>
*
* @author Lakshmi Krishnamurthy
*/

public class SegmentFlexurePenaltyControl {
private int _iDerivativeOrder = -1;
private double _dblAmplitude = java.lang.Double.NaN;
public class SegmentFlexurePenaltyControl
{
private double _amplitude = Double.NaN;
private int _derivativeOrder = Integer.MIN_VALUE;

/**
* SegmentFlexurePenaltyControl constructor
* <i>SegmentFlexurePenaltyControl</i> constructor
*
* @param iDerivativeOrder Roughness Penalty Derivative Order
* @param dblAmplitude Roughness Curvature Penalty Amplitude
* @param derivativeOrder Roughness Penalty Derivative Order
* @param amplitude Roughness Curvature Penalty Amplitude
*
* @throws java.lang.Exception Thrown if the inputs are invalid
* @throws Exception Thrown if the inputs are invalid
*/

public SegmentFlexurePenaltyControl (
final int iDerivativeOrder,
final double dblAmplitude)
throws java.lang.Exception
final int derivativeOrder,
final double amplitude)
throws Exception
{
if (0 >= (_iDerivativeOrder = iDerivativeOrder) || !org.drip.numerical.common.NumberUtil.IsValid
(_dblAmplitude = dblAmplitude))
throw new java.lang.Exception ("SegmentFlexurePenaltyControl ctr: Invalid Inputs");
if (0 >= (_derivativeOrder = derivativeOrder) || !NumberUtil.IsValid (_amplitude = amplitude)) {
throw new Exception ("SegmentFlexurePenaltyControl ctr: Invalid Inputs");
}
}

/**
Expand All @@ -130,7 +146,7 @@ public SegmentFlexurePenaltyControl (

public int derivativeOrder()
{
return _iDerivativeOrder;
return _derivativeOrder;
}

/**
Expand All @@ -141,6 +157,6 @@ public int derivativeOrder()

public double amplitude()
{
return _dblAmplitude;
return _amplitude;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

package org.drip.spline.params;

import org.drip.numerical.common.NumberUtil;

/*
* -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*/
Expand Down Expand Up @@ -96,45 +98,41 @@
*
* SegmentResponseValueConstraint exports the following functionality:
*
* <br><br>
* <br>
* <ul>
* <li>
* Retrieve the Array of Predictor Ordinates.
* </li>
* <li>
* Retrieve the Array of Response Weights at each Predictor Ordinate.
* </li>
* <li>
* Retrieve the Constraint Value.
* </li>
* <li>
* Convert the Segment Constraint onto Local Predictor Ordinates, the corresponding Response Basis
* Function, and the Shape Controller Realizations.
* </li>
* <li>
* Get the Position of the Predictor Knot relative to the Constraints.
* </li>
* <li>
* Generate a SegmentResponseValueConstraint instance from the given predictor/response pair.
* </li>
* <li>Indicator specifying that the knot is to the left of the constraint ordinates</li>
* <li>Indicator specifying that the knot is to the right of the constraint ordinates</li>
* <li>Indicator specifying that the knot splits the constraint ordinates</li>
* <li>Generate a SegmentResponseValueConstraint instance from the given predictor/response pair</li>
* <li>SegmentResponseValueConstraint constructor</li>
* <li>Retrieve the Array of Predictor Ordinates</li>
* <li>Retrieve the Array of Response Weights at each Predictor Ordinate</li>
* <li>Retrieve the Constraint Value</li>
* <li>Display the Comment Annotated State</li>
* <li>Convert the Segment Constraint onto Local Predictor Ordinates, the corresponding Response Basis Function, and the Shape Controller Realizations</li>
* <li>Get the Position of the Predictor Knot relative to the Constraints</li>
* </ul>
*
* SegmentResponseValueConstraint can be viewed as the global response point value transform of
* SegmentBasisFlexureConstraint.
*
* <br><br>
* <ul>
* <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
* <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/SplineBuilderLibrary.md">Spline Builder Library</a></li>
* <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/spline/README.md">Basis Splines and Linear Compounders across a Broad Family of Spline Basis Functions</a></li>
* <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/spline/params/README.md">Spline Segment Construction Control Parameters</a></li>
* </ul>
* <br><br>
* <br>
* <style>table, td, th {
* padding: 1px; border: 2px solid #008000; border-radius: 8px; background-color: #dfff00;
* text-align: center; color: #0000ff;
* }
* </style>
*
* <table style="border:1px solid black;margin-left:auto;margin-right:auto;">
* <tr><td><b>Module </b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></td></tr>
* <tr><td><b>Library</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></td></tr>
* <tr><td><b>Project</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/spline/README.md">Basis Splines and Linear Compounders across a Broad Family of Spline Basis Functions</a></td></tr>
* <tr><td><b>Package</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/spline/params/README.md">Spline Segment Construction Control Parameters</a></td></tr>
* </table>
* <br>
*
* @author Lakshmi Krishnamurthy
*/

public class SegmentResponseValueConstraint {
public class SegmentResponseValueConstraint
{

/**
* Indicator specifying that the knot is to the left of the constraint ordinates
Expand All @@ -154,31 +152,31 @@ public class SegmentResponseValueConstraint {

public static final int SPLITS_CONSTRAINT = 4;

private double[] _adblPredictorOrdinate = null;
private double[] _adblResponseValueWeight = null;
private double _dblWeightedResponseValueConstraint = java.lang.Double.NaN;
private double[] _predictorOrdinateArray = null;
private double[] _responseValueWeightArray = null;
private double _weightedResponseValueConstraint = Double.NaN;

/**
* Generate a SegmentResponseValueConstraint instance from the given predictor/response pair.
*
* @param dblPredictorOrdinate The Predictor Ordinate
* @param dblResponseValue The Response Value
* @param predictorOrdinate The Predictor Ordinate
* @param responseValue The Response Value
*
* @return The SegmentResponseValueConstraint instance
*/

public static final SegmentResponseValueConstraint FromPredictorResponsePair (
final double dblPredictorOrdinate,
final double dblResponseValue)
final double predictorOrdinate,
final double responseValue)
{
if (!org.drip.numerical.common.NumberUtil.IsValid (dblPredictorOrdinate) ||
!org.drip.numerical.common.NumberUtil.IsValid (dblResponseValue))
return null;

try {
return new SegmentResponseValueConstraint (new double[] {dblPredictorOrdinate}, new double[]
{1.}, dblResponseValue);
} catch (java.lang.Exception e) {
return !NumberUtil.IsValid (predictorOrdinate) || !NumberUtil.IsValid (responseValue) ? null :
new SegmentResponseValueConstraint (
new double[] {predictorOrdinate},
new double[] {1.},
responseValue
);
} catch (Exception e) {
e.printStackTrace();
}

Expand All @@ -202,14 +200,14 @@ public SegmentResponseValueConstraint (
final double dblWeightedResponseValueConstraint)
throws java.lang.Exception
{
if (null == (_adblPredictorOrdinate = adblPredictorOrdinate) || null == (_adblResponseValueWeight =
if (null == (_predictorOrdinateArray = adblPredictorOrdinate) || null == (_responseValueWeightArray =
adblResponseValueWeight) || !org.drip.numerical.common.NumberUtil.IsValid
(_dblWeightedResponseValueConstraint = dblWeightedResponseValueConstraint))
(_weightedResponseValueConstraint = dblWeightedResponseValueConstraint))
throw new java.lang.Exception ("SegmentResponseValueConstraint ctr: Invalid Inputs");

int iNumPredictorOrdinate = adblPredictorOrdinate.length;

if (0 == iNumPredictorOrdinate || _adblResponseValueWeight.length != iNumPredictorOrdinate)
if (0 == iNumPredictorOrdinate || _responseValueWeightArray.length != iNumPredictorOrdinate)
throw new java.lang.Exception ("SegmentResponseValueConstraint ctr: Invalid Inputs");
}

Expand All @@ -221,7 +219,7 @@ public SegmentResponseValueConstraint (

public double[] predictorOrdinates()
{
return _adblPredictorOrdinate;
return _predictorOrdinateArray;
}

/**
Expand All @@ -232,7 +230,7 @@ public double[] predictorOrdinates()

public double[] responseWeights()
{
return _adblResponseValueWeight;
return _responseValueWeightArray;
}

/**
Expand All @@ -243,7 +241,7 @@ public double[] responseWeights()

public double constraintValue()
{
return _dblWeightedResponseValueConstraint;
return _weightedResponseValueConstraint;
}

/**
Expand All @@ -255,11 +253,11 @@ public double constraintValue()
public void display (
final java.lang.String strComment)
{
for (int i = 0; i < _adblPredictorOrdinate.length; ++i)
for (int i = 0; i < _predictorOrdinateArray.length; ++i)
System.out.println ("\t\t" + strComment + " - " + new org.drip.analytics.date.JulianDate ((int)
_adblPredictorOrdinate[i]) + " => " + _adblResponseValueWeight[i]);
_predictorOrdinateArray[i]) + " => " + _responseValueWeightArray[i]);

System.out.println ("\tConstraint: " + _dblWeightedResponseValueConstraint);
System.out.println ("\tConstraint: " + _weightedResponseValueConstraint);
}

/**
Expand All @@ -280,7 +278,7 @@ public org.drip.spline.params.SegmentBasisFlexureConstraint responseIndexedBasis

int iNumResponseBasis = lbe.numBasis();

int iNumPredictorOrdinate = _adblPredictorOrdinate.length;
int iNumPredictorOrdinate = _predictorOrdinateArray.length;
double[] adblResponseBasisWeight = new double[iNumResponseBasis];

if (0 == iNumResponseBasis) return null;
Expand All @@ -290,12 +288,12 @@ public org.drip.spline.params.SegmentBasisFlexureConstraint responseIndexedBasis
adblResponseBasisWeight[i] = 0.;

for (int j = 0; j < iNumPredictorOrdinate; ++j)
adblResponseBasisWeight[i] += _adblResponseValueWeight[j] *
lbe.shapedBasisFunctionResponse (_adblPredictorOrdinate[j], i);
adblResponseBasisWeight[i] += _responseValueWeightArray[j] *
lbe.shapedBasisFunctionResponse (_predictorOrdinateArray[j], i);
}

return new org.drip.spline.params.SegmentBasisFlexureConstraint (adblResponseBasisWeight,
_dblWeightedResponseValueConstraint);
_weightedResponseValueConstraint);
} catch (java.lang.Exception e) {
e.printStackTrace();
}
Expand All @@ -321,9 +319,9 @@ public int knotPosition (
if (!org.drip.numerical.common.NumberUtil.IsValid (dblPredictorKnot))
throw new java.lang.Exception ("SegmentResponseValueConstraint::knotPosition => Invalid Inputs");

if (dblPredictorKnot < _adblPredictorOrdinate[0]) return LEFT_OF_CONSTRAINT;
if (dblPredictorKnot < _predictorOrdinateArray[0]) return LEFT_OF_CONSTRAINT;

if (dblPredictorKnot > _adblPredictorOrdinate[_adblPredictorOrdinate.length - 1])
if (dblPredictorKnot > _predictorOrdinateArray[_predictorOrdinateArray.length - 1])
return RIGHT_OF_CONSTRAINT;

return SPLITS_CONSTRAINT;
Expand Down
Loading

0 comments on commit 0a229c7

Please sign in to comment.