esa / esa/pygmo2

Documentation of decision vector variable types ordering

Open
#176 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
536
Forks
74
PR merge metrics
No merged PRs in 30d

Description

Reading the [documentation](https://esa.github.io/pygmo2/problem.html#pygmo.problem), it does state with mathematical notation ($\mathbf{lb}, \mathbf{ub} \in \mathbb R^{n_{cx}} \times \mathbb Z^{n_{ix}}$) that the decision vector is composed by real variables followed by the integer part, however I think it would be good to explicitly state this with words in the docs.

To verify the order matters (not that I did it by mistake at first and this is how I realised):

```python
class Problem:
def get_bounds(self, ) -> tuple[np.ndarray, np.ndarray]:

# Some unoptimized code
box_bounds_lower = [0, 0, ..., 0, 0.0, ..., 0.0]
box_bounds_upper = [1, 1, ..., 1, 1.0, ..., 1.0]

return box_bounds_lower, box_bounds_upper

# Integer dec. variables before real raises value error
prob = pg.problem(Problem())

# Output:
ValueError:
function: check_problem_bounds
where: /root/install/pagmo2-2.19.0/src/problem.cpp, 104
what: An upper bound of the integer part of the decision vector is: 35.182177 and is not an integer.
```

By changing the bounds order, the error goes away:

```python
...
def get_bounds(self, ) -> tuple[np.ndarray, np.ndarray]:
return box_bounds_lower[::-1], box_bounds_upper[::-1]

prob = pg.problem(Problem())

# Output:
Problem name: SolarMED MINLP problem
C++ class name: pybind11::object

Global dimension: 78
Integer dimension: 24
Fitness dimension: 11
Number of objectives: 1
Equality constraints dimension: 0
Inequality constraints dimension: 10
Tolerances on constraints: [0, 0, 0, 0, 0, ... ]
Lower bounds: [0, 0, 0, 0, 0, ... ]
Upper bounds: [35.3206, 35.286, 35.1822, 0, 0, ... ]
Has batch fitness evaluation: false
```

Also, I wonder if since the data types of the box-bounds already need to match the data type of the decision vector, if it would not be possible to support an arbitrary ordering of the decision vector.

Best regards,
Juanmi

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.