Record Class PathCost
java.lang.Object
java.lang.Record
com.darkcollective.relix.provenance.PathCost
- Record Components:
cost- the cheapest derivation cost;+∞for an absent tupleroutes- the co-cheapest routes (the witness set); nevernulltruncated- whether routes were dropped to stay within the representation bound
An element of the cheapest-route semiring
PathCostSemiring — a path's
minimum cost and the set of co-cheapest routes
that achieve it. It answers "what is the cheapest itinerary and
what is it?" in one annotation, where tropical keeps only the cost and
lineage only the routes.
Held canonically: 0 is (+∞, ∅) (unreachable / absent) and
1 is (0.0, {ε}) (the free derivation). Every non-zero value's
routes are the derivations of exactly cost — the witness set of the
arg-min. The truncated flag records that the route-set hit
the representation cap and dropped some
co-cheapest routes — a sound under-approximation (the surviving routes are real,
each of cost cost; the cost itself is always exact, since min stays
idempotent and only the route-set can grow).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublecost()Returns the value of thecostrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisZero()Returns whether this is the zero element (no routes — an absent tuple).static PathCostReturns a single-route value(cost, {route}).static PathCostone()Returns the one element(0.0, {ε})— the free (empty-path) derivation.routes()Returns the value of theroutesrecord component.toString()Returns the value rendered as320.0 via r1 | r2.booleanReturns the value of thetruncatedrecord component.static PathCostzero()Returns the zero element(+∞, ∅)— an unreachable / absent tuple.
-
Constructor Details
-
PathCost
Canonicalisesroutesinto an immutable sorted copy.- Parameters:
cost- the cheapest derivation costroutes- the witness routes; nevernulltruncated- whether some routes were dropped to honour the bound
-
-
Method Details
-
zero
Returns the zero element(+∞, ∅)— an unreachable / absent tuple.- Returns:
- the zero element
(+∞, ∅)— an unreachable / absent tuple
-
one
Returns the one element(0.0, {ε})— the free (empty-path) derivation.- Returns:
- the one element
(0.0, {ε})— the free (empty-path) derivation
-
of
Returns a single-route value(cost, {route}). The base annotation of one weighted edge.- Parameters:
cost- the edge weightroute- the edge's route (typically a one-token route)- Returns:
- a single-route value
(cost, {route})
-
isZero
public boolean isZero()Returns whether this is the zero element (no routes — an absent tuple).- Returns:
- whether this is the zero element (no routes — an absent tuple)
-
toString
Returns the value rendered as320.0 via r1 | r2.∞for the zero element; a trailing| ⋯whentruncated(). -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
cost
public double cost()Returns the value of thecostrecord component.- Returns:
- the value of the
costrecord component
-
routes
Returns the value of theroutesrecord component.- Returns:
- the value of the
routesrecord component
-
truncated
public boolean truncated()Returns the value of thetruncatedrecord component.- Returns:
- the value of the
truncatedrecord component
-