Skip to content

Commit

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

Samples:

	- Spline Segment Latent State Response Model - Monotone Type (1, 2, 3)
	- Spline Segment Latent State Response Model - Clip Left of Predictor Ordinate (4, 5, 6)
	- Spline Segment Latent State Response Model - Clip Right of Predictor Ordinate (7, 8, 9)
	- Spline Segment Latent State Response Model - Display String (10, 11, 12)
	- Spline Stretch Boundary Settings (13, 14, 15)
	- Spline Stretch Boundary Settings - Floating (16)
	- Spline Stretch Boundary Settings - Natural (17)
	- Spline Stretch Boundary Settings - Financial (18)
	- Spline Stretch Boundary Settings - Not-a-Knot (19)
	- Spline Stretch Boundary Settings - Left Derivative Order (20, 21)
	- Spline Stretch Boundary Settings - Right Derivative Order (22, 23)
	- Spline Stretch Boundary Settings - Condition Type (24, 25)
	- Spline Stretch Boundary Settings - Natural Standard (26, 27)
	- Spline Stretch Boundary Settings - Floating Standard (28, 29)
	- Spline Stretch Boundary Settings - Financial Standard (30, 31)
	- Spline Stretch Boundary Settings - Not-a-Knot Standard (32, 33)
	- Spline Stretch Boundary Settings - Constructor (34, 35, 36)
	- Spline Stretch Single Segment Sequence (37, 38, 39)
	- Spline Stretch Single Segment Sequence - Setup (40, 41)
	- Spline Stretch Single Segment Sequence - Response Value (42)
	- Spline Stretch Single Segment Sequence - Response Value Derivative (43, 44)
	- Spline Stretch Single Segment Sequence - Jack D Response Calibration Input (45, 46)
	- Spline Stretch Single Segment Sequence - Jack D Response Manifest Measure (47, 48)
	- Spline Stretch Single Segment Sequence - Jack D Response Monotone Type (49)
	- Spline Stretch Single Segment Sequence - Is Locally Monotone (50)
	- Spline Stretch Single Segment Sequence - Is Co-Monotone (51)
	- Spline Stretch Single Segment Sequence - Is Knot (52)
	- Spline Stretch Single Segment Sequence - Reset Node (53, 54)
	- Spline Stretch Single Segment Sequence - Left Predictor Ordinate Edge (55)
	- Spline Stretch Single Segment Sequence - Right Predictor Ordinate Edge (56)
	- Spline Stretch Single Segment Sequence - To R1 Function (57)
	- Spline Stretch Single Segment Lagrange Polynomial (58, 59)
	- Spline Stretch Single Segment Lagrange Polynomial - DIFF_SCALE (60)


IdeaDRIP:
  • Loading branch information
Lakshmik committed Jan 14, 2024
1 parent 49ae317 commit 5569cce
Show file tree
Hide file tree
Showing 6 changed files with 294 additions and 174 deletions.
43 changes: 43 additions & 0 deletions ReleaseNotes/05_04_2023.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Features:

Bug Fixes/Re-organization:

Samples:

- Spline Segment Latent State Response Model - Monotone Type (1, 2, 3)
- Spline Segment Latent State Response Model - Clip Left of Predictor Ordinate (4, 5, 6)
- Spline Segment Latent State Response Model - Clip Right of Predictor Ordinate (7, 8, 9)
- Spline Segment Latent State Response Model - Display String (10, 11, 12)
- Spline Stretch Boundary Settings (13, 14, 15)
- Spline Stretch Boundary Settings - Floating (16)
- Spline Stretch Boundary Settings - Natural (17)
- Spline Stretch Boundary Settings - Financial (18)
- Spline Stretch Boundary Settings - Not-a-Knot (19)
- Spline Stretch Boundary Settings - Left Derivative Order (20, 21)
- Spline Stretch Boundary Settings - Right Derivative Order (22, 23)
- Spline Stretch Boundary Settings - Condition Type (24, 25)
- Spline Stretch Boundary Settings - Natural Standard (26, 27)
- Spline Stretch Boundary Settings - Floating Standard (28, 29)
- Spline Stretch Boundary Settings - Financial Standard (30, 31)
- Spline Stretch Boundary Settings - Not-a-Knot Standard (32, 33)
- Spline Stretch Boundary Settings - Constructor (34, 35, 36)
- Spline Stretch Single Segment Sequence (37, 38, 39)
- Spline Stretch Single Segment Sequence - Setup (40, 41)
- Spline Stretch Single Segment Sequence - Response Value (42)
- Spline Stretch Single Segment Sequence - Response Value Derivative (43, 44)
- Spline Stretch Single Segment Sequence - Jack D Response Calibration Input (45, 46)
- Spline Stretch Single Segment Sequence - Jack D Response Manifest Measure (47, 48)
- Spline Stretch Single Segment Sequence - Jack D Response Monotone Type (49)
- Spline Stretch Single Segment Sequence - Is Locally Monotone (50)
- Spline Stretch Single Segment Sequence - Is Co-Monotone (51)
- Spline Stretch Single Segment Sequence - Is Knot (52)
- Spline Stretch Single Segment Sequence - Reset Node (53, 54)
- Spline Stretch Single Segment Sequence - Left Predictor Ordinate Edge (55)
- Spline Stretch Single Segment Sequence - Right Predictor Ordinate Edge (56)
- Spline Stretch Single Segment Sequence - To R1 Function (57)
- Spline Stretch Single Segment Lagrange Polynomial (58, 59)
- Spline Stretch Single Segment Lagrange Polynomial - DIFF_SCALE (60)


IdeaDRIP:
Binary file modified ScheduleSheet.xlsx
Binary file not shown.
88 changes: 58 additions & 30 deletions src/main/java/org/drip/spline/segment/LatentStateResponseModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2115,28 +2115,40 @@ public Monotonocity monotoneType()
* Clip the part of the Segment to the Right of the specified Predictor Ordinate. Retain all other
* constraints the same.
*
* @param dblPredictorOrdinate The Predictor Ordinate
* @param predictorOrdinate The Predictor Ordinate
*
* @return The Clipped Segment
*/

public LatentStateResponseModel clipLeftOfPredictorOrdinate (
final double dblPredictorOrdinate)
final double predictorOrdinate)
{
try {
LatentStateResponseModel csLeftSnipped = LatentStateResponseModel.Create (dblPredictorOrdinate,
right(), _basisEvaluator.replicate(), _segmentInelasticDesignControl);

int iCk = _segmentInelasticDesignControl.Ck();
LatentStateResponseModel leftSnippedLatentStateResponseModel =
LatentStateResponseModel.Create (
predictorOrdinate,
right(),
_basisEvaluator.replicate(),
_segmentInelasticDesignControl
);

double[] adblCalibLeftEdgeDeriv = 0 != iCk ? csLeftSnipped.transmissionCk (dblPredictorOrdinate,
this, iCk) : null;
int ck = _segmentInelasticDesignControl.Ck();

return csLeftSnipped.calibrateState (new org.drip.spline.params.SegmentStateCalibrationInputs
(new double[] {dblPredictorOrdinate, right()}, new double[] {responseValue
(dblPredictorOrdinate), responseValue (right())}, adblCalibLeftEdgeDeriv, null, null,
null)) ? csLeftSnipped : null;
} catch (java.lang.Exception e) {
return leftSnippedLatentStateResponseModel.calibrateState (
new SegmentStateCalibrationInputs (
new double[] {predictorOrdinate, right()},
new double[] {responseValue (predictorOrdinate), responseValue (right())},
0 != ck ? leftSnippedLatentStateResponseModel.transmissionCk (
predictorOrdinate,
this,
ck
) : null,
null,
null,
null
)
) ? leftSnippedLatentStateResponseModel : null;
} catch (Exception e) {
e.printStackTrace();
}

Expand All @@ -2147,25 +2159,35 @@ public LatentStateResponseModel clipLeftOfPredictorOrdinate (
* Clip the part of the Segment to the Right of the specified Predictor Ordinate. Retain all other
* constraints the same.
*
* @param dblPredictorOrdinate The Predictor Ordinate
* @param predictorOrdinate The Predictor Ordinate
*
* @return The Clipped Segment
*/

public LatentStateResponseModel clipRightOfPredictorOrdinate (
final double dblPredictorOrdinate)
final double predictorOrdinate)
{
try {
LatentStateResponseModel csRightSnipped = LatentStateResponseModel.Create (left(),
dblPredictorOrdinate, _basisEvaluator.replicate(), _segmentInelasticDesignControl);
LatentStateResponseModel rightSnippedLatentStateResponseModel = LatentStateResponseModel.Create (
left(),
predictorOrdinate,
_basisEvaluator.replicate(),
_segmentInelasticDesignControl
);

int iCk = _segmentInelasticDesignControl.Ck();
int ck = _segmentInelasticDesignControl.Ck();

return csRightSnipped.calibrateState (new org.drip.spline.params.SegmentStateCalibrationInputs
(new double[] {left(), dblPredictorOrdinate}, new double[] {responseValue (left()),
responseValue (dblPredictorOrdinate)}, 0 != iCk ? csRightSnipped.transmissionCk (left(),
this, iCk) : null, null, null, null)) ? csRightSnipped : null;
} catch (java.lang.Exception e) {
return rightSnippedLatentStateResponseModel.calibrateState (
new SegmentStateCalibrationInputs (
new double[] {left(), predictorOrdinate},
new double[] {responseValue (left()), responseValue (predictorOrdinate)},
0 != ck ? rightSnippedLatentStateResponseModel.transmissionCk (left(), this, ck) : null,
null,
null,
null
)
) ? rightSnippedLatentStateResponseModel : null;
} catch (Exception e) {
e.printStackTrace();
}

Expand All @@ -2178,18 +2200,24 @@ public LatentStateResponseModel clipRightOfPredictorOrdinate (
* @return The string representation
*/

public java.lang.String displayString()
public String displayString()
{
java.lang.StringBuffer sb = new java.lang.StringBuffer();
StringBuffer stringBuffer = new StringBuffer();

sb.append ("\t\t\t[" + left() + " => " + right() + "\n");
stringBuffer.append ("\t\t\t[" + left() + " => " + right() + "\n");

for (int i = 0; i < _responseToBasisCoefficientSensitivity.length; ++i) {
if (0 != i) sb.append (" | ");
for (int responseToBasisCoefficientSensitivityIndex = 0;
responseToBasisCoefficientSensitivityIndex < _responseToBasisCoefficientSensitivity.length;
++responseToBasisCoefficientSensitivityIndex) {
if (0 != responseToBasisCoefficientSensitivityIndex) {
stringBuffer.append (" | ");
}

sb.append (_responseToBasisCoefficientSensitivity[i] + "\n");
stringBuffer.append (
_responseToBasisCoefficientSensitivity[responseToBasisCoefficientSensitivityIndex] + "\n"
);
}

return sb.toString();
return stringBuffer.toString();
}
}
119 changes: 69 additions & 50 deletions src/main/java/org/drip/spline/stretch/BoundarySettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*/

/*!
* Copyright (C) 2025 Lakshmi Krishnamurthy
* Copyright (C) 2024 Lakshmi Krishnamurthy
* Copyright (C) 2023 Lakshmi Krishnamurthy
* Copyright (C) 2022 Lakshmi Krishnamurthy
* Copyright (C) 2021 Lakshmi Krishnamurthy
* Copyright (C) 2020 Lakshmi Krishnamurthy
Expand Down Expand Up @@ -84,34 +87,44 @@

/**
* <i>BoundarySettings</i> implements the Boundary Settings that determine the full extent of description of
* the regime's State. It exports functions that:
* the regime's State. It exports functions that:
*
* <br><br>
* <br>
* <ul>
* <li>
* Specify the type of the boundary condition (NATURAL/FLOATING/IS-A-KNOT)
* </li>
* <li>
* Boundary Condition specific additional parameters (e.g., Derivative Orders and Matches)
* </li>
* <li>
* Static methods that help construct standard boundary settings
* </li>
* <li>Calibration Boundary Condition: Floating Boundary Condition</li>
* <li>Calibration Boundary Condition: Natural Boundary Condition</li>
* <li>Calibration Boundary Condition: Financial Boundary Condition</li>
* <li>Calibration Boundary Condition: Not-A-Knot Boundary Condition</li>
* <li>Return the Instance of the Standard Natural Boundary Condition</li>
* <li>Return the Instance of the Standard Floating Boundary Condition</li>
* <li>Return the Instance of the Standard Financial Boundary Condition</li>
* <li>Return the Instance of the Standard Not-A-Knot Boundary Condition</li>
* <li><i>BoundarySettings</i> constructor</li>
* <li>Retrieve the Order of the Left Derivative</li>
* <li>Retrieve the Order of the Right Derivative</li>
* <li>Retrieve the Type of the Boundary Condition</li>
* </ul>
*
* <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/stretch/README.md">Multi-Segment Sequence Spline Stretch</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/stretch/README.md">Multi-Segment Sequence Spline Stretch</a></td></tr>
* </table>
* <br>
*
* @author Lakshmi Krishnamurthy
*/

public class BoundarySettings {
public class BoundarySettings
{

/**
* Calibration Boundary Condition: Floating Boundary Condition
Expand All @@ -137,9 +150,9 @@ public class BoundarySettings {

public static final int BOUNDARY_CONDITION_NOT_A_KNOT = 8;

private int _iLeftDerivOrder = -1;
private int _iRightDerivOrder = -1;
private int _iBoundaryConditionType = -1;
private int _leftDerivativeOrder = -1;
private int _rightDerivativeOrder = -1;
private int _boundaryConditionType = -1;

/**
* Return the Instance of the Standard Natural Boundary Condition
Expand All @@ -151,7 +164,7 @@ public static final BoundarySettings NaturalStandard()
{
try {
return new BoundarySettings (-1, 2, BOUNDARY_CONDITION_NATURAL);
} catch (java.lang.Exception e) {
} catch (Exception e) {
e.printStackTrace();
}

Expand All @@ -168,7 +181,7 @@ public static final BoundarySettings FloatingStandard()
{
try {
return new BoundarySettings (-1, -1, BOUNDARY_CONDITION_FLOATING);
} catch (java.lang.Exception e) {
} catch (Exception e) {
e.printStackTrace();
}

Expand All @@ -185,7 +198,7 @@ public static final BoundarySettings FinancialStandard()
{
try {
return new BoundarySettings (-1, 1, BOUNDARY_CONDITION_FINANCIAL);
} catch (java.lang.Exception e) {
} catch (Exception e) {
e.printStackTrace();
}

Expand All @@ -195,48 +208,54 @@ public static final BoundarySettings FinancialStandard()
/**
* Return the Instance of the Standard Not-A-Knot Boundary Condition
*
* @param iLeftDerivOrder Order of the Left Derivative
* @param iRightDerivOrder Order of the Right Derivative
* @param leftDerivativeOrder Order of the Left Derivative
* @param rightDerivativeOrder Order of the Right Derivative
*
* @return Instance of the Standard Not-A-Knot Boundary Condition
*/

public static final BoundarySettings NotAKnotStandard (
final int iLeftDerivOrder,
final int iRightDerivOrder)
final int leftDerivativeOrder,
final int rightDerivativeOrder)
{
try {
return new BoundarySettings (iLeftDerivOrder, iRightDerivOrder, BOUNDARY_CONDITION_NOT_A_KNOT);
} catch (java.lang.Exception e) {
return new BoundarySettings (
leftDerivativeOrder,
rightDerivativeOrder,
BOUNDARY_CONDITION_NOT_A_KNOT
);
} catch (Exception e) {
e.printStackTrace();
}

return null;
}

/**
* BoundarySettings constructor
* <i>BoundarySettings</i> constructor
*
* @param iLeftDerivOrder Order of the Left Derivative
* @param iRightDerivOrder Order of the Right Derivative
* @param iBoundaryConditionType Type of the Boundary Condition - NATURAL/FINANCIAL/NOT_A_KNOT
* @param leftDerivativeOrder Order of the Left Derivative
* @param rightDerivativeOrder Order of the Right Derivative
* @param boundaryConditionType Type of the Boundary Condition - NATURAL/FINANCIAL/NOT_A_KNOT
*
* @throws java.lang.Exception Thrown if Inputs are invalid
* @throws Exception Thrown if Inputs are invalid
*/

public BoundarySettings (
final int iLeftDerivOrder,
final int iRightDerivOrder,
final int iBoundaryConditionType)
throws java.lang.Exception
final int leftDerivativeOrder,
final int rightDerivativeOrder,
final int boundaryConditionType)
throws Exception
{
if (BOUNDARY_CONDITION_FLOATING != (_iBoundaryConditionType = iBoundaryConditionType) &&
BOUNDARY_CONDITION_NATURAL != _iBoundaryConditionType && BOUNDARY_CONDITION_FINANCIAL !=
_iBoundaryConditionType && BOUNDARY_CONDITION_NOT_A_KNOT != _iBoundaryConditionType)
throw new java.lang.Exception ("BoundarySettings ct: Invalid Inputs");
if (BOUNDARY_CONDITION_FLOATING != (_boundaryConditionType = boundaryConditionType) &&
BOUNDARY_CONDITION_NATURAL != _boundaryConditionType &&
BOUNDARY_CONDITION_FINANCIAL != _boundaryConditionType &&
BOUNDARY_CONDITION_NOT_A_KNOT != _boundaryConditionType) {
throw new Exception ("BoundarySettings ct: Invalid Inputs");
}

_iLeftDerivOrder = iLeftDerivOrder;
_iRightDerivOrder = iRightDerivOrder;
_leftDerivativeOrder = leftDerivativeOrder;
_rightDerivativeOrder = rightDerivativeOrder;
}

/**
Expand All @@ -247,7 +266,7 @@ public BoundarySettings (

public int leftDerivOrder()
{
return _iLeftDerivOrder;
return _leftDerivativeOrder;
}

/**
Expand All @@ -258,7 +277,7 @@ public int leftDerivOrder()

public int rightDerivOrder()
{
return _iRightDerivOrder;
return _rightDerivativeOrder;
}

/**
Expand All @@ -269,6 +288,6 @@ public int rightDerivOrder()

public int boundaryCondition()
{
return _iBoundaryConditionType;
return _boundaryConditionType;
}
}
Loading

0 comments on commit 5569cce

Please sign in to comment.