Robot Arm Function#

import numpy as np
import matplotlib.pyplot as plt
import uqtestfuns as uqtf

The robot arm function is an eight-dimensional, scalar-valued test function that calculates the distance between a fixed origin and the tip of a four-segment robot arm.

The function is commonly used in metamodeling exercises; for example, see [BHB+19, AO01]. Due to its complexity, the function is challenging to approximate using polynomials and has therefore been studied extensively in the neural network literature [AO01].

Test function instance#

To create a default instance of the robot arm test function:

my_testfun = uqtf.RobotArm()

Check if it has been correctly instantiated:

print(my_testfun)
Function ID      : RobotArm
Input Dimension  : 8 (fixed)
Output Dimension : 1
Parameterized    : False
Description      : Four-segment robot arm function from An and Owen (2001)
Applications     : metamodeling

Description#

Consider a four-segment robot arm, with its shoulder fixed at the origin in the \((x, y)\)-plane. The segments have lengths \(L_1, L_2, L_3\) and \(L_4\). The position of the end of the robot arm is given by:

\[\begin{split} \begin{aligned} x_* (\boldsymbol{x}) & = \sum_{i = 1}^4 L_i \, \cos{\left( \sum_{j = 1}^i \theta_j \right)} \\ y_* (\boldsymbol{x}) & = \sum_{i = 1}^4 L_i \, \sin{\left( \sum_{j = 1}^i \theta_j \right)}, \end{aligned} \end{split}\]

where:

  • \(\theta_1\) is the angle formed by the first segment and the horizontal axis, and

  • \(\theta_2, \theta_3, \theta_4\) are the angles formed by consecutive segments with the previous segments, i.e., the 2nd and 1st, 3rd and 2nd, and 4th and 3rd segments, respectively.

The robot arm function computes the Euclidean distance between the tip of the robot arm and the fixed origin, expressed as[1]

\[ \mathcal{M}(\boldsymbol{x}) = \sqrt{x_*^2(\boldsymbol{x}) + y_*^2(\boldsymbol{x})}, \]

where \(\boldsymbol{x} = \left( L_1, L_2, L_3, L_4, \theta_1, \theta_2, \theta_3, \theta_4 \right)\) is the eight-dimensional vector of input variables further defined below.

Probabilistic input#

The probabilistic input model for the robot arm function consists of eight independent uniform random variables with the ranges shown below.

Hide code cell source
print(my_testfun.prob_input)
Function ID     : RobotArm
Input ID        : An2001
Input Dimension : 8
Description     : Input model for the Robot Arm function from An and Owen
                  (2001)
Marginals       :

 No.    Name    Distribution         Parameters                        Description
-----  ------  --------------  -----------------------  -----------------------------------------
  1      L1       uniform               [0 1]                   Length of the 1st segment
  2      L2       uniform               [0 1]                   Length of the 2nd segment
  3      L3       uniform               [0 1]                   Length of the 3rd segment
  4      L4       uniform               [0 1]                   Length of the 4th segment
  5    theta1     uniform      [0.         6.28318531]  Angle between 1st segment and horizontal
  6    theta2     uniform      [0.         6.28318531]  Angle between 2nd segment and 1st segment
  7    theta3     uniform      [0.         6.28318531]  Angle between 3rd segment and 2nd segment
  8    theta4     uniform      [0.         6.28318531]  Angle between 4th segment and 3rd segment

Copulas         : Independence

Reference results#

This section provides several reference results of typical UQ analyses involving the test function.

Sample histogram#

Shown below is the histogram of the output based on \(1'000'000\) random points:

Hide code cell source
my_testfun.prob_input.reset_rng(42)
xx_test = my_testfun.prob_input.get_sample(1000000)
yy_test = my_testfun(xx_test)

plt.hist(yy_test, bins="auto", color="#8da0cb");
plt.grid();
plt.ylabel("Counts [-]");
plt.xlabel("$\mathcal{M}(\mathbf{X})$");
plt.gcf().set_dpi(150);
../_images/71268c558001ce9fd3914815d5ad2a7695ee715b3bee44312589e76375d98e78.png

References#

[BHB+19]

Mohamed Amine Bouhlel, John T. Hwang, Nathalie Bartoli, Rémi Lafage, Joseph Morlier, and Joaquim R. R. A. Martins. A Python surrogate modeling framework with derivatives. Advances in Engineering Software, 135:102662, 2019. doi:10.1016/j.advengsoft.2019.03.005.

[AO01] (1,2,3)

Jian An and Art Owen. Quasi-regression. Journal of Complexity, 17(4):588–607, 2001. doi:10.1006/jcom.2001.0588.