From 4107e67629e75524cda5fb2fb0c9a0421bb91382 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Fri, 6 Sep 2024 20:15:10 +0000 Subject: [PATCH] Add docs for types --- docs/types.rst | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 docs/types.rst diff --git a/docs/types.rst b/docs/types.rst new file mode 100644 index 00000000..68ac7c60 --- /dev/null +++ b/docs/types.rst @@ -0,0 +1,53 @@ +====================== +Decsion Variable Types +====================== + +Real Valued +----------- + +Real valued variables are expressed as floating-point numbers between +some minimum and maximum bounds. For example, in the following, we +configure the bounds as `[-10, 10]`: + +.. literalinclude:: ../examples/custom_problem_function.py + :language: python + +Binary +------ + +Binary variables store a "binary string". Traditionally, this is +represented as `0`s and `1`s, but in Platypus, it is stored as an +array of `False` and `True` values. The knapsack problem demonstrates +the binary representation, where an item is selected when the binary +value is `True`. The goal, then, is to maximize the profit of the +selected items while being constrained by the total capacity. + +.. literalinclude:: ../examples/knapsack.py + :language: python + +Integer +------- + +The integer variable is a mix between `Real` and `Binary`. The variable +is constructed with minimum and maximum bounds, but is internally represented +as a Gray-coded binary variable. The Gray-coding ensures each adjacent +integer value can be produced by a single bit mutation. + +Permutation +----------- + +The permutation variable creates a permutation of a list of items. That is, +each item must appear in the list, but the ordering can change. Here we +construct a permutaton of the numbers `0` through `10` using the `range` +functon. However, note that the items is not limited to a list of integers, +any collection of objects can be provided. + +.. literalinclude:: ../examples/permutaton.py + :language: python + +Subset +------ + +Lastly we have the subset. Similar to the mathematical `choose(n, k)` operation, +a subset variable represents a fixed-size selection of size `k` from a +collection of `n` items.