Record Class OptimizeNode

java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.OptimizeNode
Record Components:
sense - whether to maximise or minimise the objective; never null
objective - the per-row coefficient expression summed in the objective; never null
constraints - the linear constraints (at least one); never null
groupingKeys - the grouping keys (empty = one whole-relation group); never null
allocation - present iff this is LP (continuous allocation) mode; never null
input - the candidate relation; never null
location - the source location of this node; never null
All Implemented Interfaces:
RelNode

public record OptimizeNode(ObjectiveSense sense, Operand objective, List<OptimizeConstraint> constraints, List<String> groupingKeys, Optional<AllocationSpec> allocation, RelNode input, SourceLocation location) extends Record implements RelNode
Declarative optimisation (OPTIMIZE) — the goal-seeking sibling of γ. Within each group (by groupingKeys) it either selects the optimal subset (MIP mode) or assigns continuous allocations (LP mode).

MIP mode (default, allocation is empty): each row carries a binary decision (in or out); the output is the chosen input rows unchanged, so the output schema equals the input schema. A group whose constraints are infeasible contributes no rows. Example: OPTIMIZE MAXIMIZE SUM(value) SUBJECT TO SUM(weight) <= 100 PER region (Candidates).

LP mode (allocation is present): each row receives a continuous decision variable in [lo, hi]; every row is emitted with its allocation value appended as a new column — output schema = input + 1 column. Syntax: OPTIMIZE ALLOCATE (lo, hi) MAXIMIZE SUM(return) SUBJECT TO SUM(1) = 1.0 -> weight (Portfolio).

Solved in-engine above the federation boundary; never pushes down. Materialises its input ([bag]). At least one constraint is required.

  • Constructor Details

  • Method Details

    • accept

      public <R> R accept(RelNodeVisitor<R> visitor)
      Specified by:
      accept in interface RelNode
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • sense

      public ObjectiveSense sense()
      Returns the value of the sense record component.
      Returns:
      the value of the sense record component
    • objective

      public Operand objective()
      Returns the value of the objective record component.
      Returns:
      the value of the objective record component
    • constraints

      public List<OptimizeConstraint> constraints()
      Returns the value of the constraints record component.
      Returns:
      the value of the constraints record component
    • groupingKeys

      public List<String> groupingKeys()
      Returns the value of the groupingKeys record component.
      Returns:
      the value of the groupingKeys record component
    • allocation

      public Optional<AllocationSpec> allocation()
      Returns the value of the allocation record component.
      Returns:
      the value of the allocation record component
    • input

      public RelNode input()
      Returns the value of the input record component.
      Returns:
      the value of the input record component
    • location

      public SourceLocation location()
      Returns the value of the location record component.
      Specified by:
      location in interface RelNode
      Returns:
      the value of the location record component