function.so.robot_arm_hard

function.so.robot_arm_hard(X)

10-Link Robot Arm with Maze-Like Hard Constraints.

A challenging constrained optimization problem where a 10-link planar robot arm must reach a target point (5.0, 5.0) while avoiding multiple obstacles forming a maze-like environment. This function tests an optimizer’s ability to handle hard constraints and navigate complex feasible regions.

The problem features three main difficulty factors: 1. ‘The Great Wall’: A vertical barrier at x=2.5 blocking direct paths 2. ‘The Ceiling’: A horizontal bar at y=8.5 preventing high loop strategies 3. ‘The Target Trap’: Obstacles surrounding the target, requiring precise approach

Mathematical formulation

f(X) = distance_cost + constraint_penalty + energy_regularization

where

  • distance_cost = (x_end - 5.0)^2 + (y_end - 5.0)^2
  • constraint_penalty = 10,000 * sum(max(0, r - d + 0.05)^2) for all joints and obstacles
  • energy_regularization = 0.01 * sum(angles^2)

Parameters

Name Type Description Default
X np.ndarray Input points with shape (n_samples, 10) or (10,). Each sample contains 10 joint angles normalized to [0, 1], which are internally mapped to [-1.2π, 1.2π] to allow looping strategies. Can be a 1D array for a single point or 2D array for multiple points. required

Returns

Name Type Description
np.ndarray np.ndarray: Function values at the input points with shape (n_samples,). Lower values indicate better solutions (closer to target with fewer constraint violations).

Note

  • Dimension: 10 (one angle per link)
  • Link length: L = 1.0 for all links
  • Target position: (5.0, 5.0)
  • Search domain: [0, 1]^10 (mapped internally to [-1.2π, 1.2π]^10)
  • Characteristics: Highly constrained, non-convex, multimodal
  • Constraint penalty: 10,000 per violation (effectively hard constraints)
  • Number of obstacles: ~30 forming walls and traps
  • Feasible region: Very small relative to search space

Examples

Single point evaluation with random configuration:

from spotoptim.function import robot_arm_hard
import numpy as np
X = np.random.rand(10) * 0.5  # Conservative random angles
result = robot_arm_hard(X)
result.shape
(1,)
(1,)

Multiple points evaluation:

from spotoptim.function import robot_arm_hard
import numpy as np
X = np.array([[0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5],
              [0.3, 0.4, 0.5, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.0]])
robot_arm_hard(X)
array([269.77734305, 144.65586174])

Evaluating a straight configuration (all angles = 0.5, mapped to 0 radians):

from spotoptim.function import robot_arm_hard
import numpy as np
X_straight = np.full(10, 0.5)
cost_straight = robot_arm_hard(X_straight)
cost_straight[0] > 1000  # High cost due to obstacles
np.False_

References

This function is inspired by robot motion planning problems with obstacles, commonly studied in:

  • LaValle, S. M. (2006). “Planning Algorithms”. Cambridge University Press.
  • Choset, H., et al. (2005). “Principles of Robot Motion: Theory, Algorithms, and Implementations”. MIT Press.