We used PSO30, a stochastic optimization algorithm47, to discover gaits that optimize forward velocity under different adhesion and travel orientation conditions. We implemented PSO using the inspyred (inspyred.github.com) Python ( python.org) framework. Briefly, 50 candidate gaits (particles) were randomly initialized within a 5-dimensional search space of possible solutions. Each dimension represents one leg's phase of motion relative to the front left leg, which was fixed at 0° phase. During PSO, the phases of the five remaining legs could vary between 0° and 360°. For example, in this formulation a phase vector [L1=0°; R1=180°; L2=180°; R2=0°; L3=0°; R3=180°] defines the classic tripod gait, which we call tripod-A to distinguish it from alternative three-legged gaits.
Each particle was initialized with a random velocity that defined its movement within this search space during an iteration of the algorithm. Then, each particle's gait was simulated in the model. We measured its forward velocity over 0.5 s of simulated time (fitness). This allowed us to bias optimization for straight locomotion. Notably, we did not explicitly optimize for energy efficiency but nevertheless obtained more energy efficient gaits as a byproduct of speed optimization. For each iteration, particle positions were adjusted according to equations (4) and (5):
where
is the velocity at t+1 of particle i,
is the current velocity of the particle,
is the current position of the particle,
is the position of the personal best solution of particle i,
is the position of the neighborhood best solution, r1 and r2 are random numbers in the range [0,1], and the coefficients w (inertia weight), c1 (cognitive rate), and c2 (social rate) are fixed. For our simulation, we use the suggested30,67 values w=0.729, c1=1.49 and c2=1.49. In addition, we limited the maximum particle velocity to 0.4 (a fraction of the parameter space). The approach described here and implemented in inspyred is outlined in67. As our search space is periodic/circular (0=2π), we implemented a specialized bounding function using a custom PSO class that inherits the inspyred class and replaces the vector determination function. For each experimental condition, we ran 15 experiments with 50 particles each over 150 iterations. This number of iterations was chosen after assessing the convergence time of the optimization process. This number of experiments was chosen to best explore the search space of possible gaits while also limiting computing time.
We optimized for different geometric conditions (for example, ground and vertical locomotion) by changing the global direction of gravitational acceleration. If a model fell off of the substrate during vertical locomotion, the forward distance travelled before falling was taken into account when calculating speed rather than setting the fitness to zero. This procedure helped smooth the fitness landscape and assisted optimization.
Do you have any questions about this protocol?
Post your question to gather feedback from the community. We will also invite the authors of this article to respond.