Record Class PiecewiseFunction.FunctionSegment

java.lang.Object
java.lang.Record
com.amalgamasimulation.core.piecewise.PiecewiseFunction.FunctionSegment
Enclosing class:
PiecewiseFunction

public static record PiecewiseFunction.FunctionSegment(Interval argumentInterval, double beforeBeginValue, double beginValue, double endValue, double rate) extends Record
A function segment is a section between breakpoints where the function behaves linearly or has a constant rate.

Each segment is defined by:

  • An argument interval that specifies the range of the segment.
  • The value of the function at the start and end of the interval.
  • The rate of change (slope) of the function within the interval.

A function segment always includes any step change at its beginning, allowing it to reflect abrupt value transitions, but excludes any step change that may occur at its end, ensuring continuity with subsequent segments.

  • Constructor Summary

    Constructors
    Constructor
    Description
    FunctionSegment(Interval argumentInterval, double beforeBeginValue, double beginValue, double endValue, double rate)
    Creates an instance of a FunctionSegment record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the argumentInterval record component.
    double
    Returns the value of the beforeBeginValue record component.
    double
    Returns the value of the beginValue record component.
    double
    Returns the value of the endValue record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    double
    max()
    Returns the maximum value of the function within this segment.
    double
    Returns the value within this segment that has the greatest absolute value.
    double
    min()
    Returns the minimum value of the function within this segment.
    double
    Returns the value of the rate record component.
    double
    Returns the signed square of the segment, representing the area under the segment (with sign depending on the value).
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FunctionSegment

      public FunctionSegment(Interval argumentInterval, double beforeBeginValue, double beginValue, double endValue, double rate)
      Creates an instance of a FunctionSegment record class.
      Parameters:
      argumentInterval - the value for the argumentInterval record component
      beforeBeginValue - the value for the beforeBeginValue record component
      beginValue - the value for the beginValue record component
      endValue - the value for the endValue record component
      rate - the value for the rate record component
  • Method Details

    • signedSquare

      public double signedSquare()
      Returns the signed square of the segment, representing the area under the segment (with sign depending on the value).
      Returns:
      the signed square (area) of the segment
    • min

      public double min()
      Returns the minimum value of the function within this segment. Does not consider possible step change at the end of the segment
      Returns:
      the minimum value of the segment.
    • maxByAbs

      public double maxByAbs()
      Returns the value within this segment that has the greatest absolute value. If the maximum and minimum values have equal absolute values, the maximum (positive) value is returned.

      Does not consider a possible step change at the end of the segment.

      Returns:
      the value with the greatest absolute magnitude in this segment, preserving the original sign
    • max

      public double max()
      Returns the maximum value of the function within this segment. Does not consider possible step change at the end of the segment
      Returns:
      the maximum value of the segment.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • argumentInterval

      public Interval argumentInterval()
      Returns the value of the argumentInterval record component.
      Returns:
      the value of the argumentInterval record component
    • beforeBeginValue

      public double beforeBeginValue()
      Returns the value of the beforeBeginValue record component.
      Returns:
      the value of the beforeBeginValue record component
    • beginValue

      public double beginValue()
      Returns the value of the beginValue record component.
      Returns:
      the value of the beginValue record component
    • endValue

      public double endValue()
      Returns the value of the endValue record component.
      Returns:
      the value of the endValue record component
    • rate

      public double rate()
      Returns the value of the rate record component.
      Returns:
      the value of the rate record component