! Gear ratio selection.
We want to choose a set of gear ratios to
use in a vehicle transmission, and the amount
of time to spend in each gear ratio so as
to accelerate from 0 to a target speed in a
minimum amount of time;
! Keywords: Gear ratio selection, Transmission design, Acceleration,
 Automotive design;
SETS:
 SPEED;
 RATIO;
 SXR( SPEED, RATIO): TM, x;
 SXRXR( SPEED, RATIO, RATIO): y;
ENDSETS
! Parameters: TM(s,r) = time in seconds to reach speed step s from step s-1, using gear ratio r. STIME = time it takes to shift from one gear ratio to the another, SLIM = upper limit on number of gear ratios allowed. Variables: x(s,r) = 1 if gear ratio r was used to get from speed step s-1 to s, y(s,r,k) = 1 if after reaching speed step s, the ratio is switched from r to k; DATA: STIME = 0.06; ! Time to shift in seconds; SLIM = 3; ! Number gear ratios allowed; SPEED = S020 S040 S060 S080 S100; ! Speed steps; RATIO = R4_1 R3_1 R2_1 R1_1; ! Gear ratios; ! Time to accelerate from one speed to next by gear ratio; TM = 0.8 1.0 1.3 1.9 ! S020; 0.9 0.95 1.2 1.7 ! S040; 1.2 0.90 1.1 1.5 ! S060; 1.9 0.97 0.9 1.1 ! S080; 2.3 1.4 1.1 0.9; ! S100; ENDDATA NS = @SIZE( SPEED); ! Number of speed increments; ! Minimize the time to final speed; MIN = @SUM( SXR(s,r): TM(s,r)*x(s,r)) ! Time in each gear; + STIME*@SUM(SXRXR(s,r,k): y(s,r,k)); ! Shift time; ! Must choose some initial gear ratio for first increment; 1 = @SUM( RATIO(r): x(1,r)); ! Must reach final speed in some gear ratio r; @SUM( RATIO(r): x(NS,r)) = 1; ! For each speed step s and ratio r...; @FOR( SXR( s, r) | s #LT# NS: ! If we accelerated from s-1 to s in r, or shifted into r at s...; x( s,r) + @SUM( RATIO( k) | k #NE# r: y(s,k,r)) ! then we must either accelerate to s+1 in r or shift from r to some other gear ratio k at s; = x( s+1,r) + @SUM( RATIO(k) | k #NE# r: y(s,r,k)); ); ! Cannot use more ratios than allowed. If SLIM ratios allowed, can shift at most SLIM-1 times; @SUM( SXRXR(s,r,k): y(s,r,k)) <= SLIM-1; ! Must make discrete, not fractional, shifts; @FOR( SXRXR(s,r,k): @BIN(Y(s,r,k)));