Package org.tweetyproject.math.algebra
Class Semiring<T>
java.lang.Object
org.tweetyproject.math.algebra.Semiring<T>
- Type Parameters:
T
- The type of elements in the semiring.
- Direct Known Subclasses:
BooleanSemiring
,BottleneckSemiring
,FuzzySemiring
,NonNumericSemiring
,ProbabilisticSemiring
,WeightedSemiring
This class represents a generic Semiring, an algebraic structure with two binary operations
(addition and multiplication), and two corresponding identity elements (zeroElement and oneElement).
- Author:
- Sandra Hoffmann
-
Constructor Summary
ConstructorDescriptionSemiring
(BinaryOperator<T> addition, BinaryOperator<T> multiplication, T zeroElement, T oneElement) Constructs a Semiring instance. -
Method Summary
Modifier and TypeMethodDescriptionPerforms the addition operation on two elements.betterOrSame
(T a, T b) Returns true if value 'a' is better than or equal to value 'b' in the semiring.abstract T
Performs the division operation as definded in the semiring class.Retrieves the binary addition operation.Retrieves the binary multiplication operation.Retrieves the multiplicative identity element.abstract T
Generates a random element of the semiring.Retrieves the additive identity element.Performs the multiplication operation on two elements.double
toNumericalValue
(T value) Converts a value in a semiring to a numerical representation.validateAndReturn
(T value) Validates and returns the given value.
-
Constructor Details
-
Semiring
public Semiring(BinaryOperator<T> addition, BinaryOperator<T> multiplication, T zeroElement, T oneElement) Constructs a Semiring instance.- Parameters:
addition
- The binary addition operation.multiplication
- The binary multiplication operation.zeroElement
- The additive identity element.oneElement
- The multiplicative identity element.
-
-
Method Details
-
getAddition
Retrieves the binary addition operation.- Returns:
- The binary addition operation.
-
getMultiplication
Retrieves the binary multiplication operation.- Returns:
- The binary multiplication operation.
-
getZeroElement
Retrieves the additive identity element.- Returns:
- The additive identity element.
-
getOneElement
Retrieves the multiplicative identity element.- Returns:
- The multiplicative identity element.
-
multiply
-
add
-
betterOrSame
-
validateAndReturn
-
getRandomElement
Generates a random element of the semiring. Note: Concrete implementations in subclasses should provide the actual logic.- Returns:
- A random element of the semiring.
-
divide
Performs the division operation as definded in the semiring class. Needed for g-defense. Note: Concrete implementations in subclasses should provide the actual logic.- Parameters:
dividend
- the dividenddivisor
- the divisor- Returns:
- The inverse of element.
-
toNumericalValue
Converts a value in a semiring to a numerical representation.- Parameters:
value
- The value in the semiring.- Returns:
- The numerical representation of the semiring value.
- Throws:
IllegalArgumentException
- If the provided semiring value is not a valid numeric representation.
-