TFR Supplementary Code
Genetic Optimization of the Single-DOF Coupled Transmission
============================================================

Purpose
-------
This code reproduces the geometric parameter-search workflow used to select
candidate dimensions for the crank-rocker / parallel-mechanism / foot-linkage
system described in the supplementary material.

Recommended workflow
--------------------
1. Open the code folder in MATLAB.
2. The supplied file theta_cache.mat contains the precomputed parallel-mechanism
   angle grid used by the optimization.
3. Run:
       main_optimization.m
4. Modify the parameter-search intervals only in:
       robot_config.m
5. After optimization, use:
       plot_xy_yz.m
   to reconstruct and inspect the saved foot trajectory.

If theta_cache.mat needs to be regenerated
------------------------------------------
Run:
    robot_config
    get_theta_matrix

The angular grid is defined by alpha_center, delta_alpha, beta_center,
delta_beta, and epsilon in robot_config.m.

Main files
----------
main_optimization.m   Main entry point and GA settings.
robot_config.m        Fixed mechanism parameters and optimization bounds.
diy_ga.m              Custom GA iteration loop.
GA.m                  Selection, crossover/mutation assembly, and evaluation.
initialize.m          Initial population generation.
crossover.m           Crossover operator.
mutate.m              Mutation operator.
fitness_function.m    Candidate evaluation and objective calculation.
trajectory.m          Candidate foot-trajectory generation.
cal_theta.m           Parallel-mechanism inverse-kinematic calculation.
cal_pi.m              Crank-rocker branch-angle calculation.
get_track.m           Coupling-constraint filtering and foot-point calculation.
get_score.m           Trajectory feasibility/placement scoring.
plot_xy_yz.m          Post-optimization trajectory inspection.

Implementation note
-------------------
To preserve the exact computational behavior used in the experiments, this
supplementary version standardizes the comments and documentation but does not
increase grid resolution, population size, cached-array dimensions, or the
number of parallel workers. The numerical statements in the original MATLAB
files have intentionally been left unchanged.

Computational requirements
--------------------------
The custom search uses a MATLAB process-based parallel pool. get_track.m also
uses gpuArray for the coupling-condition filtering step. The available CPU/GPU
memory therefore depends on the workstation. If the code is moved to a machine
with less memory, PoolSize can be reduced in main_optimization.m without
changing the mechanism model, although execution time will increase.

Units and conventions
---------------------
Geometric lengths are in millimeters unless otherwise stated.
Angles in the parameter search are in degrees; cal_theta.m performs internal
conversion to radians and cal_pi.m returns crank-rocker branch angles in degrees.

Output
------
The current script saves the best candidate to bestParams0716_1.mat and writes
intermediate candidate files during the GA run. These filenames are retained
from the experimental code for traceability.

Note on legacy files
--------------------
Several auxiliary/development scripts are included because they were part of
the original design workspace. The reported GA workflow is centered on
main_optimization.m and the files listed above.
