From d8f1add506681b0b6c515eced40e63d7d0ab6f4a Mon Sep 17 00:00:00 2001 From: Sandor Magyar <59902336+sandorzm@users.noreply.github.com> Date: Mon, 29 Dec 2025 17:25:04 -0500 Subject: [PATCH 1/3] Clarify problem definition docs --- docs/source/problems/definition.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/source/problems/definition.md b/docs/source/problems/definition.md index e24128a8..7cdfb261 100644 --- a/docs/source/problems/definition.md +++ b/docs/source/problems/definition.md @@ -59,8 +59,8 @@ Moreover, in *pymoo* there exist three different ways for defining a problem: +++ -The majority of optimization algorithms implemented in *pymoo* are population-based, which means that more than one solution is evaluated in each generation. This is ideal for implementing a parallelization of function evaluations. Thus, the default definition of a problem retrieves a **set** of solutions to be evaluated. The actual function evaluation takes place in the `_evaluate` method, which aims to fill the `out` dictionary with the corresponding data. -The function values are supposed to be written into `out["F"]` and the constraints into `out["G"]` if `n_constr` is greater than zero. If another approach is used to compute the function values or the constraints, they must be appropriately converted into a two-dimensional `numpy` array (one dimension for the function values, the other dimension for each element of the population evaluated in the current round). For example, if the function values are written in a regular python list like `F_list = [[], [], ...]`, before returning from the `_evaluate` method, the list must be converted to numpy array with `out["F"] = np.row_stack(F_list_of_lists)`. +The majority of optimization algorithms implemented in *pymoo* are population-based, which means that more than one solution is evaluated in each generation. This is ideal for implementing a parallelization of function evaluations. Thus, the default definition of a problem receives a **set** of solutions to be evaluated. The actual function evaluation takes place in the `_evaluate` method, which aims to fill the `out` dictionary with the corresponding data. +The function values are supposed to be written into `out["F"]` and the constraints into `out["G"]` if `n_constr` is greater than zero. If another approach is used to compute the function values or the constraints, they must be appropriately converted into a two-dimensional `numpy` array (one dimension for the function values, the other dimension for each element of the population evaluated in the current round). For example, if the function values are written in a regular Python list like `F_list = [[], [], ...]`, before returning from the `_evaluate` method, the list must be converted to NumPy array with `out["F"] = np.row_stack(F_list)`. ```{raw-cell} :raw_mimetype: text/restructuredtext @@ -68,10 +68,10 @@ The function values are supposed to be written into `out["F"]` and the constrain .. admonition:: Tip :class: myOwnStyle - How the objective and constraint values are calculate is **irrelevant** from a pymoo's point of view. Whether it is a simple mathematical equation or a discrete-event simulation, you only have to ensure that for each input the corresponding values have been set. + How the objective and constraint values are calculated is **irrelevant** from pymoo's point of view. Whether it is a simple mathematical equation or a discrete-event simulation, you only have to ensure that for each input the corresponding values have been set. ``` -The example below shows a modified **Sphere** problem with a radial constraint located at the center. The problem consists of 10 design variables, one objective, one constraint, and the lower and upper bounds of each variable are in the range of 0 and 1. +The example below shows a modified **Sphere** problem with a radial constraint located at the center. The problem consists of 10 design variables, one objective, one constraint, and lower and upper bounds of 0 and 1 for each variable. ```{code-cell} ipython3 import numpy as np @@ -88,7 +88,7 @@ class SphereWithConstraint(Problem): out["G"] = 0.1 - out["F"] ``` -Assuming the algorithm being used requests to evaluate a set of solutions of size 100, then the input NumPy matrix `x` will be of the shape `(100,10)`. Please note that the two-dimensional matrix is summed up on the first axis which results in a vector of length 100 for `out["F"]`. Thus, NumPy performs a vectorized operation on a matrix to speed up the evaluation. +Assuming the algorithm being used requests to evaluate a set of 100 solutions, the input NumPy matrix `x` will be of the shape `(100,10)`. Please note that the two-dimensional matrix is summed up along each row, which results in a column vector of length 100 for `out["F"]`. NumPy performs vectorized operations on the matrix to speed up the evaluation. ```{raw-cell} :raw_mimetype: text/restructuredtext @@ -119,7 +119,7 @@ class ElementwiseSphereWithConstraint(ElementwiseProblem): out["G"] = np.column_stack([0.1 - out["F"], out["F"] - 0.5]) ``` -Regardless of the number of solutions being asked to be evaluated, the `_evaluate` function retrieves a vector of length 10. The `_evaluate`, however, will be called for each solution. Implementing an element-wise problem, the [Parallelization](../parallelization/index.ipynb) available in *pymoo* using processes or threads can be directly used. +Regardless of the number of solutions to be evaluated, the `_evaluate` function retrieves a vector of length 10. `_evaluate` will be called for each solution. Implementing an element-wise problem, the [Parallelization](../parallelization/index.ipynb) available in *pymoo* using processes or threads can be directly used. Moreover, note that the problem above uses a vector definition for the lower and upper bounds (`xl` and `xu`) because the first variables should cover a different range of values. ```{raw-cell} From fd1b65a5bde0f0e4028a3f93e4c422ff577cde21 Mon Sep 17 00:00:00 2001 From: Sandor Magyar <59902336+sandorzm@users.noreply.github.com> Date: Wed, 31 Dec 2025 10:29:16 -0500 Subject: [PATCH 2/3] Fix another "retrieves" use; clarify bounds description --- docs/source/problems/definition.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/problems/definition.md b/docs/source/problems/definition.md index 7cdfb261..cd3ed3f7 100644 --- a/docs/source/problems/definition.md +++ b/docs/source/problems/definition.md @@ -119,8 +119,8 @@ class ElementwiseSphereWithConstraint(ElementwiseProblem): out["G"] = np.column_stack([0.1 - out["F"], out["F"] - 0.5]) ``` -Regardless of the number of solutions to be evaluated, the `_evaluate` function retrieves a vector of length 10. `_evaluate` will be called for each solution. Implementing an element-wise problem, the [Parallelization](../parallelization/index.ipynb) available in *pymoo* using processes or threads can be directly used. -Moreover, note that the problem above uses a vector definition for the lower and upper bounds (`xl` and `xu`) because the first variables should cover a different range of values. +Regardless of the number of solutions to be evaluated, the `_evaluate` function receives a vector of length 10. `_evaluate` will be called for each solution. Implementing an element-wise problem, the [Parallelization](../parallelization/index.ipynb) available in *pymoo* using processes or threads can be directly used. +Note that the problem above uses a vector definition for the lower and upper bounds (`xl` and `xu`) so the first variable can have different bounds than the others. ```{raw-cell} :raw_mimetype: text/restructuredtext From 95809f6eac9b3b0b57ab974f67cd2042d0cf2ccd Mon Sep 17 00:00:00 2001 From: Sandor Magyar <59902336+sandorzm@users.noreply.github.com> Date: Wed, 31 Dec 2025 13:02:30 -0500 Subject: [PATCH 3/3] Remove inaccurate "column vector" language --- docs/source/problems/definition.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/problems/definition.md b/docs/source/problems/definition.md index cd3ed3f7..a12e4daa 100644 --- a/docs/source/problems/definition.md +++ b/docs/source/problems/definition.md @@ -88,7 +88,7 @@ class SphereWithConstraint(Problem): out["G"] = 0.1 - out["F"] ``` -Assuming the algorithm being used requests to evaluate a set of 100 solutions, the input NumPy matrix `x` will be of the shape `(100,10)`. Please note that the two-dimensional matrix is summed up along each row, which results in a column vector of length 100 for `out["F"]`. NumPy performs vectorized operations on the matrix to speed up the evaluation. +Assuming the algorithm being used requests to evaluate a set of 100 solutions, the input NumPy matrix `x` will be of the shape `(100,10)`. Please note that the two-dimensional matrix is summed up along each row, which results in a vector of length 100 for `out["F"]`. NumPy performs vectorized operations on the matrix to speed up the evaluation. ```{raw-cell} :raw_mimetype: text/restructuredtext