{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Minimal number of runs for an orthognal array" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this example we calculate the minimum number of runs required for an orthogonal array. For more details, see [Schoen et al.](https://onlinelibrary.wiley.com/doi/abs/10.1002/jcd.20236)\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "import itertools\n", "\n", "import numpy as np\n", "\n", "\n", "def minimum_number_of_runs(factor_levels, strength):\n", " \"\"\"Calculate the minimum number of runs for an orthogonal array\n", "\n", " The minimum number of runs is based on the strength conditions. IWhether a design actually exists\n", " Args:\n", " factor_levels: Factor levels of the design\n", " strength: Strength of the array\n", " Returns:\n", " Minimum number of runs\n", "\n", " \"\"\"\n", " runs = [np.prod(tt) for tt in itertools.combinations(factor_levels, strength)]\n", " N = np.lcm.reduce(runs)\n", " return N" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We run the method on several examples." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "for a design of strength 3 and factor levels [2, 3, 3, 4, 5] we require (a multiple of) 360 runs\n" ] } ], "source": [ "strength = 3\n", "factor_levels = [2, 3, 3, 4, 5]\n", "N = minimum_number_of_runs(factor_levels, strength)\n", "\n", "print(f\"for a design of strength {strength} and factor levels {factor_levels} we require (a multiple of) {N} runs\")" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "for a design of strength 2 and factor levels [3, 2, 2, 2, 2] we require (a multiple of) 12 runs\n" ] } ], "source": [ "strength = 2\n", "factor_levels = [3, 2, 2, 2, 2]\n", "N = minimum_number_of_runs(factor_levels, strength)\n", "\n", "print(f\"for a design of strength {strength} and factor levels {factor_levels} we require (a multiple of) {N} runs\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.6" } }, "nbformat": 4, "nbformat_minor": 4 }