Skip to content

3. Expressions, Operators & Declarative Traversers

3.1 Arithmetic & Relational Operators

Rave provides standard arithmetic operators (+, -, *, /, %) and relational comparison operators (=, <>, >, <, >=, <=).

%is_overtime% = %duty_flight_time% > 08:00;
%layover_rest% = next(duty(trip), duty.%start_time%) - duty.%end_time%;

3.2 Logical Connectives & Conditional Expressions

Logical connectives (and, or, not) build complex boolean constraints. Conditional logic uses pure functional if ... then ... else constructs:

%effective_max_fdp% = 
  if %start_time_night% then
    09:00
  else if %flight_count% > 3 then
    11:30
  else
    13:00;

3.3 Traversers & Vector Computations

Traversers are Rave's declarative alternative to loops. They aggregate child properties over a parent level context.

Traverser Syntax Example Description
sum sum(leg(duty), %leg_duration%) Computes the numerical sum of an expression over all child instances.
count count(leg(duty)) Counts the total number of child instances in the parent scope.
any any(leg(duty), leg.%is_deadhead%) Returns True if the expression evaluates to True for at least one child.
all all(leg(duty), leg.%is_valid%) Returns True if the expression evaluates to True for all child instances.
max / min max(duty(trip), duty.%length%) Finds the maximum or minimum value across all child instances.
avg avg(leg(duty), %leg_duration%) Computes the arithmetic mean over all child instances.

3.4 Inter-Instance Navigation (prev, next, first, last)

To evaluate transition rules between adjacent activities, Rave provides spatial-temporal navigation traversers:

// Minimum Sit Time check between consecutive flight legs in a duty
%sit_time_valid% = 
  for each f1 -> f2 in elements
    f2.departure_time - f1.arrival_time >= %min_sit_time%;

// Accessing the rest duration prior to the current duty
%rest_before_duty% = 
  duty.%start_time% - prev(duty(trip), duty.%end_time%);

// Verifying that a trip originates and terminates at the same base airport
%trip_base_closed% = 
  first(leg(trip), leg.%dep_airport%) = last(leg(trip), leg.%arr_airport%);