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,)
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
f(X) = distance_cost + constraint_penalty + energy_regularization
| 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 |
| 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). |
Single point evaluation with random configuration:
(1,)
Multiple points evaluation:
array([269.77734305, 144.65586174])
Evaluating a straight configuration (all angles = 0.5, mapped to 0 radians):
This function is inspired by robot motion planning problems with obstacles, commonly studied in: