← All procedures

generators.shrinkPoint

This function shrinks a point of a family that fails. Each dimension moves toward `shrinkTarget`, while the point still fails. - In each round, each dimension first tries its target. Then a bisection on the scale of the dimension finds the edge of the failure. - The rounds continue until a round has no move, or until the budget of checks ends. - The function `fails` gives `true` for a point that fails. A first point that does not fail is a `RangeError`. - The shrink has no random draws. Thus the same point and the same function give the same result.

CLI
Package
@procedures/generators · README
Path
["generators","shrinkPoint"]
CLI
mark generators shrinkPoint --family <object> --point <object> --fails <object>
As data
{"$proc":["generators","shrinkPoint"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/generators/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["generators","shrinkPoint"], { family: {}, point: {}, fails: {} });
console.log(JSON.stringify(result));

From the command line

$ mark generators shrinkPoint --family <object> --point <object> --fails <object>

As data, in a program

{
  "$proc": ["generators", "shrinkPoint"],
  "input": { "family": {}, "point": {}, "fails": {} }
}

Input

FieldTypeRequiredDefaultDescription
familyobjectyes
pointobjectyes
failsobjectyesOne call of a pure procedure, as data, for the function (point: Readonly<Record<string, number>>) => boolean. It reads each parameter as {"$ref": "<name>"}: point.
optionsobjectno

Output

FieldTypeRequiredDefaultDescription
pointobjectyesThe last point that failed. Each key of the first point stays.
stepsobject[]yesThe moves, in their order.
checksnumberyesThe count of checks, with the check of the first point.
exhaustedbooleanyesThe value `true` tells that the budget of checks ended before a round with no move.
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "family": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "dimensions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "The name of the dimension. It is a key of each point."
                },
                "min": {
                  "type": "number",
                  "description": "The smallest value."
                },
                "max": {
                  "type": "number",
                  "description": "The largest value. A uniform or log dimension that is not `integer` gets values below `max`."
                },
                "distribution": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "family": {
                          "type": "string",
                          "const": "beta"
                        },
                        "a": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "array",
                              "items": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "number"
                                }
                              ],
                              "additionalItems": {},
                              "minItems": 2,
                              "maxItems": 2
                            }
                          ]
                        },
                        "b": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "array",
                              "items": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "number"
                                }
                              ],
                              "additionalItems": {},
                              "minItems": 2,
                              "maxItems": 2
                            }
                          ]
                        }
                      },
                      "required": [
                        "family",
                        "a",
                        "b"
                      ],
                      "additionalProperties": {}
                    },
                    {
                      "type": "object",
                      "properties": {
                        "family": {
                          "type": "string",
                          "const": "lognormal"
                        },
                        "mu": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "array",
                              "items": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "number"
                                }
                              ],
                              "additionalItems": {},
                              "minItems": 2,
                              "maxItems": 2
                            }
                          ]
                        },
                        "sigma": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "array",
                              "items": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "number"
                                }
                              ],
                              "additionalItems": {},
                              "minItems": 2,
                              "maxItems": 2
                            }
                          ]
                        }
                      },
                      "required": [
                        "family",
                        "mu",
                        "sigma"
                      ],
                      "additionalProperties": {}
                    },
                    {
                      "type": "object",
                      "properties": {
                        "family": {
                          "type": "string",
                          "const": "mixture"
                        },
                        "parts": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "weight": {
                                "type": "number"
                              },
                              "part": {
                                "$ref": "#/definitions/__schema0"
                              }
                            },
                            "required": [
                              "weight",
                              "part"
                            ],
                            "additionalProperties": {}
                          }
                        }
                      },
                      "required": [
                        "family",
                        "parts"
                      ],
                      "additionalProperties": {}
                    },
                    {
                      "type": "object",
                      "properties": {
                        "family": {
                          "type": "string",
                          "const": "pareto"
                        },
                        "scale": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "array",
                              "items": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "number"
                                }
                              ],
                              "additionalItems": {},
                              "minItems": 2,
                              "maxItems": 2
                            }
                          ]
                        },
                        "shape": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "array",
                              "items": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "number"
                                }
                              ],
                              "additionalItems": {},
                              "minItems": 2,
                              "maxItems": 2
                            }
                          ]
                        }
                      },
                      "required": [
                        "family",
                        "scale",
                        "shape"
                      ],
                      "additionalProperties": {}
                    },
                    {
                      "type": "object",
                      "properties": {
                        "family": {
                          "type": "string",
                          "const": "recorded"
                        },
                        "values": {
                          "type": "array",
                          "items": {
                            "type": "number"
                          }
                        }
                      },
                      "required": [
                        "family",
                        "values"
                      ],
                      "additionalProperties": {}
                    },
                    {
                      "type": "object",
                      "properties": {
                        "family": {
                          "type": "string",
                          "const": "zipf"
                        },
                        "n": {
                          "type": "number"
                        },
                        "exponent": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "array",
                              "items": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "number"
                                }
                              ],
                              "additionalItems": {},
                              "minItems": 2,
                              "maxItems": 2
                            }
                          ]
                        }
                      },
                      "required": [
                        "family",
                        "n",
                        "exponent"
                      ],
                      "additionalProperties": {}
                    }
                  ],
                  "description": "The distribution of the values, cut to the range. Without it, the values are uniform in the range."
                },
                "scale": {
                  "type": "string",
                  "enum": [
                    "linear",
                    "log"
                  ],
                  "description": "With `log`, the logarithm of the value is uniform. `min` must be above 0. A dimension with a distribution has no scale."
                },
                "integer": {
                  "type": "boolean",
                  "description": "With `true`, each value is an integer. `min` and `max` must be integers."
                }
              },
              "required": [
                "name",
                "min",
                "max"
              ],
              "additionalProperties": {}
            }
          }
        },
        "required": [
          "name",
          "dimensions"
        ],
        "additionalProperties": {}
      },
      "point": {
        "type": "object",
        "properties": {},
        "additionalProperties": {
          "type": "number"
        }
      },
      "fails": {
        "type": "object",
        "properties": {
          "$proc": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "input": {},
          "$when": {
            "type": "string",
            "const": "$never"
          }
        },
        "required": [
          "$proc"
        ],
        "additionalProperties": {},
        "x-procedures-program": {
          "params": [
            "point"
          ],
          "inputs": [
            {
              "type": "object",
              "properties": {},
              "additionalProperties": {
                "type": "number"
              }
            }
          ],
          "output": {
            "type": "boolean"
          }
        },
        "description": "One call of a pure procedure, as data, for the function (point: Readonly<Record<string, number>>) => boolean. It reads each parameter as {\"$ref\": \"<name>\"}: point."
      },
      "options": {
        "type": "object",
        "properties": {
          "maxChecks": {
            "type": "number",
            "description": "The most checks of points, with the check of the first point. The default is `SHRINK_CHECKS`."
          },
          "tolerance": {
            "type": "number",
            "description": "The width of the last interval of a bisection on a dimension that is not an integer, as a share of its range. A log dimension uses the range of the logarithm. The default is `SHRINK_TOLERANCE`."
          }
        },
        "additionalProperties": {}
      }
    },
    "required": [
      "family",
      "point",
      "fails"
    ],
    "additionalProperties": false,
    "definitions": {
      "__schema0": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "family": {
                "type": "string",
                "const": "beta"
              },
              "a": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 2,
                    "maxItems": 2
                  }
                ]
              },
              "b": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 2,
                    "maxItems": 2
                  }
                ]
              }
            },
            "required": [
              "family",
              "a",
              "b"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "family": {
                "type": "string",
                "const": "lognormal"
              },
              "mu": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 2,
                    "maxItems": 2
                  }
                ]
              },
              "sigma": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 2,
                    "maxItems": 2
                  }
                ]
              }
            },
            "required": [
              "family",
              "mu",
              "sigma"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "family": {
                "type": "string",
                "const": "mixture"
              },
              "parts": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "weight": {
                      "type": "number"
                    },
                    "part": {
                      "allOf": [
                        {
                          "$ref": "#/definitions/__schema0"
                        }
                      ]
                    }
                  },
                  "required": [
                    "weight",
                    "part"
                  ],
                  "additionalProperties": {}
                }
              }
            },
            "required": [
              "family",
              "parts"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "family": {
                "type": "string",
                "const": "pareto"
              },
              "scale": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 2,
                    "maxItems": 2
                  }
                ]
              },
              "shape": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 2,
                    "maxItems": 2
                  }
                ]
              }
            },
            "required": [
              "family",
              "scale",
              "shape"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "family": {
                "type": "string",
                "const": "recorded"
              },
              "values": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              }
            },
            "required": [
              "family",
              "values"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "family": {
                "type": "string",
                "const": "zipf"
              },
              "n": {
                "type": "number"
              },
              "exponent": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 2,
                    "maxItems": 2
                  }
                ]
              }
            },
            "required": [
              "family",
              "n",
              "exponent"
            ],
            "additionalProperties": {}
          }
        ]
      }
    }
  },
  "output": {
    "type": "object",
    "properties": {
      "point": {
        "type": "object",
        "properties": {},
        "additionalProperties": {
          "type": "number"
        },
        "description": "The last point that failed. Each key of the first point stays."
      },
      "steps": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "dimension": {
              "type": "string"
            },
            "from": {
              "type": "number"
            },
            "to": {
              "type": "number"
            }
          },
          "required": [
            "dimension",
            "from",
            "to"
          ],
          "additionalProperties": {}
        },
        "description": "The moves, in their order."
      },
      "checks": {
        "type": "number",
        "description": "The count of checks, with the check of the first point."
      },
      "exhausted": {
        "type": "boolean",
        "description": "The value `true` tells that the budget of checks ended before a round with no move."
      }
    },
    "required": [
      "point",
      "steps",
      "checks",
      "exhausted"
    ],
    "additionalProperties": {}
  }
}