tools
Scalarization
Defines various functions for scalarizing multiobjective optimization problems.
Note that when scalarization functions are defined, they must add the post-fix '_min' to any symbol representing objective functions so that the maximization or minimization of the corresponding objective functions may be correctly accounted for when computing scalarization function values.
Op
Defines the supported operators in the MathJSON format.
Source code in desdeo/tools/scalarization.py
ScalarizationError
__create_HDF
Create a Harrington's one-sided desirability function.
Harrington's desirability function is used to compute the desirability of a given value of an objective function based on its aspiration and reservation levels.
The desirability function is defined as follows:
where
The desirability function returns a value between 0 and 1, where higher values indicate more desirable outcomes. I took the equations from the following source: Wagner, T., and Trautmann, H. Integration of preference in hypervolume-based multiobjective evolutionary algorithms by means of desirability functions. IEEE Transactions on Evolutionary Computation 14, 5 (2010), 688-701.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
str
|
The objective value to compute the desirability for. |
required |
a
|
float
|
Aspiration level for the objective. |
required |
r
|
float
|
Reservation level for the objective. |
required |
d1
|
float
|
The desirability for the aspiration level. |
0.9
|
d2
|
float
|
The desirability for the reservation level. |
0.1
|
Returns:
| Name | Type | Description |
|---|---|---|
callable |
Function
|
A function that computes the desirability for a given value. |
Source code in desdeo/tools/scalarization.py
__create_MDF
Create MaoMao's desirability function.
Distinctions form MaoMao's original function: - The upper and lower bounds of desirability are fixed to 0 and 1, respectively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
str
|
The objective value to compute the desirability for. |
required |
a
|
float
|
Aspiration level for the objective. |
required |
r
|
float
|
Reservation level for the objective. |
required |
d1
|
float
|
The desirability for the aspiration level. |
0.9
|
d2
|
float
|
The desirability for the reservation level. |
0.1
|
Returns:
| Name | Type | Description |
|---|---|---|
callable |
Function
|
A function that computes the desirability for a given value. |
Source code in desdeo/tools/scalarization.py
add_asf_diff
add_asf_diff(
problem: Problem,
symbol: str,
reference_point: dict[str, float],
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
delta: float = 1e-06,
) -> tuple[Problem, str]
Adds the differentiable variant of the achievement scalarizing function.
where \(f_i\) are objective functions, \(z_i^{\star\star} = z_i^\star - \delta\) is a component of the utopian point, \(\bar{z}_i\) is a component of the reference point, \(\rho\) and \(\delta\) are small scalar values, \(S\) is the feasible solution space of the original problem, and \(\alpha\) is an auxiliary variable.
References
Wierzbicki, A. P. (1982). A mathematical basis for satisficing decision making. Mathematical modelling, 3(5), 391-405.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
reference_point
|
dict[str, float]
|
a dict with keys corresponding to objective function symbols and values to reference point components, i.e., aspiration levels. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
delta
|
float
|
a small scalar to define the utopian point. Defaults to 1e-6. |
1e-06
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Todo
Add reference in augmentation term option!
Source code in desdeo/tools/scalarization.py
1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 | |
add_asf_generic_diff
add_asf_generic_diff(
problem: Problem,
symbol: str,
reference_point: dict[str, float],
weights: dict[str, float],
reference_point_aug: dict[str, float] | None = None,
weights_aug: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Adds the differentiable variant of the generic achievement scalarizing function.
where \(f_i\) are objective functions, \(q_i\) is a component of the reference point,
and \(w_i\) are components of the weight vector (which are assumed to be positive),
\(\rho\) and \(\delta\) are small scalar values, \(S\) is the feasible solution
space of the original problem, and \(\alpha\) is an auxiliary variable.
The summation term in the scalarization is known as the augmentation term.
If a reference point is chosen to be used in the augmentation term, e.g., a separate
reference point for the augmentation term is given (reference_point_aug), then
the reference point components are subtracted from the objective function values
in the nominator of the augmentation term. That is:
References
Wierzbicki, A. P. (1982). A mathematical basis for satisficing decision making. Mathematical modelling, 3(5), 391-405.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
reference_point
|
dict[str, float]
|
a dict with keys corresponding to objective function symbols and values to reference point components, i.e., aspiration levels. |
required |
weights
|
dict[str, float]
|
the weights to be used in the scalarization function. Must be positive. |
required |
reference_point_aug
|
dict[str, float]
|
a dict with keys corresponding to objective function symbols and values to reference point components for the augmentation term, i.e., aspiration levels. Defeults to None. |
None
|
weights_aug
|
dict[str, float]
|
the weights to be used in the scalarization function's augmentation term. Must be positive. Defaults to None. |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/scalarization.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
add_asf_generic_nondiff
add_asf_generic_nondiff(
problem: Problem,
symbol: str,
reference_point: dict[str, float],
weights: dict[str, float],
reference_point_aug: dict[str, float] | None = None,
weights_aug: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Adds the generic achievement scalarizing function to a problem with the given reference point, and weights.
This is the non-differentiable variant of the generic achievement scalarizing function, which
means the resulting scalarization function is non-differentiable. Compared to add_asf_nondiff, this
variant is useful, when the problem being scalarized does not have a defined ideal or nadir point,
or both. The weights should be non-zero to avoid zero division.
The scalarization is defined as follows:
where \(\mathbf{q} = [q_1,\dots,q_k]\) is a reference point, \(\mathbf{w} =
[w_1,\dots,w_k]\) are weights, \(k\) is the number of objective functions, and
\(\delta\) and \(\rho\) are small scalar values. The summation term in the
scalarization is known as the augmentation term. If a reference point is
chosen to be used in the augmentation term, e.g., a separate
reference point for the augmentation term is given (reference_point_aug), then
the reference point components are subtracted from the objective function values
in the nominator of the augmentation term. That is:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to which the scalarization function should be added. |
required |
symbol
|
str
|
the symbol to reference the added scalarization function. |
required |
reference_point
|
dict[str, float]
|
a reference point with as many components as there are objectives. |
required |
weights
|
dict[str, float]
|
the weights to be used in the scalarization function. must be positive. |
required |
reference_point_aug
|
dict[str, float]
|
a dict with keys corresponding to objective function symbols and values to reference point components for the augmentation term, i.e., aspiration levels. Defeults to None. |
None
|
weights_aug
|
dict[str, float]
|
the weights to be used in the scalarization function's augmentation term. Must be positive. Defaults to None. |
None
|
rho
|
float
|
the weight factor used in the augmentation term. Defaults to 0.000001. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
If either the reference point or the weights given are missing any of the objective components. |
ScalarizationError
|
If any of the ideal or nadir point values are undefined (None). |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: A tuple containing a copy of the problem with the scalarization function added, and the symbol of the added scalarization function. |
Source code in desdeo/tools/scalarization.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | |
add_asf_nondiff
add_asf_nondiff(
problem: Problem,
symbol: str,
reference_point: dict[str, float],
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
delta: float = 1e-06,
rho: float = 1e-06,
*,
reference_in_aug=False,
) -> tuple[Problem, str]
Add the achievement scalarizing function for a problem with the reference point.
This is the non-differentiable variant of the achievement scalarizing function, which means the resulting scalarization function is non-differentiable. Requires that the ideal and nadir point have been defined for the problem.
The scalarization is defined as follows:
where \(\mathbf{q} = [q_1,\dots,q_k]\) is a reference point, \(\mathbf{z^\star} = [z_1^\star,\dots,z_k^\star]\)
is the ideal point, \(\mathbf{z}^\text{nad} = [z_1^\text{nad},\dots,z_k^\text{nad}]\) is the nadir point, \(k\)
is the number of objective functions, and \(\delta\) and \(\rho\) are small scalar values. The summation term
in the scalarization is known as the augmentation term. If the reference point is chosen to
be used in the augmentation term (reference_in_aug=True), then
the reference point components are subtracted from the objective function values in the nominator
of the augmentation term. That is:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to which the scalarization function should be added. |
required |
symbol
|
str
|
the symbol to reference the added scalarization function. |
required |
reference_point
|
dict[str, float]
|
a reference point as an objective dict. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
delta
|
float
|
the scalar value used to define the utopian point (ideal - delta). Defaults to 0.000001. |
1e-06
|
rho
|
float
|
the weight factor used in the augmentation term. Defaults to 0.000001. |
1e-06
|
reference_in_aug
|
bool
|
whether the reference point should be used in the augmentation term as well. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
there are missing elements in the reference point, or if any of the ideal or nadir point values are undefined (None). |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: A tuple containing a copy of the problem with the scalarization function added, and the symbol of the added scalarization function. |
Source code in desdeo/tools/scalarization.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
add_desirability_funcs
add_desirability_funcs(
problem: Problem,
aspiration_levels: dict[str, float],
reservation_levels: dict[str, float],
desirability_levels: dict[str, tuple[float, float]]
| None = None,
desirability_func: Literal[
"Harrington", "MaoMao"
] = "Harrington",
) -> tuple[Problem, list[str]]
Adds desirability functions to the problem based on the given aspiration and reservation levels.
Note that the desirability functions are added as scalarization functions to the problem. They are also multiplied by -1 to ensure that "desirability" values can be minimized, as is assumed by the optimizers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
The problem to which the desirability functions should be added. |
required |
aspiration_levels
|
dict[str, float]
|
A dictionary with keys corresponding to objective function symbols and values to aspiration levels. |
required |
reservation_levels
|
dict[str, float]
|
A dictionary with keys corresponding to objective function symbols and values to reservation levels. |
required |
desirability_levels
|
dict[str, tuple[float, float]] | None
|
A dictionary with keys corresponding to objective function symbols and values to desirability levels, where each value is a tuple of (d1, d2). If not given, the default values for d1 and d2 are used, which are 0.9 and 0.1 respectively. Defaults to None. |
None
|
desirability_func
|
str
|
The type of desirability function to use. Currently, only "Harrington" or "MaoMao" is supported. Defaults to "Harrington". |
'Harrington'
|
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
A copy of the problem with the added desirability functions as scalarization functions. |
list[str]
|
list[str]: A list of symbols of the added desirability functions. |
Source code in desdeo/tools/scalarization.py
1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 | |
add_epsilon_constraints
add_epsilon_constraints(
problem: Problem,
symbol: str,
constraint_symbols: dict[str, str],
objective_symbol: str,
epsilons: dict[str, float],
) -> tuple[Problem, str, list[str]]
Creates expressions for an epsilon constraints scalarization and constraints.
It is assumed that epsilon have been given in a format where each objective is to be minimized.
The scalarization is defined as follows:
where \(\epsilon_j\) are the epsilon bounds used in the epsilon constraints \(f_j(\mathbf{x}) \leq \epsilon_j\), and \(k\) is the number of objective functions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to scalarize. |
required |
symbol
|
str
|
the symbol of the added objective function to be optimized. |
required |
constraint_symbols
|
dict[str, str]
|
a dict with the symbols to be used with the added constraints. The key indicates the name of the objective function the constraint is related to, and the value is the symbol to be used when defining the constraint. |
required |
objective_symbol
|
str
|
the objective used as the objective in the epsilon constraint scalarization. |
required |
epsilons
|
dict[str, float]
|
the epsilon constraint values in a dict with each key being an objective's symbol. The corresponding value is then used as the epsilon value for the respective objective function. |
required |
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, str, list[str]]
|
tuple[Problem, str, list[str]]: A triple with the first element being a copy of the problem with the added epsilon constraints. The second element is the symbol of the objective to be optimized. The last element is a list with the symbols of the added constraints to the problem. |
Source code in desdeo/tools/scalarization.py
1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 | |
add_guess_sf_diff
add_guess_sf_diff(
problem: Problem,
symbol: str,
reference_point: dict[str, float],
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
delta: float = 1e-06,
) -> tuple[Problem, str]
Adds the differentiable variant of the GUESS scalarizing function.
where \(f_{i}\) are objective functions, \(z_{i}^{nad}\) is a component of the nadir point, \(\bar{z}_{i}\) is a component of the reference point, \(\rho\) is a small scalar value, and \(S\) is the feasible solution space of the original problem. The index set \(I^\diamond\) represents objective vectors whose values are free to change. The indices belonging to this set are interpreted as those objective vectors whose components in the reference point is set to be the the respective nadir point component of the problem. Note that in Buchanan (1997), the GUESS method considers all objective functions, i.e. \(I^\diamond\) is an empty set. The functionality to have free-to-change objectives was added in Miettinen & Mäkelä (2006).
References
Buchanan, J. T. (1997). A naive approach for solving MCDM problems: The GUESS method. Journal of the Operational Research Society, 48, 202-206.
Miettinen, K., & Mäkelä, M. M. (2006). Synchronous approach in interactive multiobjective optimization. European Journal of Operational Research, 170(3), 909-922.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
reference_point
|
dict[str, float]
|
a dict with keys corresponding to objective function symbols and values to reference point components, i.e., aspiration levels. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
delta
|
float
|
a small scalar value to define the utopian point. Defaults to 1e-6. |
1e-06
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/scalarization.py
1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 | |
add_guess_sf_nondiff
add_guess_sf_nondiff(
problem: Problem,
symbol: str,
reference_point: dict[str, float],
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Adds the non-differentiable variant of the GUESS scalarizing function.
where \(f_{i}\) are objective functions, \(z_{i}^{nad}\) is a component of the nadir point, \(\bar{z}_{i}\) is a component of the reference point, \(\rho\) is a small scalar value, and \(S\) is the feasible solution space of the original problem. The index set \(I^\diamond\) represents objective vectors whose values are free to change. The indices belonging to this set are interpreted as those objective vectors whose components in the reference point is set to be the the respective nadir point component of the problem. Note that in Buchanan (1997), the GUESS method considers all objective functions, i.e. \(I^\diamond\) is an empty set. The functionality to have free-to-change objectives was added in Miettinen & Mäkelä (2006).
References
Buchanan, J. T. (1997). A naive approach for solving MCDM problems: The GUESS method. Journal of the Operational Research Society, 48, 202-206.
Miettinen, K., & Mäkelä, M. M. (2006). Synchronous approach in interactive multiobjective optimization. European Journal of Operational Research, 170(3), 909-922.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
reference_point
|
dict[str, float]
|
a dict with keys corresponding to objective function symbols and values to reference point components, i.e., aspiration levels. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/scalarization.py
1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 | |
add_iopis_funcs
add_iopis_funcs(
problem: Problem,
reference_point: dict[str, float],
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
delta: float = 1e-06,
) -> tuple[Problem, list[str]]
Add the IOPIS GUESS and STOM scalarization functions to the problem.
Source code in desdeo/tools/scalarization.py
add_nimbus_sf_diff
add_nimbus_sf_diff(
problem: Problem,
symbol: str,
classifications: dict[str, tuple[str, float | None]],
current_objective_vector: dict[str, float],
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
delta: float = 1e-06,
rho: float = 1e-06,
) -> Problem
Implements the differentiable variant of the NIMBUS scalarization function.
where \(f_i\) are objective functions, \(f_i(\mathbf{x_c})\) is a component of the current objective function, \(\hat{z}_i\) is an aspiration level, \(\varepsilon_i\) is a reservation level, \(z_i^\star\) is a component of the ideal point, \(z_i^{\star\star} = z_i^\star - \delta\) is a component of the utopian point, \(z_i^\text{nad}\) is a component of the nadir point, \(\rho\) is a small scalar, \(S\) is the feasible solution space of the problem (i.e., it means the other constraints of the problem being solved should be accounted for as well), and \(\alpha\) is an auxiliary variable.
The \(I\)-sets are related to the classifications given to each objective function value in respect to the current objective vector (e.g., by a decision maker). They are as follows:
- \(I^{<}\): values that should improve,
- \(I^{\leq}\): values that should improve until a given aspiration level \(\hat{z}_i\),
- \(I^{=}\): values that are fine as they are,
- \(I^{\geq}\): values that can be impaired until some reservation level \(\varepsilon_i\), and
- \(I^{\diamond}\): values that are allowed to change freely (not present explicitly in this scalarization function).
The aspiration levels and the reservation levels are supplied for each classification, when relevant, in
the argument classifications as follows:
classifications = {
"f_1": ("<", None),
"f_2": ("<=", 42.1),
"f_3": (">=", 22.2),
"f_4": ("0", None)
}
Here, we have assumed four objective functions. The key of the dict is a function's symbol, and the tuple
consists of a pair where the left element is the classification (self explanatory, '0' is for objective values
that may change freely), the right element is either None or an aspiration or a reservation level
depending on the classification.
References
Miettinen, K., & Mäkelä, M. M. (2002). On scalarizing functions in multiobjective optimization. OR Spectrum, 24(2), 193-213.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to be scalarized. |
required |
symbol
|
str
|
the symbol given to the scalarization function, i.e., target of the optimization. |
required |
classifications
|
dict[str, tuple[str, float | None]]
|
a dict, where the key is a symbol
of an objective function, and the value is a tuple with a classification and an aspiration
or a reservation level, or |
required |
current_objective_vector
|
dict[str, float]
|
the current objective vector that corresponds to a Pareto optimal solution. The classifications are assumed to been given in respect to this vector. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
delta
|
float
|
a small scalar used to define the utopian point. Defaults to 0.000001. |
1e-06
|
rho
|
float
|
a small scalar used in the augmentation term. Defaults to 0.000001. |
1e-06
|
Returns:
| Type | Description |
|---|---|
Problem
|
tuple[Problem, str]: a tuple with a copy of the problem with the added scalarizations and the symbol of the scalarization. |
Source code in desdeo/tools/scalarization.py
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 | |
add_nimbus_sf_nondiff
add_nimbus_sf_nondiff(
problem: Problem,
symbol: str,
classifications: dict[str, tuple[str, float | None]],
current_objective_vector: dict[str, float],
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
delta: float = 1e-06,
rho: float = 1e-06,
) -> Problem
Implements the non-differentiable variant of the NIMBUS scalarization function.
where \(f_i\) are objective functions, \(f_i(\mathbf{x_c})\) is a component of the current objective function, \(\hat{z}_i\) is an aspiration level, \(\varepsilon_i\) is a reservation level, \(z_i^\star\) is a component of the ideal point, \(z_i^{\star\star} = z_i^\star - \delta\) is a component of the utopian point, \(z_i^\text{nad}\) is a component of the nadir point, \(\rho\) is a small scalar, and \(S\) is the feasible solution space of the problem (i.e., it means the other constraints of the problem being solved should be accounted for as well).
The \(I\)-sets are related to the classifications given to each objective function value in respect to the current objective vector (e.g., by a decision maker). They are as follows:
- \(I^{<}\): values that should improve,
- \(I^{\leq}\): values that should improve until a given aspiration level \(\hat{z}_i\),
- \(I^{=}\): values that are fine as they are,
- \(I^{\geq}\): values that can be impaired until some reservation level \(\varepsilon_i\), and
- \(I^{\diamond}\): values that are allowed to change freely (not present explicitly in this scalarization function).
The aspiration levels and the reservation levels are supplied for each classification, when relevant, in
the argument classifications as follows:
classifications = {
"f_1": ("<", None),
"f_2": ("<=", 42.1),
"f_3": (">=", 22.2),
"f_4": ("0", None)
}
Here, we have assumed four objective functions. The key of the dict is a function's symbol, and the tuple
consists of a pair where the left element is the classification (self explanatory, '0' is for objective values
that may change freely), the right element is either None or an aspiration or a reservation level
depending on the classification.
References
Miettinen, K., & Mäkelä, M. M. (2002). On scalarizing functions in multiobjective optimization. OR Spectrum, 24(2), 193-213.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to be scalarized. |
required |
symbol
|
str
|
the symbol given to the scalarization function, i.e., target of the optimization. |
required |
classifications
|
dict[str, tuple[str, float | None]]
|
a dict, where the key is a symbol
of an objective function, and the value is a tuple with a classification and an aspiration
or a reservation level, or |
required |
current_objective_vector
|
dict[str, float]
|
the current objective vector that corresponds to a Pareto optimal solution. The classifications are assumed to been given in respect to this vector. |
required |
ideal
|
dict[str, float]
|
optional ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
optional nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
delta
|
float
|
a small scalar used to define the utopian point. Defaults to 0.000001. |
1e-06
|
rho
|
float
|
a small scalar used in the augmentation term. Defaults to 0.000001. |
1e-06
|
Returns:
| Type | Description |
|---|---|
Problem
|
tuple[Problem, str]: a tuple with a copy of the problem with the added scalarizations and the symbol of the scalarization. |
Source code in desdeo/tools/scalarization.py
788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 | |
add_objective_as_scalarization
add_objective_as_scalarization(
problem: Problem, symbol: str, objective_symbol: str
) -> tuple[Problem, str]
Creates a scalarization where one of the problem's objective functions is optimized.
The scalarization is defined as follows:
where \(f_t(\mathbf{x})\) is the objective function to be minimized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to which the scalarization should be added. |
required |
symbol
|
str
|
the symbol to reference the added scalarization function. |
required |
objective_symbol
|
str
|
the symbol of the objective function to be optimized. |
required |
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
the given objective_symbol does not exist in the problem. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: A tuple containing a copy of the problem with the scalarization function added, and the symbol of the added scalarization function. |
Source code in desdeo/tools/scalarization.py
add_stom_sf_diff
add_stom_sf_diff(
problem: Problem,
symbol: str,
reference_point: dict[str, float],
ideal: dict[str, float] | None = None,
rho: float = 1e-06,
delta: float = 1e-06,
) -> tuple[Problem, str]
Adds the differentiable variant of the STOM scalarizing function.
where \(f_i\) are objective functions, \(z_i^{\star\star} = z_i^\star - \delta\) is a component of the utopian point, \(\bar{z}_i\) is a component of the reference point, \(\rho\) and \(\delta\) are small scalar values, \(S\) is the feasible solution space of the original problem, and \(\alpha\) is an auxiliary variable.
References
H. Nakayama, Y. Sawaragi, Satisficing trade-off method for multiobjective programming, in: M. Grauer, A.P. Wierzbicki (Eds.), Interactive Decision Analysis, Springer Verlag, Berlin, 1984, pp. 113-122.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
reference_point
|
dict[str, float]
|
a dict with keys corresponding to objective function symbols and values to reference point components, i.e., aspiration levels. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
delta
|
float
|
a small scalar value to define the utopian point. Defaults to 1e-6. |
1e-06
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/scalarization.py
1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 | |
add_stom_sf_nondiff
add_stom_sf_nondiff(
problem: Problem,
symbol: str,
reference_point: dict[str, float],
ideal: dict[str, float] | None = None,
rho: float = 1e-06,
delta: float = 1e-06,
) -> tuple[Problem, str]
Adds the non-differentiable variant of the STOM scalarizing function.
where \(f_i\) are objective functions, \(z_i^{\star\star} = z_i^\star - \delta\) is a component of the utopian point, \(\bar{z}_i\) is a component of the reference point, \(\rho\) and \(\delta\) are small scalar values, and \(S\) is the feasible solution space of the original problem.
References
H. Nakayama, Y. Sawaragi, Satisficing trade-off method for multiobjective programming, in: M. Grauer, A.P. Wierzbicki (Eds.), Interactive Decision Analysis, Springer Verlag, Berlin, 1984, pp. 113-122.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
reference_point
|
dict[str, float]
|
a dict with keys corresponding to objective function symbols and values to reference point components, i.e., aspiration levels. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
delta
|
float
|
a small scalar value to define the utopian point. Defaults to 1e-6. |
1e-06
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/scalarization.py
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 | |
add_weighted_sums
add_weighted_sums(
problem: Problem, symbol: str, weights: dict[str, float]
) -> tuple[Problem, str]
Add the weighted sums scalarization to a problem with the given weights.
It is assumed that the weights add to 1.
The scalarization is defined as follows:
where \(\mathbf{w} = [w_1,\dots,w_k]\) are the weights and \(k\) is the number of objective functions.
Warning
The weighted sums scalarization is often not capable of finding most Pareto optimal solutions when optimized. It is advised to utilize some better scalarization functions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to which the scalarization should be added. |
required |
symbol
|
str
|
the symbol to reference the added scalarization function. |
required |
weights
|
dict[str, float]
|
the weights. For the method to work, the weights should sum to 1. However, this is not a condition that is checked. |
required |
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
if the weights are missing any of the objective components. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: A tuple containing a copy of the problem with the scalarization function added, and the symbol of the added scalarization function. |
Source code in desdeo/tools/scalarization.py
create_epsilon_constraints_json
create_epsilon_constraints_json(
problem: Problem,
objective_symbol: str,
epsilons: dict[str, float],
) -> tuple[list[str | int | float], list[str]]
Creates JSON expressions for an epsilon constraints scalarization and constraints.
It is assumed that epsilon have been given in a format where each objective is to be minimized.
Warning
To be deprecated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to scalarize. |
required |
objective_symbol
|
str
|
the objective used as the objective in the epsilon constraint scalarization. |
required |
epsilons
|
dict[str, float]
|
the epsilon constraint values in a dict with each key being an objective's symbol. |
required |
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
|
Returns:
| Type | Description |
|---|---|
tuple[list[str | int | float], list[str]]
|
tuple[list, list]: the first element is the expression of the scalarized objective expressed in MathJSON format. The second element is a list of expressions of the constraints expressed in MathJSON format. The constraints are in less than or equal format. |
Source code in desdeo/tools/scalarization.py
objective_dict_has_all_symbols
Check that a dict has all the objective function symbols of a problem as its keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem with the objective symbols. |
required |
obj_dict
|
dict[str, float]
|
a dict that should have a key for each objective symbol. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
whether all the symbols are present or not. |
Source code in desdeo/tools/scalarization.py
Partial scalarization
Scalarization functions that operate on a subset of the problem's objectives.
_build_aug_expr
_build_aug_expr(
weights_aug: dict[str, float] | None,
active_objectives: list,
default_weights: dict[str, float],
all_objectives: list,
corrected_rp_aug: dict[str, float] | None,
) -> str
Build the augmentation sum expression string.
Source code in desdeo/tools/partial_scalarization.py
add_asf_partial_diff
add_asf_partial_diff(
problem: Problem,
symbol: str,
reference_point: dict[str, float],
weights: dict[str, float] | None = None,
reference_point_aug: dict[str, float] | None = None,
weights_aug: dict[str, float] | None = None,
rho: float = 0.001,
) -> tuple[Problem, str]
Adds a differentiable generic ASF that scalarizes only the objectives in reference_point.
This is the partial version of add_asf_generic_diff.
The subset of objectives to scalarize is determined by the keys of reference_point;
objectives not present in reference_point are left out of both the max-term constraints
and the augmentation sum.
where \(I\) is the index set of objectives whose symbols appear in reference_point,
\(q_i\) are the corresponding aspiration levels, and \(w_i\) are the weights.
When weights is None the weights default to nadir_i - ideal_i (in the
minimization-corrected space) for each active objective. In that case every active
objective must have both ideal and nadir defined on its Objective instance,
otherwise a ScalarizationError is raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization function. |
required |
reference_point
|
dict[str, float]
|
maps objective symbols to aspiration levels. Only objectives whose symbols appear here are included in the scalarization. |
required |
weights
|
dict[str, float] | None
|
maps the same objective symbols to positive weight values. If |
None
|
reference_point_aug
|
dict[str, float] | None
|
optional separate reference point for the augmentation term.
Must cover the same subset as |
None
|
weights_aug
|
dict[str, float] | None
|
optional separate weights for the augmentation term, must be positive.
The augmentation term sign-flips maximized objectives internally, so unlike the
pre-correction |
None
|
rho
|
float
|
small scalar multiplier for the augmentation sum. Defaults to 1e-6. |
0.001
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
A tuple of the updated Problem and the symbol of the added scalarization. |
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
if any key in |
ScalarizationError
|
if |
ScalarizationError
|
if |
ScalarizationError
|
if |
ScalarizationError
|
if |
Source code in desdeo/tools/partial_scalarization.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
add_asf_partial_nondiff
add_asf_partial_nondiff(
problem: Problem,
symbol: str,
reference_point: dict[str, float],
weights: dict[str, float] | None = None,
reference_point_aug: dict[str, float] | None = None,
weights_aug: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Adds a non-differentiable partial ASF that scalarizes only the objectives in reference_point.
This is the non-differentiable counterpart of add_asf_partial_diff. The max
operator is expressed directly in the objective function rather than being linearised
with an auxiliary variable and constraints, making the scalarization non-differentiable.
where \(I\) is the index set of objectives whose symbols appear in reference_point,
\(q_i\) are the corresponding aspiration levels, and \(w_i\) are the weights. When
reference_point_aug is provided the augmentation numerator becomes
\(f_i(\mathbf{x}) - q_i^{\text{aug}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization function. |
required |
reference_point
|
dict[str, float]
|
maps objective symbols to aspiration levels. Only objectives whose symbols appear here are included in the scalarization. |
required |
weights
|
dict[str, float] | None
|
maps the same objective symbols to positive weight values. If |
None
|
reference_point_aug
|
dict[str, float] | None
|
optional separate reference point for the augmentation term.
Must cover the same subset as |
None
|
weights_aug
|
dict[str, float] | None
|
optional separate weights for the augmentation term, must be positive.
The augmentation term sign-flips maximized objectives internally, so unlike the
pre-correction |
None
|
rho
|
float
|
small scalar multiplier for the augmentation sum. Defaults to 1e-6. |
1e-06
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
A tuple of the updated Problem and the symbol of the added scalarization. |
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
if any key in |
ScalarizationError
|
if |
ScalarizationError
|
if |
ScalarizationError
|
if |
ScalarizationError
|
if |
Source code in desdeo/tools/partial_scalarization.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
add_cumulonimbus_diff
add_cumulonimbus_diff(
problem: Problem,
symbol: str,
classifications: dict[str, tuple[str, float | None]],
current_objective_vector: dict[str, float],
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
reference_point_aug: dict[str, float] | None = None,
weights_aug: dict[str, float] | None = None,
delta: float = 1e-06,
rho: float = 0.001,
) -> tuple[Problem, str]
Adds a differentiable partial NIMBUS scalarization that only covers classified objectives.
This is the partial variant of add_nimbus_sf_diff.
Unlike the full NIMBUS scalarization, classifications does not need to cover every
objective in the problem — objectives whose symbols are absent from classifications
are left unconstrained (treated as free, equivalent to the "0" class).
where \(I\) is the index set of classified objectives (keys of classifications),
\(z_i^{\star\star} = z_i^\star - \delta\) is the utopian point component,
\(w_i^{\text{aug}}\) are the augmentation weights (defaulting to \(z_i^{\text{nad}} - z_i^{\star\star}\)),
\(q_i^{\text{aug}}\) is the optional augmentation reference point (omitted when not provided),
and all other notation follows add_nimbus_sf_diff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to be scalarized. |
required |
symbol
|
str
|
the symbol given to the added scalarization function. |
required |
classifications
|
dict[str, tuple[str, float | None]]
|
maps objective symbols to |
required |
current_objective_vector
|
dict[str, float]
|
current objective values needed for |
required |
ideal
|
dict[str, float] | None
|
ideal point override. If |
None
|
nadir
|
dict[str, float] | None
|
nadir point override. If |
None
|
reference_point_aug
|
dict[str, float] | None
|
optional reference point for the augmentation term. When provided,
each augmentation term becomes |
None
|
weights_aug
|
dict[str, float] | None
|
optional weights for the augmentation term, must be positive. Replaces
the default |
None
|
delta
|
float
|
small scalar for the utopian offset. Defaults to 1e-6. |
1e-06
|
rho
|
float
|
small scalar for the augmentation term. Defaults to 1e-3. |
0.001
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
A tuple of the updated Problem and the symbol of the added scalarization. |
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
if any key in |
ScalarizationError
|
if an objective classified as |
ScalarizationError
|
if ideal or nadir cannot be determined for an active objective. |
ScalarizationError
|
if |
Source code in desdeo/tools/partial_scalarization.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | |
Group scalarization
Group scalarization functions split from scalarization.py.
This module contains all functions with 'group' in their name, previously located in scalarization.py.
add_group_asf
add_group_asf(
problem: Problem,
symbol: str,
reference_points: list[dict[str, float]],
agg_bounds: dict[str, float] | None = None,
delta: dict[str, float] | float = 1e-06,
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Add the achievement scalarizing function for multiple decision makers.
The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{z^{nad}_{id} - z^{uto}_{id}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to which the scalarization function should be added. |
required |
symbol
|
str
|
the symbol to reference the added scalarization function. |
required |
reference_points
|
list[dict[str, float]]
|
a list of reference points as objective dicts. |
required |
agg_bounds
|
dict[str, float]
|
a dictionary of bounds not to violate. |
None
|
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
delta
|
float
|
a small scalar used to define the utopian point. Defaults to 1e-6. |
1e-06
|
rho
|
float
|
the weight factor used in the augmentation term. Defaults to 1e-6. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
there are missing elements in any reference point. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: A tuple containing a copy of the problem with the scalarization function added, and the symbol of the added scalarization function. |
Source code in desdeo/tools/group_scalarization.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
add_group_asf_agg
add_group_asf_agg(
problem: Problem,
symbol: str,
agg_aspirations: dict[str, float],
agg_bounds: dict[str, float],
delta: dict[str, float] | float = 1e-06,
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Add the achievement scalarizing function for multiple decision makers.
Both aggregated aspiration levels (min aspirations) and agg bounds (max bounds) are required.
The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{z^{nad}_{id} - z^{uto}_{id}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to which the scalarization function should be added. |
required |
symbol
|
str
|
the symbol to reference the added scalarization function. |
required |
agg_aspirations
|
dict[str, float]
|
a dictionary of aggregated aspiration levels (min aspirations). |
required |
agg_bounds
|
dict[str, float]
|
a dictionary of aggregated bounds (max bounds). |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
delta
|
float
|
a small scalar used to define the utopian point. Defaults to 1e-6. |
1e-06
|
rho
|
float
|
the weight factor used in the augmentation term. Defaults to 1e-6. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
there are missing elements in any reference point. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: A tuple containing a copy of the problem with the scalarization function added, and the symbol of the added scalarization function. |
Source code in desdeo/tools/group_scalarization.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
add_group_asf_agg_diff
add_group_asf_agg_diff(
problem: Problem,
symbol: str,
agg_aspirations: dict[str, float],
agg_bounds: dict[str, float] | None = None,
delta: dict[str, float] | float = 1000000.0,
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Add the differentiable variant of the achievement scalarizing function for multiple decision makers.
Both aggregated aspiration levels (min aspirations) and agg bounds (max bounds) are required. The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{z^{nad}_{id} - z^{uto}_{id}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to which the scalarization function should be added. |
required |
symbol
|
str
|
the symbol to reference the added scalarization function. |
required |
agg_aspirations
|
dict[str, float]
|
a dictionary of aggregated aspiration levels (min aspirations). |
required |
agg_bounds
|
dict[str, float]
|
a dictionary of bounds not to violate. |
None
|
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
delta
|
float
|
a small scalar used to define the utopian point. Defaults to 1e-6. |
1000000.0
|
rho
|
float
|
the weight factor used in the augmentation term. Defaults to 1e-6. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
there are missing elements in any reference point. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: A tuple containing a copy of the problem with the scalarization function added, and the symbol of the added scalarization function. |
Source code in desdeo/tools/group_scalarization.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 | |
add_group_asf_diff
add_group_asf_diff(
problem: Problem,
symbol: str,
reference_points: list[dict[str, float]],
agg_bounds: dict[str, float] | None = None,
delta: dict[str, float] | float = 1000000.0,
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Add the differentiable variant of the achievement scalarizing function for multiple decision makers.
The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{z^{nad}_{id} - z^{uto}_{id}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to which the scalarization function should be added. |
required |
symbol
|
str
|
the symbol to reference the added scalarization function. |
required |
reference_points
|
list[dict[str, float]]
|
a list of reference points as objective dicts. |
required |
agg_bounds
|
dict[str, float]
|
a dictionary of bounds not to violate. |
None
|
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
delta
|
float
|
a small scalar used to define the utopian point. Defaults to 1e-6. |
1000000.0
|
rho
|
float
|
the weight factor used in the augmentation term. Defaults to 1e-6. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
there are missing elements in any reference point. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: A tuple containing a copy of the problem with the scalarization function added, and the symbol of the added scalarization function. |
Source code in desdeo/tools/group_scalarization.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | |
add_group_guess
add_group_guess(
problem: Problem,
symbol: str,
reference_points: list[dict[str, float]],
agg_bounds: dict[str, float] | None = None,
delta: dict[str, float] | float = 1e-06,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Adds the non-differentiable variant of the multiple decision maker variant of the GUESS scalarizing function.
The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{z^{nad}_{id} - \overline{z}_{id}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
reference_points
|
list[dict[str, float]]
|
a list of dicts with keys corresponding to objective function symbols and values to reference point components, i.e., aspiration levels. |
required |
agg_bounds
|
dict[str, float]
|
a dictionary of bounds not to violate. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
delta
|
float
|
a small scalar to define the utopian point. Defaults to 1e-6. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
there are missing elements in any reference point. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/group_scalarization.py
2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 | |
add_group_guess_agg
add_group_guess_agg(
problem: Problem,
symbol: str,
agg_aspirations: dict[str, float],
agg_bounds: dict[str, float],
delta: dict[str, float] | float = 1e-06,
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Adds the multiple decision maker variant of the GUESS scalarizing function.
Both aggregated aspiration levels (min aspirations) and agg bounds (max bounds) are required.
The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{\overline{z}_{id} - z^{uto}_{id}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
agg_aspirations
|
dict[str, float]
|
a dictionary of aggregated aspiration levels, i.e., min aspirations. |
required |
agg_bounds
|
dict[str, float]
|
a dictionary of bounds not to violate. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
delta
|
float
|
a small scalar value to define the utopian point. Defaults to 1e-6. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
there are missing elements in any reference point. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/group_scalarization.py
2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 | |
add_group_guess_agg_diff
add_group_guess_agg_diff(
problem: Problem,
symbol: str,
agg_aspirations: dict[str, float],
agg_bounds: dict[str, float] | None = None,
delta: dict[str, float] | float = 1e-06,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Adds the differentiable variant of the multiple decision maker variant of the GUESS scalarizing function.
Both aggregated aspiration levels (min aspirations) and agg bounds (max bounds) are required. The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{z^{nad}_{id} - \overline{z}_{id}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
agg_aspirations
|
dict[str, float]
|
a dictionary of aggregated aspiration levels, i.e., min aspirations. |
required |
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
agg_bounds
|
dict[str, float]
|
a dictionary of bounds not to violate. |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
delta
|
float
|
a small scalar to define the utopian point. Defaults to 1e-6. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
there are missing elements in any reference point. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/group_scalarization.py
2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 | |
add_group_guess_diff
add_group_guess_diff(
problem: Problem,
symbol: str,
reference_points: list[dict[str, float]],
agg_bounds: dict[str, float] | None = None,
delta: dict[str, float] | float = 1e-06,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Adds the differentiable variant of the multiple decision maker variant of the GUESS scalarizing function.
The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{z^{nad}_{id} - \overline{z}_{id}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
reference_points
|
list[dict[str, float]]
|
a list of dicts with keys corresponding to objective function symbols and values to reference point components, i.e., aspiration levels. |
required |
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
agg_bounds
|
dict[str, float]
|
a dictionary of bounds not to violate. |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
delta
|
float
|
a small scalar to define the utopian point. Defaults to 1e-6. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
there are missing elements in any reference point. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/group_scalarization.py
2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 | |
add_group_nimbus
add_group_nimbus(
problem: Problem,
symbol: str,
classifications_list: list[
dict[str, tuple[str, float | None]]
],
current_objective_vector: dict[str, float],
agg_bounds: dict[str, float],
delta: dict[str, float] | float = 1e-06,
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Implements the multiple decision maker variant of the NIMBUS scalarization function.
The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{z^{nad}_{id} - z^{uto}_{id}}\), and \(w_{jd} = \frac{1}{z^{nad}_{jd} - z^{uto}_{jd}}\).
The \(I\)-sets are related to the classifications given to each objective function value in respect to the current objective vector (e.g., by a decision maker). They are as follows:
- \(I^{<}\): values that should improve,
- \(I^{\leq}\): values that should improve until a given aspiration level \(\hat{z}_i\),
- \(I^{=}\): values that are fine as they are,
- \(I^{\geq}\): values that can be impaired until some reservation level \(\varepsilon_i\), and
- \(I^{\diamond}\): values that are allowed to change freely (not present explicitly in this scalarization function).
The aspiration levels and the reservation levels are supplied for each classification, when relevant, in
the argument classifications as follows:
classifications = {
"f_1": ("<", None),
"f_2": ("<=", 42.1),
"f_3": (">=", 22.2),
"f_4": ("0", None)
}
Here, we have assumed four objective functions. The key of the dict is a function's symbol, and the tuple
consists of a pair where the left element is the classification (self explanatory, '0' is for objective values
that may change freely), the right element is either None or an aspiration or a reservation level
depending on the classification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to be scalarized. |
required |
symbol
|
str
|
the symbol given to the scalarization function, i.e., target of the optimization. |
required |
classifications_list
|
list[dict[str, tuple[str, float | None]]]
|
a list of dicts, where the key is a symbol
of an objective function, and the value is a tuple with a classification and an aspiration
or a reservation level, or |
required |
current_objective_vector
|
dict[str, float]
|
the current objective vector that corresponds to a Pareto optimal solution. The classifications are assumed to been given in respect to this vector. |
required |
agg_bounds
|
dict[str, float]
|
a dictionary of bounds not to violate. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
delta
|
float
|
a small scalar used to define the utopian point. Defaults to 0.000001. |
1e-06
|
rho
|
float
|
a small scalar used in the augmentation term. Defaults to 0.000001. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
any of the given classifications do not define a classification for all the objective functions or any of the given classifications do not allow at least one objective function value to improve and one to worsen. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/group_scalarization.py
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 | |
add_group_nimbus_compromise
add_group_nimbus_compromise(
problem: Problem,
symbol: str,
group_classification: dict[
str,
tuple[
Literal["improve", "worsen", "conflict"],
list[float],
],
],
current_objective_vector: dict[str, float],
*,
delta: dict[str, float] | float = 1e-06,
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
find_compromise: bool = True,
) -> tuple[Problem, str]
Add a group-based NIMBUS scalarization (multiple decision-maker variant) to a Problem.
This function constructs and attaches a NIMBUS-style scalarization objective and corresponding constraints derived from a group-level classification of objectives. It supports three group classification types for each objective: - "improve": the group wants the objective to improve relative to the provided current objective vector; - "worsen": the group accepts a worsening of the objective but enforces an aggregate bound (agg_bounds); - "conflict": the group contains conflicting preferences; when find_compromise is True a compromise target is formed (median) and used like an "improve" preference if the compromise is an improvement, otherwise the original current point is enforced as in the "improve" fallback when find_compromise is False. Behavior summary - Validates that a classification is provided for every objective in the problem. - Ensures an ideal and nadir point are available (uses corrected problem values if not supplied; raises ScalarizationError otherwise). - Converts objective values for maximization problems to the same minimization convention used internally. - Computes normalization weights for each objective using nadir, ideal, and the provided delta (scalar or per-objective dict), i.e. weight_i = 1 / (nadir_i - (ideal_i - delta_i)). - For each objective, depending on the group classification: - "improve": may add a term to the scalarization's max(...) expression if the chosen target represents an improvement; always adds an improvement constraint that enforces the objective to be at least as good as the current point. - "worsen": adds a constraint preventing the objective from exceeding the provided agg_bounds value. - "conflict": if find_compromise is True, selects the median target from the group's values and treats it like an "improve" (if it improves); otherwise enforces the current point via an improvement constraint. - Constructs a scalarization objective of the form: Max(weight_i * (obj_i_min - ideal_i) for selected i) + rho * sum(weight_j * obj_j_min) where obj_k_min denotes the (possibly flipped) objective expression used for minimization in the scalarization and rho is the small augmentation coefficient. - Creates Constraint objects (with names and symbols derived from each objective) and appends them to the problem along with the new ScalarizationFunction. Parameters - problem (Problem): The problem instance to which the scalarization and constraints will be added. The function calls problem.add_scalarization(...) and problem.add_constraints(...). - symbol (str): Symbol/name for the new scalarization (target of optimization). - group_classification (dict[str, tuple[str, list[float]]]): A mapping from objective symbol -> (classification, group_targets). The classification must be one of: "improve", "worsen", "conflict". The second element is a list of numerical target values provided by the group members for that objective. Interpretation: - For "improve": the most ambitious group target is taken (currently the maximum for maximization problems or minimum for minimization problems). - For "worsen": the strictest bound from the group is used to form a bound constraint (implementation currently uses agg_bounds instead). - For "conflict": the median of the group targets is used when find_compromise is True; otherwise treated like enforcing the current point. - current_objective_vector (dict[str, float]): Objective values corresponding to a (reference) Pareto-optimal solution; used as baseline for improvement constraints. - agg_bounds (dict[str, float]): Aggregate bounds that must not be violated for objectives marked as "worsen" (values are converted appropriately for maximization objectives). - delta (dict[str, float] | float, optional): Small utopian offset used to compute normalization weights. If a dict is given it should map objective symbols to deltas; if a scalar is given the same delta is used for all objectives. Default: 1e-6. - ideal (dict[str, float] | None, optional): Ideal point values. If None, the function attempts to obtain a corrected ideal point from the problem instance. - nadir (dict[str, float] | None, optional): Nadir point values. If None, the function attempts to obtain a corrected nadir point from the problem instance. - rho (float, optional): Small augmentation coefficient multiplied by the linear sum of weighted objectives to break ties and enforce weak Pareto optimality. Default: 1e-6. - find_compromise (bool, optional): If True, conflicting objectives use a median compromise target; otherwise conflicts are enforced to keep current values. Default: True.
- tuple[Problem, str]: A tuple containing: - A new Problem instance (or the original problem mutated/augmented depending on Problem.add_scalarization/Problem.add_constraints semantics) with the scalarization objective and additional constraints appended. - The symbol (str) of the added scalarization.
- ScalarizationError: if - the group_classification mapping does not provide a classification for every objective in the problem, or - neither an explicit ideal nor a computable corrected ideal is available, or - neither an explicit nadir nor a computable corrected nadir is available.
- KeyError: if group_classification does not contain entries for objective symbols referenced in the problem (note: this will typically surface as KeyError during processing). Notes and implementation details
- The function internally flips maximization objectives into a minimization form using flip_maximized_objective_values(...) so all scalarization math assumes minimization semantics.
- Weight computation uses (nadir - (ideal - delta)); ensure delta is chosen so denominator is positive.
- The "max" term in the scalarization is constructed from selected improving objectives only; the augmentation term is the (weighted) sum over all objectives.
- Constraint objects are created with ConstraintTypeEnum.LTE and names/symbols formatted like "improvement constraint for {symbol}" or "Worsen until constraint for {symbol}".
- The function currently prints group_classification (left for debugging) — this side effect may be removed in production code.
Source code in desdeo/tools/group_scalarization.py
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 | |
add_group_nimbus_compromise_diff
add_group_nimbus_compromise_diff(
problem: Problem,
symbol: str,
group_classification: dict[
str,
tuple[
Literal["improve", "worsen", "conflict"],
list[float],
],
],
current_objective_vector: dict[str, float],
*,
delta: dict[str, float] | float = 1e-06,
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
find_compromise: bool = True,
) -> tuple[Problem, str]
Add a group-based NIMBUS scalarization (multiple decision-maker variant) to a Problem.
This function constructs and attaches a NIMBUS-style scalarization objective and corresponding constraints derived from a group-level classification of objectives. It supports three group classification types for each objective: - "improve": the group wants the objective to improve relative to the provided current objective vector; - "worsen": the group accepts a worsening of the objective but enforces an aggregate bound (agg_bounds); - "conflict": the group contains conflicting preferences; when find_compromise is True a compromise target is formed (median) and used like an "improve" preference if the compromise is an improvement, otherwise the original current point is enforced as in the "improve" fallback when find_compromise is False. Behavior summary - Validates that a classification is provided for every objective in the problem. - Ensures an ideal and nadir point are available (uses corrected problem values if not supplied; raises ScalarizationError otherwise). - Converts objective values for maximization problems to the same minimization convention used internally. - Computes normalization weights for each objective using nadir, ideal, and the provided delta (scalar or per-objective dict), i.e. weight_i = 1 / (nadir_i - (ideal_i - delta_i)). - For each objective, depending on the group classification: - "improve": may add a term to the scalarization's max(...) expression if the chosen target represents an improvement; always adds an improvement constraint that enforces the objective to be at least as good as the current point. - "worsen": adds a constraint preventing the objective from exceeding the provided agg_bounds value. - "conflict": if find_compromise is True, selects the median target from the group's values and treats it like an "improve" (if it improves); otherwise enforces the current point via an improvement constraint. - Constructs a scalarization objective of the form: Max(weight_i * (obj_i_min - ideal_i) for selected i) + rho * sum(weight_j * obj_j_min) where obj_k_min denotes the (possibly flipped) objective expression used for minimization in the scalarization and rho is the small augmentation coefficient. - Creates Constraint objects (with names and symbols derived from each objective) and appends them to the problem along with the new ScalarizationFunction. Parameters - problem (Problem): The problem instance to which the scalarization and constraints will be added. The function calls problem.add_scalarization(...) and problem.add_constraints(...). - symbol (str): Symbol/name for the new scalarization (target of optimization). - group_classification (dict[str, tuple[str, list[float]]]): A mapping from objective symbol -> (classification, group_targets). The classification must be one of: "improve", "worsen", "conflict". The second element is a list of numerical target values provided by the group members for that objective. Interpretation: - For "improve": the most ambitious group target is taken (currently the maximum for maximization problems or minimum for minimization problems). - For "worsen": the strictest bound from the group is used to form a bound constraint (implementation currently uses agg_bounds instead). - For "conflict": the median of the group targets is used when find_compromise is True; otherwise treated like enforcing the current point. - current_objective_vector (dict[str, float]): Objective values corresponding to a (reference) Pareto-optimal solution; used as baseline for improvement constraints. - agg_bounds (dict[str, float]): Aggregate bounds that must not be violated for objectives marked as "worsen" (values are converted appropriately for maximization objectives). - delta (dict[str, float] | float, optional): Small utopian offset used to compute normalization weights. If a dict is given it should map objective symbols to deltas; if a scalar is given the same delta is used for all objectives. Default: 1e-6. - ideal (dict[str, float] | None, optional): Ideal point values. If None, the function attempts to obtain a corrected ideal point from the problem instance. - nadir (dict[str, float] | None, optional): Nadir point values. If None, the function attempts to obtain a corrected nadir point from the problem instance. - rho (float, optional): Small augmentation coefficient multiplied by the linear sum of weighted objectives to break ties and enforce weak Pareto optimality. Default: 1e-6. - find_compromise (bool, optional): If True, conflicting objectives use a median compromise target; otherwise conflicts are enforced to keep current values. Default: True.
- tuple[Problem, str]: A tuple containing: - A new Problem instance (or the original problem mutated/augmented depending on Problem.add_scalarization/Problem.add_constraints semantics) with the scalarization objective and additional constraints appended. - The symbol (str) of the added scalarization.
- ScalarizationError: if - the group_classification mapping does not provide a classification for every objective in the problem, or - neither an explicit ideal nor a computable corrected ideal is available, or - neither an explicit nadir nor a computable corrected nadir is available.
- KeyError: if group_classification does not contain entries for objective symbols referenced in the problem (note: this will typically surface as KeyError during processing). Notes and implementation details
- The function internally flips maximization objectives into a minimization form using flip_maximized_objective_values(...) so all scalarization math assumes minimization semantics.
- Weight computation uses (nadir - (ideal - delta)); ensure delta is chosen so denominator is positive.
- The "max" term in the scalarization is constructed from selected improving objectives only; the augmentation term is the (weighted) sum over all objectives.
- Constraint objects are created with ConstraintTypeEnum.LTE and names/symbols formatted like "improvement constraint for {symbol}" or "Worsen until constraint for {symbol}".
- The function currently prints group_classification (left for debugging) — this side effect may be removed in production code.
Source code in desdeo/tools/group_scalarization.py
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 | |
add_group_nimbus_diff
add_group_nimbus_diff(
problem: Problem,
symbol: str,
classifications_list: list[
dict[str, tuple[str, float | None]]
],
current_objective_vector: dict[str, float],
agg_bounds: dict[str, float],
delta: dict[str, float] | float = 1e-06,
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Implements the differentiable variant of the multiple decision maker of the group NIMBUS scalarization function.
The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{z^{nad}_{id} - z^{uto}_{id}}\), and \(w_{jd} = \frac{1}{z^{nad}_{jd} - z^{uto}_{jd}}\).
The \(I\)-sets are related to the classifications given to each objective function value in respect to the current objective vector (e.g., by a decision maker). They are as follows:
- \(I^{<}\): values that should improve,
- \(I^{\leq}\): values that should improve until a given aspiration level \(\hat{z}_i\),
- \(I^{=}\): values that are fine as they are,
- \(I^{\geq}\): values that can be impaired until some reservation level \(\varepsilon_i\), and
- \(I^{\diamond}\): values that are allowed to change freely (not present explicitly in this scalarization function).
The aspiration levels and the reservation levels are supplied for each classification, when relevant, in
the argument classifications as follows:
classifications = {
"f_1": ("<", None),
"f_2": ("<=", 42.1),
"f_3": (">=", 22.2),
"f_4": ("0", None)
}
Here, we have assumed four objective functions. The key of the dict is a function's symbol, and the tuple
consists of a pair where the left element is the classification (self explanatory, '0' is for objective values
that may change freely), the right element is either None or an aspiration or a reservation level
depending on the classification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to be scalarized. |
required |
symbol
|
str
|
the symbol given to the scalarization function, i.e., target of the optimization. |
required |
classifications_list
|
list[dict[str, tuple[str, float | None]]]
|
a list of dicts, where the key is a symbol
of an objective function, and the value is a tuple with a classification and an aspiration
or a reservation level, or |
required |
current_objective_vector
|
dict[str, float]
|
the current objective vector that corresponds to a Pareto optimal solution. The classifications are assumed to been given in respect to this vector. |
required |
agg_bounds
|
dict[str, float]
|
a dictionary of bounds not to violate. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
delta
|
float
|
a small scalar used to define the utopian point. Defaults to 0.000001. |
1e-06
|
rho
|
float
|
a small scalar used in the augmentation term. Defaults to 0.000001. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
any of the given classifications do not define a classification for all the objective functions or any of the given classifications do not allow at least one objective function value to improve and one to worsen. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/group_scalarization.py
1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 | |
add_group_nimbus_sf
add_group_nimbus_sf(
problem: Problem,
symbol: str,
classifications_list: list[
dict[str, tuple[str, float | None]]
],
current_objective_vector: dict[str, float],
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
delta: float = 1e-06,
rho: float = 1e-06,
) -> tuple[Problem, str]
Implements the multiple decision maker variant of the NIMBUS scalarization function.
Variant without aggregated bounds.
The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{z^{nad}_{id} - z^{uto}_{id}}\), and \(w_{jd} = \frac{1}{z^{nad}_{jd} - z^{uto}_{jd}}\).
The \(I\)-sets are related to the classifications given to each objective function value in respect to the current objective vector (e.g., by a decision maker). They are as follows:
- \(I^{<}\): values that should improve,
- \(I^{\leq}\): values that should improve until a given aspiration level \(\hat{z}_i\),
- \(I^{=}\): values that are fine as they are,
- \(I^{\geq}\): values that can be impaired until some reservation level \(\varepsilon_i\), and
- \(I^{\diamond}\): values that are allowed to change freely (not present explicitly in this scalarization function).
The aspiration levels and the reservation levels are supplied for each classification, when relevant, in
the argument classifications as follows:
classifications = {
"f_1": ("<", None),
"f_2": ("<=", 42.1),
"f_3": (">=", 22.2),
"f_4": ("0", None)
}
Here, we have assumed four objective functions. The key of the dict is a function's symbol, and the tuple
consists of a pair where the left element is the classification (self explanatory, '0' is for objective values
that may change freely), the right element is either None or an aspiration or a reservation level
depending on the classification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to be scalarized. |
required |
symbol
|
str
|
the symbol given to the scalarization function, i.e., target of the optimization. |
required |
classifications_list
|
list[dict[str, tuple[str, float | None]]]
|
a list of dicts, where the key is a symbol
of an objective function, and the value is a tuple with a classification and an aspiration
or a reservation level, or |
required |
current_objective_vector
|
dict[str, float]
|
the current objective vector that corresponds to a Pareto optimal solution. The classifications are assumed to been given in respect to this vector. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
nadir
|
dict[str, float]
|
nadir point values. If not given, attempt will be made to calculate nadir point from problem. |
None
|
delta
|
float
|
a small scalar used to define the utopian point. Defaults to 0.000001. |
1e-06
|
rho
|
float
|
a small scalar used in the augmentation term. Defaults to 0.000001. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
any of the given classifications do not define a classification for all the objective functions or any of the given classifications do not allow at least one objective function value to improve and one to worsen. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/group_scalarization.py
1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 | |
add_group_scenario_sf_diff
add_group_scenario_sf_diff(
problem: Problem,
symbol: str,
reference_points: list[dict[str, float]],
weights: list[dict[str, float]],
epsilon: float = 1e-06,
) -> tuple[Problem, str]
Add the differentiable scenario-based scalarization.
Adds the following scalarization function:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
reference_points
|
list[dict[str, float]]
|
a list of reference points as objective dicts. function symbols and values to reference point components, i.e., aspiration levels. |
required |
weights
|
list[dict[str, float]]
|
the list of weights to be used in the scalarization function. Must be positive. |
required |
epsilon
|
float
|
small augmentation multiplier ε |
1e-06
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: A tuple containing a copy of the problem with the scalarization function added, and the symbol of the added scalarization function. |
Source code in desdeo/tools/group_scalarization.py
2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 | |
add_group_scenario_sf_nondiff
add_group_scenario_sf_nondiff(
problem: Problem,
symbol: str,
reference_points: list[dict[str, float]],
weights: list[dict[str, float]],
epsilon: float = 1e-06,
) -> tuple[Problem, str]
Add the non-differentiable scenario based scalarization function.
Add the following scalarization function:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
reference_points
|
list[dict[str, float]]
|
a list of reference points as objective dicts. function symbols and values to reference point components, i.e., aspiration levels. |
required |
weights
|
list[dict[str, float]]
|
the list of weights to be used in the scalarization function. Must be positive. |
required |
epsilon
|
float
|
small augmentation multiplier ε |
1e-06
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: A tuple containing a copy of the problem with the scalarization function added, and the symbol of the added scalarization function. |
Source code in desdeo/tools/group_scalarization.py
2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 | |
add_group_stom
add_group_stom(
problem: Problem,
symbol: str,
reference_points: list[dict[str, float]],
agg_bounds: dict[str, float] | None = None,
delta: dict[str, float] | float = 1e-06,
ideal: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Adds the multiple decision maker variant of the STOM scalarizing function.
The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{\overline{z}_{id} - z^{uto}_{id}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
reference_points
|
list[dict[str, float]]
|
a list of dicts with keys corresponding to objective function symbols and values to reference point components, i.e., aspiration levels. |
required |
agg_bounds
|
dict[str, float]
|
a dictionary of bounds not to violate. |
None
|
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
delta
|
float
|
a small scalar value to define the utopian point. Defaults to 1e-6. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
there are missing elements in any reference point. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/group_scalarization.py
1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 | |
add_group_stom_agg
add_group_stom_agg(
problem: Problem,
symbol: str,
agg_aspirations: dict[str, float],
agg_bounds: dict[str, float],
delta: dict[str, float] | float = 1e-06,
ideal: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Adds the multiple decision maker variant of the STOM scalarizing function.
Both aggregated aspiration levels (min aspirations) and agg bounds (max bounds) are required.
The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{\overline{z}_{id} - z^{uto}_{id}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
agg_aspirations
|
dict[str, float]
|
a dictionary of aggregated aspiration levels, i.e., min aspirations. |
required |
agg_bounds
|
dict[str, float]
|
a dictionary of bounds not to violate. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
delta
|
float
|
a small scalar value to define the utopian point. Defaults to 1e-6. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
there are missing elements in any reference point. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/group_scalarization.py
1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 | |
add_group_stom_agg_diff
add_group_stom_agg_diff(
problem: Problem,
symbol: str,
agg_aspirations: dict[str, float],
agg_bounds: dict[str, float] | None = None,
delta: dict[str, float] | float = 1e-06,
ideal: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Adds the differentiable variant of the multiple decision maker variant of the STOM scalarizing function.
Both aggregated aspiration levels (min aspirations) and agg bounds (max bounds) are required. The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{\overline{z}_{id} - z^{uto}_{id}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
agg_aspirations
|
dict[str, float]
|
a dictionary of aggregated aspiration levels, i.e., min aspirations. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
agg_bounds
|
dict[str, float]
|
a dictionary of bounds not to violate. |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
delta
|
float
|
a small scalar value to define the utopian point. Defaults to 1e-6. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
there are missing elements in any reference point. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/group_scalarization.py
2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 | |
add_group_stom_diff
add_group_stom_diff(
problem: Problem,
symbol: str,
reference_points: list[dict[str, float]],
agg_bounds: dict[str, float] | None = None,
delta: dict[str, float] | float = 1e-06,
ideal: dict[str, float] | None = None,
rho: float = 1e-06,
) -> tuple[Problem, str]
Adds the differentiable variant of the multiple decision maker variant of the STOM scalarizing function.
The scalarization function is defined as follows:
where \(w_{id} = \frac{1}{\overline{z}_{id} - z^{uto}_{id}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the scalarization is added to. |
required |
symbol
|
str
|
the symbol given to the added scalarization. |
required |
reference_points
|
list[dict[str, float]]
|
a list of dicts with keys corresponding to objective function symbols and values to reference point components, i.e., aspiration levels. |
required |
ideal
|
dict[str, float]
|
ideal point values. If not given, attempt will be made to calculate ideal point from problem. |
None
|
agg_bounds
|
dict[str, float]
|
a dictionary of bounds not to violate. |
None
|
rho
|
float
|
a small scalar value to scale the sum in the objective function of the scalarization. Defaults to 1e-6. |
1e-06
|
delta
|
float
|
a small scalar value to define the utopian point. Defaults to 1e-6. |
1e-06
|
Raises:
| Type | Description |
|---|---|
ScalarizationError
|
there are missing elements in any reference point. |
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
tuple[Problem, str]: a tuple with the copy of the problem with the added scalarization and the symbol of the added scalarization. |
Source code in desdeo/tools/group_scalarization.py
2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 | |
Gurobipy solver interfaces
Defines solver interfaces for gurobipy.
GurobipySolver
Bases: BaseSolver
Creates a gurobipy solver that utilizes gurobi's own Python implementation.
Source code in desdeo/tools/gurobipy_solver_interfaces.py
__init__
The solver is initialized by supplying a problem and options.
Unlike with Pyomo you do not need to have gurobi installed on your system for this to work. Suitable for solving mixed-integer linear and quadratic optimization problems.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to be solved. |
required |
options
|
dict[str, any]
|
Dictionary of Gurobi parameters to set. You probably don't need to set any of these and can just use the defaults. For available parameters see https://www.gurobi.com/documentation/current/refman/parameters.html |
None
|
Source code in desdeo/tools/gurobipy_solver_interfaces.py
solve
Solve the problem for the given target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
the symbol of the function to be optimized, and which is defined in the problem given when initializing the solver. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
the results of the optimization. |
Source code in desdeo/tools/gurobipy_solver_interfaces.py
PersistentGurobipySolver
Bases: PersistentSolver
A persistent solver class utlizing gurobipy.
Use this instead of create_gurobipy_solver when re-initializing the solver every time the problem is changed is not practical.
Source code in desdeo/tools/gurobipy_solver_interfaces.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
__init__
Initializer for the persistent solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to be transformed in a GurobipyModel. |
required |
options
|
dict[str, any]
|
Dictionary of Gurobi parameters to set. You probably don't need to set any of these and can just use the defaults. For available parameters see https://www.gurobi.com/documentation/current/refman/parameters.html |
None
|
Source code in desdeo/tools/gurobipy_solver_interfaces.py
add_constraint
Add one or more constraint expressions to the solver.
If adding a lot of constraints or dealing with a large model, this function may end up being very slow compared to adding the constraints to the model stored in the evaluator directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
constraint
|
Constraint
|
the constraint function expression or a list of constraint function expressions. |
required |
Raises:
| Type | Description |
|---|---|
GurobipyEvaluatorError
|
when an unsupported constraint type is encountered. |
Returns:
| Type | Description |
|---|---|
Constr | list[Constr]
|
gurobipy.Constr: The gurobipy constraint that was added or a list of gurobipy constraints if the constraint argument was a list. |
Source code in desdeo/tools/gurobipy_solver_interfaces.py
add_objective
Adds an objective function expression to the solver.
Does not yet add any actual gurobipy optimization objectives, only adds them to the dict containing the expressions of the objectives. The objective expressions are stored in the evaluator and the evaluator must add the appropiate gurobipy objective before solving.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objective
|
Objective
|
an objective function expression or a list of objective function expressions to be added. |
required |
Source code in desdeo/tools/gurobipy_solver_interfaces.py
add_scalarization_function
Adds a scalrization expression to the solver.
Scalarizations work identically to objectives, except they are stored in a different dict in the evaluator. If you want to solve the problem using a scalarization, the evaluator needs to set it as an optimization target first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scalarization
|
ScalarizationFunction
|
A scalarization function or a list of scalarization functions to be added. |
required |
Source code in desdeo/tools/gurobipy_solver_interfaces.py
add_variable
add_variable(
variable: Variable
| TensorVariable
| list[Variable]
| list[TensorVariable],
) -> gp.Var | gp.MVar | list[gp.Var] | list[gp.MVar]
Add one or more variables to the solver.
If adding a lot of variables or dealing with a large model, this function may end up being very slow compared to adding the variables to the model stored in the evaluator directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
Variable
|
The definition of the variable or a list of variables to be added. |
required |
Raises:
| Type | Description |
|---|---|
GurobipyEvaluatorError
|
when a problem in extracting the variables is encountered. I.e., the variables are of a non supported type. |
Returns:
| Type | Description |
|---|---|
Var | MVar | list[Var] | list[MVar]
|
gp.Var: the variable that was added to the model or a list of variables if variable argument was a list. |
Source code in desdeo/tools/gurobipy_solver_interfaces.py
remove_constraint
Removes a constraint from the solver.
If removing a lot of constraints or dealing with a very large model this function may be slow because of the model.update() calls. Accessing the model stored in the evaluator directly may be faster.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
a str representing the symbol of the constraint to be removed. Can also be a list of multiple symbols. |
required |
Source code in desdeo/tools/gurobipy_solver_interfaces.py
remove_variable
Removes a variable from the model.
If removing a lot of variables or dealing with a very large model this function may be slow because of the model.update() calls. Accessing the model stored in the evaluator directly may be faster.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
a str representing the symbol of the variable to be removed. Can also be a list of multiple symbols. |
required |
Source code in desdeo/tools/gurobipy_solver_interfaces.py
solve
Solves the current problem with the specified target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
a str representing the symbol of the target function. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
The results of the solver |
Source code in desdeo/tools/gurobipy_solver_interfaces.py
_constraint_contains_objective
Check if a constraint's function contains a specific objective symbol.
Source code in desdeo/tools/gurobipy_solver_interfaces.py
check_gurobi_license
Check if Gurobi is using a full license (not trial).
Returns:
| Type | Description |
|---|---|
str | bool
|
True if using full academic/commercial license False if using trial license or no license found |
Source code in desdeo/tools/gurobipy_solver_interfaces.py
parse_gurobipy_optimizer_results
Parses results from GurobipyEvaluator's model into DESDEO SolverResults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem being solved. |
required |
evaluator
|
GurobipyEvaluator
|
the evaluator utilized to solve the problem. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
DESDEO solver results. |
Source code in desdeo/tools/gurobipy_solver_interfaces.py
CVXPY solver interfaces
Defines solver interfaces for cvxpy.
CVXPYSolver
Bases: BaseSolver
Creates a CVXPY solver that utilizes CVXPY's optimization capabilities.
Source code in desdeo/tools/cvxpy_solver_interfaces.py
__init__
The solver is initialized by supplying a problem and options.
CVXPY is a Python-embedded modeling language for convex optimization problems, supporting a broad range of problem types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to be solved. |
required |
options
|
CVXPYSolverOptions
|
Pydantic model containing solver options for CVXPY. For available options see https://www.cvxpy.org/api_reference/cvxpy.problems.html#solve |
_default_cvxpy_options
|
Source code in desdeo/tools/cvxpy_solver_interfaces.py
solve
Solve the problem for the given target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
the symbol of the function to be optimized, and which is defined in the problem given when initializing the solver. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
the results of the optimization. |
Source code in desdeo/tools/cvxpy_solver_interfaces.py
CVXPYSolverOptions
Bases: BaseModel
Defines a pydantic model to store and pass options to the CVXPY solver.
Source code in desdeo/tools/cvxpy_solver_interfaces.py
check_cvxpy_suitability
Checks whether a problem is suitable for being solved with CVXPY.
Source code in desdeo/tools/cvxpy_solver_interfaces.py
parse_cvxpy_optimizer_results
Parses results from CVXPYEvaluator's problem into DESDEO SolverResults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem being solved. |
required |
evaluator
|
CVXPYEvaluator
|
the evaluator utilized to solve the problem. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
DESDEO solver results. |
Source code in desdeo/tools/cvxpy_solver_interfaces.py
Nevergrad solver interfaces
Solver interfaces to the optimization routines found in nevergrad.
For more info, see https://facebookresearch.github.io/nevergrad/index.html
_default_nevergrad_generic_options
module-attribute
The set of default options for nevergrad's NgOpt optimizer.
NevergradGenericOptions
Bases: BaseModel
Defines options to be passed to nevergrad's optimization routines.
Source code in desdeo/tools/ng_solver_interfaces.py
budget
class-attribute
instance-attribute
budget: int = Field(
description="The maximum number of allowed function evaluations.",
default=100,
)
The maximum number of allowed function evaluations. Defaults to 100.
num_workers
class-attribute
instance-attribute
num_workers: int = Field(
description="The maximum number of allowed parallel evaluations.",
default=1,
)
The maximum number of allowed parallel evaluations. This is currently used to define the batch size when evaluating problems. Defaults to 1.
optimizer
class-attribute
instance-attribute
optimizer: Literal[*available_nevergrad_optimizers,] = (
Field(
description="The optimizer to be used. Must be one of `NGOpt`, `TwoPointDE`, `PortfolioDiscreteOnePlusOne`, `OnePlusOne`, `CMA`, `TBPSA`, `PSO`, `ScrHammersleySearchPlusMiddlePoint`, or `RandomSearch`. Defaults to `NGOpt`.",
default="NGOpt",
)
)
The optimizer to be used. Must be one of NGOpt, TwoPointsDE, PortfolioDiscreteOnePlusOne,
OnePlusOne, CMA, TBPSA, PSO, ScrHammersleySearchPlusMiddlePoint, or RandomSearch.
Defaults to NGOpt.
NevergradGenericSolver
Bases: BaseSolver
Creates a solver that utilizes optimizations routines found in the nevergrad library.
Source code in desdeo/tools/ng_solver_interfaces.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
__init__
__init__(
problem: Problem,
options: NevergradGenericOptions
| None = _default_nevergrad_generic_options,
)
Creates a solver that utilizes optimizations routines found in the nevergrad library.
These solvers are best utilized for black-box, gradient free optimization with
computationally expensive function calls. Utilizing multiple workers is recommended
(see NevergradGenericOptions) when function calls are heavily I/O bound.
See https://facebookresearch.github.io/nevergrad/getting_started.html for further information on nevergrad and its solvers.
References
Rapin, J., & Teytaud, O. (2018). Nevergrad - A gradient-free optimization platform. GitHub. https://GitHub.com/FacebookResearch/Nevergrad
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to be solved. |
required |
options
|
NgOptOptions | None
|
options to be passes to the solver.
If none, |
_default_nevergrad_generic_options
|
Source code in desdeo/tools/ng_solver_interfaces.py
solve
Solve the problem for the given target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
the symbol of the objective function to be optimized. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
the results of the optimization. |
Source code in desdeo/tools/ng_solver_interfaces.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
parse_ng_results
Parses the optimization results returned by nevergrad solvers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
dict
|
the results. A dict with at least the keys
|
required |
problem
|
Problem
|
the problem the results belong to. |
required |
evaluator
|
GenericEvaluator
|
the evaluator used to evaluate the problem. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
a pydantic dataclass withthe relevant optimization results. |
Source code in desdeo/tools/ng_solver_interfaces.py
Scipy solver interfaces
Solver interfaces to the optimization routines found in scipy.
These solvers can solve various scalarized problems of multiobjective optimization problems.
EvalTargetEnum
Bases: StrEnum
An enum that describe whether the evaluator target is an objective or a constraint.
Source code in desdeo/tools/scipy_solver_interfaces.py
ScipyDeOptions
Bases: BaseModel
Defines a pydantic model to store and pass options to the Scipy differential evolution solver.
Source code in desdeo/tools/scipy_solver_interfaces.py
ScipyDeSolver
Bases: BaseSolver
Creates a scipy solver that utilizes differential evolution.
Source code in desdeo/tools/scipy_solver_interfaces.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
__init__
Creates a solver that utilizes the scipy.optimize.differential_evolution routine.
The scipy.optimize.differential_evolution routine is fully accessible through this function.
For additional details and explanation of some of the argumetns, see
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.differential_evolution.html
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the multiobjective optimization problem to be solved. |
required |
options
|
ScipyDeOptions
|
Pydantic model containing arguments used by scipy DE solver. |
_default_scipy_de_options
|
Source code in desdeo/tools/scipy_solver_interfaces.py
solve
Solve the problem for a given target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
the symbol of the objective function to be optimized. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
results of the optimization. |
Source code in desdeo/tools/scipy_solver_interfaces.py
ScipyMinimizeOptions
Bases: BaseModel
Defines a pydantic model to store and pass options to the Scipy Minimize solver.
Source code in desdeo/tools/scipy_solver_interfaces.py
ScipyMinimizeSolver
Bases: BaseSolver
Creates a scipy solver that utilizes the minimization routine.
Source code in desdeo/tools/scipy_solver_interfaces.py
__init__
Initializes a solver that utilizes the scipy.optimize.minimize routine.
The scipy.optimize.minimze routine is fully accessible through this function.
For additional details and explanation of some of the argumetns, see
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html#scipy.optimize.minimize
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the multiobjective optimization problem to be solved. |
required |
options
|
ScipyMinimizeOptions
|
(ScipyMinimizeOptions): Pydantic model containing args for scipy minimize solver. |
_default_scipy_minimize_options
|
Source code in desdeo/tools/scipy_solver_interfaces.py
solve
Solves the problem for a given target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
the sumbol of the objective function to be optimized. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
results of the optimization. |
Source code in desdeo/tools/scipy_solver_interfaces.py
create_scipy_dict_constraints
Creates a dict with scipy compatible constraints.
It is assumed that there are constraints defined in problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the Problem with the constraints. |
required |
evaluator
|
GenericEvaluator
|
the evaluator utilized to evaluate problem. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
a dict with scipy compatible constraints. |
Source code in desdeo/tools/scipy_solver_interfaces.py
create_scipy_object_constraints
create_scipy_object_constraints(
problem: Problem, evaluator: PolarsEvaluator
) -> list[NonlinearConstraint]
Creates a list with scipy constraint object NonLinearConstraints used by some scipy routines.
For more infor, see https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.NonlinearConstraint.html#scipy-optimize-nonlinearconstraint
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem with the original constraint to be utilized in creating the list of constraints. |
required |
evaluator
|
GenericEvaluator
|
the evaluator corresponding to problem that can be used to evaluate the constraints. |
required |
Returns:
| Type | Description |
|---|---|
list[NonlinearConstraint]
|
list[NonlinearConstraint]: a list of scipy's NonLinearConstraint objects. |
Source code in desdeo/tools/scipy_solver_interfaces.py
get_scipy_eval
get_scipy_eval(
problem: Problem,
evaluator: PolarsEvaluator,
target: str,
eval_target: EvalTargetEnum,
) -> Callable[[list[float | int]], list[float | int]]
Wraps the problem and evaluator into a callable function that can be used by scipy routines.
The returned function expects an array-like argument, such as a numpy array or list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem being solved. |
required |
evaluator
|
GenericEvaluator
|
the evaluator to evaluate the problem being solved. |
required |
target
|
str
|
the symbol of the objective to of the optimization, defined in problem. |
required |
eval_target
|
EvalTargetEnum
|
either objective or constraints. If objective, it is assumed that the evalution is about evaluating the objective function of the single-objective optimization problem being solved, e.g., a scalarization function defined in problem. If constraint, then the evalution is assumed to be about evaluating the constraints defined in problem. |
required |
Returns:
| Type | Description |
|---|---|
Callable[[list[float | int]], list[float | int]]
|
Callable[[list[float | int]], list[float | int]]: a function that takes as its argument an array like object. |
Note
Constraints in scipy are defined such that a positive number means the constraint is respected. In DESDEO, this is the opposite, e.g., a positive number means a constraint is breached. We take this into account when returning the constraint values, but this does not affect the constraint values computed for the true constraints.
Source code in desdeo/tools/scipy_solver_interfaces.py
get_variable_bounds_pairs
Returns the variable bounds defined in a Problem as a list of tuples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem with the variables of interest. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[float | int, float | int]]
|
list[tuple[float | int, float | int]]: a list of tuples, the first element of each tuple is the lower bound of a variable and the second its upper bound. Each tuple corresponds to a variable. |
Source code in desdeo/tools/scipy_solver_interfaces.py
parse_scipy_optimization_result
parse_scipy_optimization_result(
optimization_result: OptimizeResult,
problem: Problem,
evaluator: PolarsEvaluator,
) -> SolverResults
Parses the optimization results returned by various scipy methods.
For documentation, see https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.OptimizeResult.html#scipy.optimize.OptimizeResult
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
optimization_result
|
OptimizeResult
|
the optimization results. |
required |
problem
|
Problem
|
the problem to which the optimization results correspond to. |
required |
evaluator
|
GenericEvaluator
|
the evaluator that has been used in computing the optimization results. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
a pydantic dataclass with the relevant optimization results. |
Source code in desdeo/tools/scipy_solver_interfaces.py
set_initial_guess
Sets or gets the initial guess for each variable defined in a Problem.
For variables without an initial guess, the initial guess is set to the middle point of the variable's lower and upper bound. If only one of the bounds is defined, that bound is used instead. If neither bound is defined, the initial guess defaults to 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem with the variables of which the initial values are of interest. |
required |
Returns:
| Type | Description |
|---|---|
list[float | int]
|
list[float | int]: a list of numbers, each number represents the initial guess of each variable in the problem. |
Source code in desdeo/tools/scipy_solver_interfaces.py
Pyomo solver interfaces
Defines solver interfaces for pyomo.
_default_bonmin_options
module-attribute
Defines Bonmin options with default values.
_default_cbc_options
module-attribute
Defines CBC options with default values.
_default_ipopt_options
module-attribute
Defines Ipopt optins with default values.
BonminOptions
Bases: BaseModel
Defines a pydantic model to store and pass options to the Bonmin solver.
Because Bonmin utilizes many sub-solver, the options specific to Bonmin
must be prefixed in their name with 'bonmin.{option_name}',
e.g., bonmin.integer_tolerance. For a list of options, see
https://www.coin-or.org/Bonmin/options_list.html
Note
Not all options are available through this model. Please add options as they are needed and make a pull request.
Source code in desdeo/tools/pyomo_solver_interfaces.py
bonmin_algorithm
class-attribute
instance-attribute
bonmin_algorithm: str = Field(
description="Presets some of the options in Bonmin based on the algorithm choice. Defaults to 'B-BB'. A good first option to try is 'B-Hyb'.",
default="B-BB",
)
Presets some of the options in Bonmin based on the algorithm choice. Defaults to 'B-BB'. A good first option to try is 'B-Hyb'.
bonmin_integer_tolerance
class-attribute
instance-attribute
bonmin_integer_tolerance: float = Field(
description="Numbers within this value of an integer are considered integers. Defaults to 1e-6.",
default=1e-06,
)
Numbers within this value of an integer are considered integers. Defaults to 1e-6.
tol
class-attribute
instance-attribute
tol: float = Field(
description="Sets the convergence tolerance of ipopt. Defaults to 1e-8.",
default=1e-08,
)
Sets the convergence tolerance of ipopt. Defaults to 1e-8.
asdict
Converts the Pydantic model into a dict so that Bonmin specific options are in the correct format.
This means that the attributes starting with bonmin_optionname will be
converted to keys in the format bonmin.optionname in the returned dict.
Source code in desdeo/tools/pyomo_solver_interfaces.py
CbcOptions
Bases: BaseModel
Defines a pydantic dataclass to pass options to the CBC solver.
For more information and documentation on the options, see https://github.com/coin-or/Cbc
Note
Not all options are available through this model. Please add options as they are needed and make a pull request.
Source code in desdeo/tools/pyomo_solver_interfaces.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
absolute_gap
class-attribute
instance-attribute
absolute_gap: float = Field(
alias="absoluteGap",
description="Sets the absolute MIP gap (an absolute value) at which the solver will terminate. Defaults to 1.0.",
default=1.0,
)
Sets the absolute MIP gap (an absolute value) at which the solver will terminate. Defaults to 1.0.
feasibility_tolerance
class-attribute
instance-attribute
feasibility_tolerance: float = Field(
alias="feasibilityTolerance",
description="Sets the feasibility tolerance for constraints. Defaults to 1e-6.",
default=1e-06,
)
Sets the feasibility tolerance for constraints. Defaults to 1e-6.
integer_tolerance
class-attribute
instance-attribute
integer_tolerance: float = Field(
alias="integerTolerance",
description="Sets the tolerance for integrality of integer variables. Defaults to 1e-5.",
default=1e-05,
)
Sets the tolerance for integrality of integer variables. Defaults to 1e-5.
log_level
class-attribute
instance-attribute
log_level: int = Field(
alias="logLevel",
description="Controls the level of logging output. Values range from 0 (no output) to 5 (very detailed output). Defaults to 2.",
default=2,
)
Controls the level of logging output. Values range from 0 (no output) to 5 (very detailed output). Defaults to 2.
max_nodes
class-attribute
instance-attribute
max_nodes: int = Field(
alias="maxNodes",
description="Sets the maximum number of branch-and-bound nodes to explore. Defaults to 1000.",
default=1000,
)
Sets the maximum number of branch-and-bound nodes to explore. Defaults to 1000.
max_solutions
class-attribute
instance-attribute
max_solutions: int = Field(
alias="maxSolutions",
description="Limits the number of feasible solutions found by the solver. Defaults to 10.",
default=10,
)
Limits the number of feasible solutions found by the solver. Defaults to 10.
presolve
class-attribute
instance-attribute
presolve: int = Field(
description="Controls the presolve level (0: no presolve, 1: default, 2: aggressive). Defaults to 2.",
default=2,
)
Controls the presolve level (0: no presolve, 1: default, 2: aggressive). Defaults to 2.
ratio_gap
class-attribute
instance-attribute
ratio_gap: float = Field(
alias="ratioGap",
description="Sets the relative MIP gap (as a fraction of the optimal solution value) at which the solver will terminate. Defaults to 0.01.",
default=0.01,
)
Sets the relative MIP gap (as a fraction of the optimal solution value) at which the solver will terminate. Defaults to 0.01.
seconds
class-attribute
instance-attribute
seconds: int = Field(
description="The maximum amount of time (in seconds) the solver should run. Defaults to 600.",
default=600,
)
The maximum amount of time (in seconds) the solver should run. Defaults to 600.
solve
class-attribute
instance-attribute
solve: str = Field(
description="Determines the strategy to use for solving the problem (e.g., 'branchAndCut', 'tree', 'trunk'). Defaults to 'branchAndCut'.",
default="branchAndCut",
)
Determines the strategy to use for solving the problem (e.g., 'branchAndCut', 'tree', 'trunk'). Defaults to 'branchAndCut'.
IpoptOptions
Bases: BaseModel
Defines a pydantic dataclass to pass options to the Ipopt solver.
For more information and documentation on the options, see https://coin-or.github.io/Ipopt/
Note
Not all options are available through this model. Please add options as they are needed and make a pull request.
Source code in desdeo/tools/pyomo_solver_interfaces.py
max_iter
class-attribute
instance-attribute
max_iter: int = Field(
description="Maximum number of iterations. Must be >1. Defaults to 3000.",
default=3000,
)
Maximum number of iterations. Must be >1. Defaults to 3000.
PyomoBonminSolver
Bases: BaseSolver
Creates pyomo solvers that utilize bonmin.
Source code in desdeo/tools/pyomo_solver_interfaces.py
__init__
The solver is initialized with a problem and solver options.
Suitable for mixed-integer problems. The objective function being minimized (target) and the constraint functions must be twice continuously differentiable. When the objective functions and constraints are convex, the solution is exact. When the objective or any of the constraints, or both, are non-convex, then the solution is based on heuristics.
For more info about bonmin, see: https://www.coin-or.org/Bonmin/
Note
Bonmin must be installed on the system running DESDEO, and its executable must be defined in the PATH.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to be solved. |
required |
options
|
BonminOptions
|
options to be passed to the Bonmin solver.
If |
_default_bonmin_options
|
Source code in desdeo/tools/pyomo_solver_interfaces.py
solve
Solve the problem for a given target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
the symbol of the objective function to be optimized. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
the results of the optimization. |
Source code in desdeo/tools/pyomo_solver_interfaces.py
PyomoCBCSolver
Bases: BaseSolver
Create a pyomo solver that utilizes CBC.
Source code in desdeo/tools/pyomo_solver_interfaces.py
__init__
The solver is initialized with a problem and solver options.
Suitable for combinatorial and large-scale mixed-integer linear problems.
For more information, see https://coin-or.github.io/Ipopt/
Note
CBC must be installed on the system running DESDEO, and its executable must be defined in the PATH.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem being solved. |
required |
options
|
CbcOptions
|
options to be passed to the CBC solver.
If |
_default_cbc_options
|
Source code in desdeo/tools/pyomo_solver_interfaces.py
solve
Solve the problem for a given target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
the symbol of the objective function to be optimized. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
results of the Optimization. |
Source code in desdeo/tools/pyomo_solver_interfaces.py
PyomoGurobiSolver
Bases: BaseSolver
Creates a pyomo solver that utilized Gurobi.
Source code in desdeo/tools/pyomo_solver_interfaces.py
__init__
Creates a pyomo solver that utilizes gurobi.
You need to have gurobi installed on your system for this to work.
Suitable for solving mixed-integer linear and quadratic optimization problems.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to be solved. |
required |
options
|
GurobiOptions
|
Dictionary of Gurobi parameters to set. This is passed to pyomo as is, so it works the same as options would for calling pyomo SolverFactory directly. See https://www.gurobi.com/documentation/current/refman/parameters.html for information on the available options |
None
|
Source code in desdeo/tools/pyomo_solver_interfaces.py
solve
Solve the problem for a given target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
the symbol of the objective function to be optimized. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
the results of the optimization. |
Source code in desdeo/tools/pyomo_solver_interfaces.py
PyomoIpoptSolver
Bases: BaseSolver
Create a pyomo solver that utilizes Ipopt.
Source code in desdeo/tools/pyomo_solver_interfaces.py
__init__
The solver is initialized with a problem and solver options.
Suitable for non-linear, twice differentiable constrained problems. The problem may be convex or non-convex.
For more information, see https://coin-or.github.io/Ipopt/
Note
Ipopt must be installed on the system running DESDEO, and its executable must be defined in the PATH.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem being solved. |
required |
options
|
IpoptOptions
|
options to be passed to the Ipopt solver.
If |
_default_ipopt_options
|
Source code in desdeo/tools/pyomo_solver_interfaces.py
solve
Solve the problem for a given target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
the symbol of the objective function to be optimized. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
results of the Optimization. |
Source code in desdeo/tools/pyomo_solver_interfaces.py
parse_pyomo_optimizer_results
parse_pyomo_optimizer_results(
opt_res: SolverResults,
problem: Problem,
evaluator: PyomoEvaluator,
) -> SolverResults
Parses pyomo SolverResults into DESDEO SolverResults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
opt_res
|
SolverResults
|
the pyomo solver results. |
required |
problem
|
Problem
|
the problem being solved. |
required |
evaluator
|
PyomoEvaluator
|
the evaluator utilized to get the pyomo solver results. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
DESDEO solver results. |
Source code in desdeo/tools/pyomo_solver_interfaces.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
Proximal solver
Defines solvers meant to be utilized with Problems with discrete representations.
ProximalSolver
Bases: BaseSolver
Creates a solver that finds the closest solution given a fully discrete problem.
Note
This solver is extremely naive. It will optimize the problem and the result will be a point defined for a discrete problem that is closest (Euclidean distance) to the optimum. The result may be wildly inaccurate depending on how representative the discrete points are of the original problem.
Source code in desdeo/tools/proximal_solver.py
__init__
Creates a solver that assumes the problem being a fully discrete one.
Assumes that problem has only data-based objectives and a discrete definition that fully defines all the objectives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem being solved. |
required |
kwargs
|
Optional[dict]
|
optional keyword arguments. Not used right now, but kept here for compatibility reasons. Defaults to None. |
None
|
Source code in desdeo/tools/proximal_solver.py
solve
Solve the problem for the given target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
the symbol of the objective function to be optimized. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
the results fo the optimization. |
Source code in desdeo/tools/proximal_solver.py
Scenario tools
Tools for constructing and solving scenario-based optimization problems.
_build_constant_maps
_build_constant_maps(
leaf_scenarios: list[str],
scenario_problems: dict[str, Problem],
) -> tuple[
dict[str, dict[str, str]],
dict[str, Constant | TensorConstant],
]
Build per-leaf constant rename maps and the combined constant dict.
Constants whose value is the same in every leaf keep their original symbol.
Constants that differ across leaves are renamed to symbol_leaf.
Returns:
| Name | Type | Description |
|---|---|---|
const_maps |
dict[str, dict[str, str]]
|
{leaf -> {original_sym -> new_sym}} |
combined_constants |
dict[str, Constant | TensorConstant]
|
{new_sym -> Constant | TensorConstant} |
Source code in desdeo/tools/scenarios.py
_build_parent_map
Return a mapping from each node to its parent node.
Source code in desdeo/tools/scenarios.py
_build_variable_maps
_build_variable_maps(
scenario_model: ScenarioModel,
leaf_scenarios: list[str],
parent_map: dict[str, str],
scenario_problems: dict[str, Problem],
) -> tuple[
dict[str, dict[str, str]],
dict[str, Variable | TensorVariable],
]
Build per-leaf variable rename maps and the combined variable dict.
Returns:
| Name | Type | Description |
|---|---|---|
var_maps |
dict[str, dict[str, str]]
|
{leaf -> {original_sym -> new_sym}} |
combined_variables |
dict[str, Variable | TensorVariable]
|
{new_sym -> Variable | TensorVariable} |
Source code in desdeo/tools/scenarios.py
_combine_elements
_combine_elements(
leaf_scenarios: list[str],
scenario_problems: dict[str, Problem],
var_maps: dict[str, dict[str, str]],
const_maps: dict[str, dict[str, str]],
get_list: callable,
make_update: callable,
extra_leaf_maps: dict[str, dict[str, str]]
| None = None,
) -> tuple[list | None, dict[str, dict[str, str]]]
Build a combined list for one element type across all leaf scenarios.
Elements whose renamed func string is identical across every leaf that
carries them are kept as a single shared element (original symbol).
All others get a per-leaf prefix leaf_symbol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
leaf_scenarios
|
list[str]
|
ordered list of leaf scenario names. |
required |
scenario_problems
|
dict[str, Problem]
|
pre-computed {leaf -> Problem} mapping. |
required |
var_maps
|
dict[str, dict[str, str]]
|
per-leaf variable rename maps {leaf -> {orig_sym -> new_sym}}. |
required |
const_maps
|
dict[str, dict[str, str]]
|
per-leaf constant rename maps {leaf -> {orig_sym -> new_sym}}. |
required |
get_list
|
callable
|
callable(Problem) -> list | None of elements. |
required |
make_update
|
callable
|
callable(elem, new_func, leaf) -> dict for model_copy.
|
required |
extra_leaf_maps
|
dict[str, dict[str, str]] | None
|
optional additional per-leaf rename maps merged into
the leaf_map before renaming expressions. Useful for passing
objective-symbol renames (including |
None
|
Returns:
| Type | Description |
|---|---|
tuple[list | None, dict[str, dict[str, str]]]
|
A tuple of (combined list or None, symbol map). The symbol map has the original symbol as key and a {leaf -> new_symbol} dict as value. Leaves that do not carry an element keep the original symbol as their value. |
Source code in desdeo/tools/scenarios.py
_longest_common_name
Return the longest common substring across all names, stripped of edge separators.
Falls back to fallback when the list is empty or no non-empty common substring exists.
Source code in desdeo/tools/scenarios.py
_new_variable_symbol
_new_variable_symbol(
var_sym: str,
leaf: str,
anticipation_stop: dict[str, list[str]],
parent_map: dict[str, str],
) -> str
Return the combined-problem symbol for a variable in a given leaf scenario.
Walks from ROOT toward the leaf. The first (highest) ancestor where the variable appears in anticipation_stop determines sharing:
- ROOT -> all scenarios share one copy; original symbol is kept.
- Other -> all leaves under that node share one copy; symbol gets that node name as prefix.
- None -> fully independent per leaf; symbol gets the leaf name as prefix.
Source code in desdeo/tools/scenarios.py
_path_from_root
Return the path [ROOT, ..., node] inclusive of both ends.
Source code in desdeo/tools/scenarios.py
_pool_names_for
_pool_names_for(
scenario_model: ScenarioModel,
found_type: str,
sym: str,
per_leaf: dict[str, str],
) -> list[str]
Collect distinct pool-element names for sym across the leaves in per_leaf.
Source code in desdeo/tools/scenarios.py
_rename_in_mathjson
Recursively rename symbol strings in a MathJSON node.
Source code in desdeo/tools/scenarios.py
_rename_symbols
Rename symbols in a MathJSON expression (list) or infix string.
Walks the MathJSON tree and substitutes every string leaf that is not a
known operator keyword. If expr is a plain infix string it is first
parsed to MathJSON, then the renaming is applied.
The returned value is always a MathJSON list, which Pydantic's
parse_infix_to_func validator accepts directly without re-parsing.
Source code in desdeo/tools/scenarios.py
append_aggregated_elem
append_aggregated_elem(
found_type: str,
new_objectives: list,
new_scal_funcs: list,
new_extra_funcs: list,
*,
name: str,
symbol: str,
func: Any,
description: str | None = None,
maximize: bool = False,
is_linear: bool = False,
is_convex: bool = False,
is_twice_differentiable: bool = False,
) -> None
Append a new aggregated element to the appropriate list based on found_type.
Appends an Objective if found_type is 'objectives', a ScalarizationFunction if
'scalarization_funcs', and an ExtraFunction for everything else.
description and maximize are only used for objectives.
Source code in desdeo/tools/scenarios.py
build_combined_scenario_problem
build_combined_scenario_problem(
scenario_model: ScenarioModel,
) -> tuple[Problem, dict[str, dict[str, dict[str, str]]]]
Build a single Problem that encodes all leaf scenarios simultaneously.
Decision variables are duplicated once per leaf scenario unless a variable appears in anticipation_stop for an ancestor node, in which case all leaves under that node share one copy. Every objective, constraint, extra function, and scalarization function is also duplicated per leaf, with all variable and scenario-specific constant references rewritten to their renamed counterparts.
Elements whose renamed func string is identical across all leaves that carry them are kept as a single shared element (no per-leaf prefix).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_model
|
ScenarioModel
|
the model to expand into a combined Problem. |
required |
Returns:
| Type | Description |
|---|---|
Problem
|
A tuple of: |
dict[str, dict[str, dict[str, str]]]
|
|
tuple[Problem, dict[str, dict[str, dict[str, str]]]]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
if the model contains no leaf scenarios. |
Source code in desdeo/tools/scenarios.py
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
build_scenario_problem
Build a concrete Problem for a single named scenario.
Applies the scenario's pool overrides and additions to the base problem and returns the resulting Problem instance ready to be passed to a solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_model
|
ScenarioModel
|
the ScenarioModel containing the base problem and pools. |
required |
scenario_name
|
str
|
the key identifying which scenario to construct. |
required |
Returns:
| Type | Description |
|---|---|
Problem
|
A Problem instance with the scenario's elements applied. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if scenario_name is not found in the model. |
Source code in desdeo/tools/scenarios.py
build_scenario_symbol_maps
build_scenario_symbol_maps(
problem: Problem, scenario_model: ScenarioModel
) -> dict[str, dict[str, dict[str, str]]]
Derive element symbol maps from an already-built combined scenario problem.
A lightweight alternative to calling build_combined_scenario_problem
when the combined problem is already available. Infers the per-leaf symbol
for each base element by checking whether {leaf}_{orig} exists among the
combined problem's element symbols.
Covers objectives, extra_funcs, constraints, and
scalarization_funcs; variables are excluded because their naming depends
on anticipation_stop and cannot be inferred from symbol presence alone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the combined scenario problem (as returned by
|
required |
scenario_model
|
ScenarioModel
|
the scenario model used to build |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, dict[str, str]]]
|
Symbol maps dict with keys |
Source code in desdeo/tools/scenarios.py
find_base_elem
Return the first matching element from objectives, extra_funcs, scalarization_funcs, or constraints.
Source code in desdeo/tools/scenarios.py
resolve_elem
resolve_elem(
sym: str,
symbol_maps: dict[str, dict[str, dict[str, str]]],
combined: Problem,
scenario_model: ScenarioModel,
) -> _ElemResolution
Resolve per-symbol metadata needed by aggregation functions.
Looks up the element type and per-leaf symbol map, retrieves the reference element from the combined problem for technical properties, and the original element from the base problem for name and description.
Raises:
| Type | Description |
|---|---|
ValueError
|
if sym is not found in symbol_maps. |
Source code in desdeo/tools/scenarios.py
solve_all_scenarios
solve_all_scenarios(
scenario_model: ScenarioModel,
solver_callable: callable,
solver_options: dict | None = None,
) -> dict[str, SolverResults]
Solve every leaf scenario in the model independently.
Leaf scenarios are nodes in the scenario tree with no children.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_model
|
ScenarioModel
|
the ScenarioModel to solve. |
required |
solver_callable
|
callable
|
a callable that accepts a Problem (and optional options dict) and returns a SolverResults instance. |
required |
solver_options
|
dict | None
|
optional dict of keyword arguments forwarded to solver_callable. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, SolverResults]
|
A dict mapping each leaf scenario name to its SolverResults. |
Source code in desdeo/tools/scenarios.py
solve_scenario
solve_scenario(
scenario_model: ScenarioModel,
scenario_name: str,
solver_callable: callable,
solver_options: dict | None = None,
) -> SolverResults
Solve a single scenario.
Constructs the scenario problem and passes it to the provided solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_model
|
ScenarioModel
|
the ScenarioModel containing the base problem and pools. |
required |
scenario_name
|
str
|
the key identifying which scenario to solve. |
required |
solver_callable
|
callable
|
a callable that accepts a Problem (and optional options dict) and returns a SolverResults instance. |
required |
solver_options
|
dict | None
|
optional dict of keyword arguments forwarded to solver_callable. |
None
|
Returns:
| Type | Description |
|---|---|
SolverResults
|
SolverResults from the solver. |
Source code in desdeo/tools/scenarios.py
Stochastic tools
Tools for solving scenario-based optimization problems.
add_conditional_value_at_risk
add_conditional_value_at_risk(
scenario_model: ScenarioModel,
symbols: list[str],
alpha: float,
var_prefix: str = "VAR_",
cvar_prefix: str = "CVAR_",
combined: Problem | None = None,
symbol_maps: dict[str, dict[str, dict[str, str]]]
| None = None,
) -> tuple[Problem, dict[str, str]]
Add CVaR aggregations using the Rockafellar-Uryasev LP formulation.
For each symbol in symbols, introduces:
{var_prefix}{sym}: VaR threshold variable η (shared across scenarios).{leaf}_{var_prefix}{sym}: per-leaf auxiliary z_s ≥ 0 such that z_s >= sym_s - eta.{leaf}_{var_prefix}{sym}_con: per-leaf LTE constraint sym_s - eta - z_s <= 0.{cvar_prefix}{sym}: CVaR = eta + 1/(1-alpha) * sum_s p_s * z_s.
The CVaR element preserves the type of the original element (objective stays objective, scalarization function stays scalarization function, anything else becomes an extra function).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_model
|
ScenarioModel
|
the ScenarioModel used to build or match |
required |
symbols
|
list[str]
|
original symbols whose CVaR should be added. |
required |
alpha
|
float
|
confidence level, 0 < alpha < 1 (e.g., 0.95 for 95% CVaR). |
required |
var_prefix
|
str
|
prefix for the VaR threshold and auxiliary variables.
Defaults to |
'VAR_'
|
cvar_prefix
|
str
|
prefix for the resulting CVaR element. Defaults to |
'CVAR_'
|
combined
|
Problem | None
|
pre-built combined Problem. If provided together with
|
None
|
symbol_maps
|
dict[str, dict[str, dict[str, str]]] | None
|
pre-built symbol maps; required together with |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, dict[str, str]]
|
A tuple of the updated combined Problem and a dict mapping each original symbol to its CVaR symbol. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if a requested symbol is not found in the combined problem. |
Source code in desdeo/tools/stochastic.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
add_expected_asf
add_expected_asf(
scenario_model: ScenarioModel,
symbol: str,
reference_point: dict[str, float],
ideal: dict[str, float] | None = None,
nadir: dict[str, float] | None = None,
rho: float = 1e-06,
delta: float = 1e-06,
) -> tuple[Problem, str]
Build a combined scenario problem with an expected value of ASF scalarization.
This is here mostly as a convenience for testing, but it can also be used as a template for users who want to build their own scenario problems expected-value scalarizations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_model
|
ScenarioModel
|
the ScenarioModel to expand and scalarize. |
required |
symbol
|
str
|
symbol for the scalarization function added to the problem. |
required |
reference_point
|
dict[str, float]
|
maps objective symbols to reference point values. |
required |
ideal
|
dict[str, float] | None
|
maps objective symbols to ideal values. If None, the problem's ideal is used. |
None
|
nadir
|
dict[str, float] | None
|
maps objective symbols to nadir values. If None, the problem's nadir is used. |
None
|
rho
|
float
|
augmentation term weight for the ASF. |
1e-06
|
delta
|
float
|
small perturbation for the differentiable ASF variant. |
1e-06
|
Returns:
| Type | Description |
|---|---|
tuple[Problem, str]
|
A tuple of the combined Problem and the scalarization function symbol. |
Source code in desdeo/tools/stochastic.py
add_expected_value
add_expected_value(
scenario_model: ScenarioModel,
symbols: list[str],
prefix: str = "E_",
combined: Problem | None = None,
symbol_maps: dict[str, dict[str, dict[str, str]]]
| None = None,
) -> tuple[Problem, dict[str, str]]
Add expected-value aggregations for selected symbols to the combined scenario problem.
For each symbol the expected value is a probability-weighted sum of the per-leaf copies of that symbol in the combined problem. The new element type matches the original: objectives stay objectives, scalarization functions stay scalarization functions, and everything else (extra functions, constraints, …) becomes an extra function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_model
|
ScenarioModel
|
the ScenarioModel to expand. |
required |
symbols
|
list[str]
|
original symbols whose expected values should be added. |
required |
prefix
|
str
|
prefix prepended to each original symbol to form the new symbol.
Defaults to |
'E_'
|
combined
|
Problem | None
|
pre-built combined Problem. If provided together with
|
None
|
symbol_maps
|
dict[str, dict[str, dict[str, str]]] | None
|
pre-built symbol maps from |
None
|
Returns:
| Type | Description |
|---|---|
Problem
|
A tuple of the combined Problem with the expected-value elements appended, |
dict[str, str]
|
and a dict mapping each original symbol to its new expected-value symbol. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if a requested symbol is not found in the combined problem. |
Source code in desdeo/tools/stochastic.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
Robust tools
Tools for worst-case robust optimization over scenario-based problems.
add_single_objective_worst_case_regret
add_single_objective_worst_case_regret(
scenario_model: ScenarioModel,
symbols: list[str],
ideals: dict[str, dict[str, float]],
prefix: str = "regret_wc_",
combined: Problem | None = None,
symbol_maps: dict[str, dict[str, dict[str, str]]]
| None = None,
) -> tuple[Problem, dict[str, str]]
Add worst-case regret aggregations for selected symbols to the combined scenario problem.
For each symbol, the per-scenario regret is the difference between the objective value in that scenario and its ideal (best achievable) value in that scenario:
- Minimise objectives:
regret_s = f_s - ideal_s(ideal is the minimum). - Maximise objectives:
regret_s = ideal_s - f_s(ideal is the maximum).
The worst-case regret across all scenarios is then expressed via the standard
epigraph reformulation: minimise t subject to regret_s - t <= 0 for
every leaf scenario s. The resulting element is always a minimise
objective (or extra function / scalarization function matching the original type)
regardless of the original optimisation direction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_model
|
ScenarioModel
|
the ScenarioModel to expand. |
required |
symbols
|
list[str]
|
original symbols whose worst-case regret should be added. |
required |
ideals
|
dict[str, dict[str, float]]
|
mapping |
required |
prefix
|
str
|
prefix prepended to each original symbol to form the new symbol.
Defaults to |
'regret_wc_'
|
combined
|
Problem | None
|
pre-built combined Problem. If provided together with
|
None
|
symbol_maps
|
dict[str, dict[str, dict[str, str]]] | None
|
pre-built symbol maps from |
None
|
Returns:
| Type | Description |
|---|---|
Problem
|
A tuple of the combined Problem with worst-case regret elements appended, |
dict[str, str]
|
and a dict mapping each original symbol to its regret symbol. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if a requested symbol is not found in the combined problem. |
ValueError
|
if |
Source code in desdeo/tools/robust.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
add_weighted_scenarios
add_weighted_scenarios(
scenario_model: ScenarioModel,
symbols: list[str],
weights: dict[str, float],
prefix: str = "weighted_",
combined: Problem | None = None,
symbol_maps: dict[str, dict[str, dict[str, str]]]
| None = None,
) -> tuple[Problem, dict[str, str]]
Add user-weighted aggregations for selected symbols to the combined scenario problem.
Identical to add_expected_value in desdeo.tools.stochastic, except that the
per-leaf weights come from the caller rather than from the scenario probabilities in
scenario_model. This lets you express, e.g., pessimistic weightings that put
more mass on bad scenarios than their true probabilities warrant.
The new element type matches the original: objectives stay objectives, scalarization functions stay scalarization functions, and everything else becomes an extra function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_model
|
ScenarioModel
|
the ScenarioModel to expand. |
required |
symbols
|
list[str]
|
original symbols whose weighted sums should be added. |
required |
weights
|
dict[str, float]
|
mapping from leaf scenario name to its weight. Must contain a key
for every leaf in |
required |
prefix
|
str
|
prefix prepended to each original symbol to form the new symbol.
Defaults to |
'weighted_'
|
combined
|
Problem | None
|
pre-built combined Problem. If provided together with
|
None
|
symbol_maps
|
dict[str, dict[str, dict[str, str]]] | None
|
pre-built symbol maps from |
None
|
Returns:
| Type | Description |
|---|---|
Problem
|
A tuple of the combined Problem with the weighted elements appended, and a dict |
dict[str, str]
|
mapping each original symbol to its new weighted symbol. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if a requested symbol is not found in the combined problem. |
ValueError
|
if |
Source code in desdeo/tools/robust.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
add_worst_case_robust
add_worst_case_robust(
scenario_model: ScenarioModel,
symbols: list[str],
prefix: str = "robust_",
combined: Problem | None = None,
symbol_maps: dict[str, dict[str, dict[str, str]]]
| None = None,
) -> tuple[Problem, dict[str, str]]
Add worst-case robust aggregations for selected symbols to the combined scenario problem.
Uses the standard epigraph reformulation with an auxiliary variable t and
per-leaf bound constraints, avoiding non-smooth Max/Min expressions that
most solvers cannot handle.
The worst-case direction matches the original optimisation direction:
- Minimise objectives / scalarization functions / extra functions — worst case
is the largest value across scenarios. Adds constraints
f_s - t <= 0and exposestas a new minimise element (equivalent tomin max_s f_s). - Maximise objectives — worst case is the smallest value across scenarios.
Adds constraints
t - f_s <= 0and exposestas a new maximise element (equivalent tomax min_s f_s).
The new element type matches the original: objectives stay objectives, scalarization
functions stay scalarization functions, and everything else becomes an extra function.
The epigraph variable is named _t_{prefix}{sym} and the returned element is
{prefix}{sym}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_model
|
ScenarioModel
|
the ScenarioModel to expand. |
required |
symbols
|
list[str]
|
original symbols whose worst-case values should be added. |
required |
prefix
|
str
|
prefix prepended to each original symbol to form the new symbol.
Defaults to |
'robust_'
|
combined
|
Problem | None
|
pre-built combined Problem. If provided together with
|
None
|
symbol_maps
|
dict[str, dict[str, dict[str, str]]] | None
|
pre-built symbol maps from |
None
|
Returns:
| Type | Description |
|---|---|
Problem
|
A tuple of the combined Problem with robust elements appended, and a dict |
dict[str, str]
|
mapping each original symbol to its robust symbol. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if a requested symbol is not found in the combined problem. |
Source code in desdeo/tools/robust.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
Unary indicators
This module implements unary indicators that can be used to evaluate the quality of a single solution set.
It assumes that the solution set has been normalized just that some ideal point (not necessarily the ideal point of the set) is the origin and some nadir point (not necessarily the nadir point of the set) is (1, 1, ..., 1). The normalized solution set is assumed to be inside the bounding box [0, 1]^k where k is the number of objectives. If these conditions are not met, the results of the indicators will not be meaningful.
Additionally, the set may be assumed to only contain mutually non-dominated solutions, depending on the indicator.
For now, we rely on pymoo for the implementation of some of the indicators.
Find more information about the indicators in: Audet, Charles, et al. "Performance indicators in multiobjective optimization." European journal of operational research 292.2 (2021): 397-422.
DistanceIndicators
Bases: BaseModel
A container for closely related distance based indicators.
Source code in desdeo/tools/indicators_unary.py
ahd
class-attribute
instance-attribute
The average Hausdorff distance indicator value.
gd
class-attribute
instance-attribute
The generational distance indicator value.
gd_p
class-attribute
instance-attribute
gd_p: float = Field(
description="The generational distance indicator, where instead of taking arithmetic mean of the distances, we take the geometric mean."
)
The generational distance indicator, where instead of taking arithmetic mean of the distances,
igd
class-attribute
instance-attribute
The inverted generational distance indicator value.
igd_p
class-attribute
instance-attribute
igd_p: float = Field(
description="The inverted generational distance indicator, where instead of taking arithmetic mean of the distances, we take the geometric mean."
)
The inverted generational distance indicator, where instead of taking arithmetic mean of the distances,
IGDPlusIndicators
Bases: BaseModel
A container for the IGD+ distance-based indicator.
Source code in desdeo/tools/indicators_unary.py
R2Indicator
RMetricIndicators
Bases: BaseModel
A container for R-metric indicators: R-HV and R-IGD.
Source code in desdeo/tools/indicators_unary.py
r_hv
class-attribute
instance-attribute
The R-HV indicator value, based on hypervolume.
distance_indicators
distance_indicators(
solution_set: ndarray,
reference_set: ndarray,
p: float = 2.0,
) -> DistanceIndicators
Calculates various distance based indicators between a solution set and a reference set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution_set
|
ndarray
|
A 2D numpy array where each row is a solution and each column is an objective value. The solutions are assumed to be normalized within the unit hypercube. The ideal and nadir of the set itself can lie within the hypercube, but not outside it. The solutions are assumed to be non-dominated. |
required |
reference_set
|
ndarray
|
A 2D numpy array where each row is a solution and each column is an objective value. The solutions are assumed to be normalized within the unit hypercube. The ideal and nadir of the reference set should probably be (0, 0, ..., 0) and (1, 1, ..., 1) respectively. The reference set is assumed to be non-dominated. |
required |
p
|
float
|
The power of the Minkowski metric. Set to 1 for Manhattan distance and 2 for Euclidean distance, and np.inf (or math.inf) for Chebyshev distance. Defaults to 2.0. |
2.0
|
Returns:
| Name | Type | Description |
|---|---|---|
DistanceIndicators |
DistanceIndicators
|
A Pydantic class containing the IGD, IGD+, GD, GD+, and AHD indicators values. |
Source code in desdeo/tools/indicators_unary.py
distance_indicators_batch
distance_indicators_batch(
solution_sets: dict[str, ndarray],
reference_set: ndarray,
p: float = 2.0,
) -> dict[str, DistanceIndicators]
Calculate the IGD, GD, GD_P, IGD_P, and AHD for a sets of solutions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution_sets
|
dict[str, ndarray]
|
A dict of strings mapped to 2D numpy arrays where each array contains a set of solutions. Each row is a solution and each column is an objective value. The solutions are assumed to be normalized within the unit hypercube. The ideal and nadir of the set itself can lie within the hypercube, but not outside it. The solutions are assumed to be non-dominated within their respective sets. The sets must have the same number of objectives/columns but can have different number of solutions/rows. The keys of the dict are the names of the sets. |
required |
reference_set
|
ndarray
|
A 2D numpy array where each row is a solution and each column is an objective value. The solutions are assumed to be normalized within the unit hypercube. The ideal and nadir of the reference set should probably be (0, 0, ..., 0) and (1, 1, ..., 1) respectively. The reference set is assumed to be non-dominated. |
required |
p
|
float
|
The power of the Minkowski metric. Set to 1 for Manhattan distance and 2 for Euclidean distance, and np.inf (or math.inf) for Chebyshev distance. Defaults to 2.0. |
2.0
|
Returns:
| Type | Description |
|---|---|
dict[str, DistanceIndicators]
|
dict[str, DistanceIndicators]: A dict of strings mapped to DistanceIndicators objects. The keys of the dict are the names of the sets. The DistanceIndicators objects contain the IGD, IGD+, GD, GD+, and AHD indicators values. This data structure can be easily converted to a DataFrame or saved to disk as a JSON file. |
Source code in desdeo/tools/indicators_unary.py
get_pareto_front
Extract the Pareto front from a set of solutions.
Source code in desdeo/tools/indicators_unary.py
hv
Calculate the hypervolume indicator for a set of solutions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution_set
|
ndarray
|
A 2D numpy array where each row is a solution and each column is an objective value. The solutions are assumed to be non-dominated. The solutions are assumed to be normalized within the unit hypercube. The ideal and nadir of the set itself can lie within the hypercube, but not outside it. |
required |
reference_point_component
|
float
|
The value of the reference point component. The reference point is assumed to be the same for all objectives. The reference point must be at least 1. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hypervolume indicator value. |
Source code in desdeo/tools/indicators_unary.py
hv_batch
hv_batch(
solution_sets: dict[str, ndarray],
reference_points_component: list[float],
) -> dict[str, list[float | None]]
Calculate the hypervolume indicator for a set of solutions over a range of reference points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution_sets
|
dict[str, ndarray]
|
A dict of strings mapped to 2D numpy arrays where each array contains a set of solutions. Each row is a solution and each column is an objective value. The solutions are assumed to be non-dominated within their respective sets. The solutions are assumed to be normalized within the unit hypercube. The ideal and nadir of the set itself can lie within the hypercube, but not outside it. The sets must have the same number of objectives/columns but can have different number of solutions/rows. The keys of the dict are the names of the sets. |
required |
reference_points_component
|
list[float]
|
A list of the value of the reference point component. The hypervolume is calculated for each set of solutions for each reference point component. The reference point is assumed to be the same for all objectives. The reference point must be at least 1. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, list[float | None]]
|
dict[str, list[float | None]]: A dict of strings mapped to lists of hypervolume indicator values. The keys of the dict are the names of the sets. The lists contain the hypervolume indicator values for each reference point component. If the calculation fails, the value is set to None, and should be handled by the user. |
Source code in desdeo/tools/indicators_unary.py
igd_plus_batch
igd_plus_batch(
solution_sets: dict[str, ndarray],
reference_set: ndarray,
p: float = 2.0,
) -> dict[str, IGDPlusIndicators]
Computes the IGD+ indicator for multiple solution sets.
Notes
The minimization of the objective function values is assumed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution_sets
|
dict[str, ndarray]
|
A dictionary of solution sets. |
required |
reference_set
|
ndarray
|
The reference Pareto front. |
required |
p
|
float
|
The power of the Minkowski metric. Defaults to 2.0 (Euclidean distance). |
2.0
|
Returns:
| Type | Description |
|---|---|
dict[str, IGDPlusIndicators]
|
dict[str, IGDPlusIndicators]: A dictionary of IGDPlusIndicators. |
Source code in desdeo/tools/indicators_unary.py
igd_plus_indicator
igd_plus_indicator(
solution_set: ndarray,
reference_set: ndarray,
p: float = 2.0,
) -> IGDPlusIndicators
Computes the IGD+ indicator for a given solution set.
Notes
The minimization of the objective function values is assumed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution_set
|
ndarray
|
The solution set being evaluated. |
required |
reference_set
|
ndarray
|
The reference Pareto front. |
required |
p
|
float
|
The power of the Minkowski metric. Defaults to 2.0 (Euclidean distance). |
2.0
|
Returns:
| Name | Type | Description |
|---|---|---|
IGDPlusIndicators |
IGDPlusIndicators
|
A Pydantic class containing the IGD+ indicator value. |
Source code in desdeo/tools/indicators_unary.py
is_dominated
Check if a solution is dominated by any other solution.
r2_batch
r2_batch(
solution_sets: dict[str, ndarray],
lambda_set: ndarray,
z_star: ndarray,
rho: float = 0.05,
) -> dict[str, R2Indicator]
Computes the R2 indicator for multiple solution sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution_sets
|
dict[str, ndarray]
|
Dictionary of solution sets. |
required |
lambda_set
|
ndarray
|
Set of weight vectors. |
required |
z_star
|
ndarray
|
Ideal point. |
required |
rho
|
float
|
Augmented Tchebycheff parameter. |
0.05
|
Returns:
| Type | Description |
|---|---|
dict[str, R2Indicator]
|
dict[str, R2IndicatorResult]: Dictionary of results. |
Source code in desdeo/tools/indicators_unary.py
r2_indicator
r2_indicator(
solution_set: ndarray,
lambda_set: ndarray,
z_star: ndarray,
rho: float = 0.05,
) -> R2Indicator
Computes the unary R2 indicator for a given solution set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution_set
|
ndarray
|
The Pareto front approximation. |
required |
lambda_set
|
ndarray
|
The set of normalized weight vectors (λ). |
required |
z_star
|
ndarray
|
The ideal point (must dominate or weakly dominate all solutions). |
required |
rho
|
float
|
Small positive number for augmented Tchebycheff. Default is 0.05. |
0.05
|
Returns:
| Name | Type | Description |
|---|---|---|
R2IndicatorResult |
R2Indicator
|
Pydantic class with R2 value. |
Source code in desdeo/tools/indicators_unary.py
r_metric_indicator
r_metric_indicator(
solution_set: ndarray,
ref_points: ndarray,
w: ndarray = None,
delta: float = 0.2,
) -> RMetricIndicators
Calculate the R-metric (either R-HV or R-IGD) for a given solution set.
solution_set : np.ndarray The set of solutions.
np.ndarray
A set of reference points..
np.ndarray, optional
Weights for each objective.
float, optional
Region of interest for the metric calculation.
RMetricIndicators An object containing the computed R-HV and R-IGD values.
Source code in desdeo/tools/indicators_unary.py
r_metric_indicators_batch
r_metric_indicators_batch(
solution_set: dict[str, ndarray],
ref_points: ndarray,
w: ndarray = None,
delta: float = 0.2,
) -> dict[str, RMetricIndicators]
Calculate the R-metrics (R-HV and R-IGD) for a batch of solution sets.
Source code in desdeo/tools/indicators_unary.py
tchebycheff_utility
Calculates the augmented Tchebycheff utility of a solution.
Source code in desdeo/tools/indicators_unary.py
Binary indicators
This module implements unary indicators that can be used to compare two solution sets.
It assumes that the solution set has been normalized just that some ideal point (not necessarily the ideal point of the set) is the origin and some nadir point (not necessarily the nadir point of the set) is (1, 1, ..., 1). The normalized solution set is assumed to be inside the bounding box [0, 1]^k where k is the number of objectives. If these conditions are not met, the results of the indicators will not be meaningful.
Additionally, the set may be assumed to only contain mutually non-dominated solutions, depending on the indicator.
For now, we rely on pymoo for the implementation of many of the indicators.
epsilon_component
Computes the additive epsilon-indicator between two solutions.
Basically, returns the minimum amount by which the values in solution1 must be translated (minimization assumed) such that it (weakly) dominates solution2. If solution1 already dominates solution2, returns 0.0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution1
|
ndarray
|
Should be an one-dimensional array, where each value is normalized between [0, 1] |
required |
solution2
|
ndarray
|
Should be an one-dimensional array, where each value is normalized between [0, 1] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The maximum distance between the values in s1 and s2. |
Source code in desdeo/tools/indicators_binary.py
epsilon_indicator
epsilon_indicator(
set1: ndarray,
set2: ndarray,
kind: Literal[
"additive", "multiplicative"
] = "additive",
) -> float
Computes the additive epsilon-indicator between two solution sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
set1
|
ndarray
|
Should be a two-dimensional array, where each row is a solution normalized between [0, 1] |
required |
set2
|
ndarray
|
Should be a two-dimensional array, where each row is a solution normalized between [0, 1] |
required |
kind
|
Literal['additive', 'multiplicative']
|
The kind of epsilon-indicator to compute. Defaults to "additive". |
'additive'
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
the epsilon-indicator between the two sets. |
Source code in desdeo/tools/indicators_binary.py
hv_component
Computes the hypervolume contribution of solution1 with respect to solution2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution1
|
ndarray
|
Should be an one-dimensional array, where each value is normalized between [0, 1] |
required |
solution2
|
ndarray
|
Should be an one-dimensional array, where each value is normalized between [0, 1] |
required |
ref
|
float
|
The reference point for the hypervolume calculation. Defaults to 2.0. |
2.0
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The hypervolume contribution of solution1 with respect to solution2. |
Source code in desdeo/tools/indicators_binary.py
self_epsilon
Computes the pairwise additive epsilon-indicator for a solution set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution_set
|
ndarray
|
Should be a two-dimensional array, where each row is a solution normalized between [0, 1]. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: A two-dimensional array where the entry at (i, j) is the additive epsilon-indicator between the i-th and j-th solution in the set. |
Source code in desdeo/tools/indicators_binary.py
self_hv
Computes the pairwise hypervolume contribution for a solution set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution_set
|
ndarray
|
Should be a two-dimensional array, where each row is a solution normalized between [0, 1]. |
required |
ref
|
float
|
The reference point for the hypervolume calculation. Defaults to 2.0. |
2.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: A two-dimensional array where the entry at (i, j) is the hypervolume contribution of the i-th solution with respect to the j-th solution in the set. |
Source code in desdeo/tools/indicators_binary.py
Reference vectors
Reference vector generation for decomposition-based evolutionary methods.
add_edge_vectors
Add edge (axis-aligned) vectors to the set of reference vectors.
This ensures that each axis direction is represented in the set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
ndarray
|
Array of reference vectors. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Array of reference vectors with edge vectors added and normalized. |
Source code in desdeo/tools/reference_vectors.py
approx_lattice_resolution
Approximate the lattice resolution based on the number of vectors and dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number_of_vectors
|
int
|
Desired number of reference vectors. |
required |
num_dims
|
int
|
Number of objectives (dimensions). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The smallest lattice resolution that produces more than the desired number of vectors. |
Source code in desdeo/tools/reference_vectors.py
create_simplex
create_simplex(
number_of_objectives: int,
lattice_resolution: int | None = None,
number_of_vectors: int | None = None,
) -> np.ndarray
Create reference vectors using the simplex lattice design.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number_of_objectives
|
int
|
Number of objectives (dimensions). |
required |
lattice_resolution
|
int
|
Lattice resolution to use. If None, will be determined from number_of_vectors. |
None
|
number_of_vectors
|
int
|
Desired number of reference vectors. Used if lattice_resolution is None. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Array of normalized reference vectors. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both lattice_resolution and number_of_vectors are None. |
Source code in desdeo/tools/reference_vectors.py
householder
Return reflection matrix via householder transformation.
Source code in desdeo/tools/reference_vectors.py
neighbouring_angles
Calculate the angles to the nearest neighbor for each reference vector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
ndarray
|
Array of normalized reference vectors. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Array of angles (in radians) to the nearest neighbor for each vector. |
Source code in desdeo/tools/reference_vectors.py
normalize
Normalize a set of vectors to unit length (project onto the unit hypersphere).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
ndarray
|
Array of vectors to normalize. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Normalized vectors. |
Source code in desdeo/tools/reference_vectors.py
rotate
Calculate the rotation matrix that rotates the initial_vector to the rotated_vector.
Apply that rotation on other_vectors and return. Uses Householder reflections twice to achieve this.
Source code in desdeo/tools/reference_vectors.py
rotate_toward
Rotate other_vectors (with the centre at initial_vector) towards final_vector by an angle degrees.
Parameters
initial_vector : np.ndarray Centre of the vectors to be rotated. final_vector : np.ndarray The final position of the center of other_vectors. other_vectors : np.ndarray The array of vectors to be rotated degrees : float, optional The amount of rotation (the default is 5)
Returns:
rotated_vectors : np.ndarray The rotated vectors reached: bool True if final_vector has been reached
Source code in desdeo/tools/reference_vectors.py
shear
Shear a set of vectors lying on the plane z=0 towards the z-axis.
The resulting vectors are'degrees' angle away from the z axis.
Parameters
vectors : numpy.ndarray The final element of each vector should be zero. degrees : float, optional The angle that the resultant vectors make with the z axis. Unit is radians. (the default is 5)
Source code in desdeo/tools/reference_vectors.py
Reference point generation
Generate reference points for the IPA algorithm.
generate_points
Generate reference points for the IPA algorithm.
Creates a (large) number of reference points on a plane perpendicular to the largest space diagonal of the unit hypercube in the num_dims-dimensional space. First, the vertices of the unit hypercube are generated. Then, the vertices are projected onto the plane perpendicular to the largest space diagonal (vertex first parallel projection) and rotated such that the plane is perpendular to one of the axes, making all objective values zero. A convex hull is then constructed from the projected vertices, and a bounding box is constructed around the convex hull. Finally, points are generated uniformly within the bounding box until num_points points are generated inside the convex hull. Note that the number of dimensions must be at least 2. Also, the number of dimensions of the reference points is one less than the number of dimensions of the objective space. This is because the reference points are generated on the projected plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_points
|
int
|
The number of reference points to generate. |
required |
num_dims
|
int
|
The number of dimensions of the space in which the reference points are generated. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
np.ndarray: A (num_points) x (num_dims-1) array of reference points. |
Source code in desdeo/tools/generateReferencePoints.py
get_hull_equations
Get the equations of the hyperplanes defining the convex hull.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hull
|
ConvexHull
|
A convex hull. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: A (num_dims-1) x num_hyperplanes array of the coefficients of the hyperplanes defining the convex hull. |
ndarray
|
np.ndarray: A (num_hyperplanes) array of the constants of the hyperplanes defining the convex hull. |
Source code in desdeo/tools/generateReferencePoints.py
get_reference_hull
Get the convex hull of the valid reference points for IPA.
This algorithm generates the vertices of the unit hypercube in the (num_dims)-dimensional space. Then, the vertices are projected onto the plane perpendicular to the largest space diagonal (vertex first parallel projection) and rotated such that the plane is perpendular to one of the axes. Then, the points are are flattened to (num_dims-1)-dimensional space. A convex hull is then constructed from the projected vertices, and a bounding box is constructed around the convex hull.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_dims
|
int
|
The number of dimensions of the space in which the reference points are generated. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: A (2) x (num_dims-1) array of the bounding box. Reference points are guaranteed to be within this box. However, not all points within this box are valid reference points. |
ndarray
|
np.ndarray: A (num_dims-1) x (num_dims-1) array of the coefficients of the hyperplanes defining the convex hull of the bounds of the reference points. A point is a valid reference point if it lies within the convex hull. |
ndarray
|
np.ndarray: A (num_dims-1) array of the constants of the hyperplanes defining the convex hull. See above. |
ConvexHull
|
scipy.spatial.ConvexHull: The convex hull of the projected vertices/valid reference points. |
Source code in desdeo/tools/generateReferencePoints.py
householder
Return reflection matrix via householder transformation.
Source code in desdeo/tools/generateReferencePoints.py
normalize
Normalize a set of vectors.
The length of the returned vectors will be 1.
Parameters
vectors : np.ndarray Set of vectors of any length, except zero.
Source code in desdeo/tools/generateReferencePoints.py
numba_random_gen
Generates num_points random points within the convex hull defined by A and b.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_points
|
int
|
The number of points to generate. |
required |
bounding_box
|
ndarray
|
A (2) x (num_objs - 1) array defining the bounding box within which to generate points initially. |
required |
a
|
ndarray
|
A (num_hyperplanes) x (num_objs - 1) array of the coefficients of the hyperplanes defining the convex hull. Basically the first num_objs - 1 columns of hull.equations. |
required |
b
|
ndarray
|
A (num_hyperplanes) array of the constants of the hyperplanes defining the convex hull. Basically the last column of hull.equations. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: A (num_points) x (num_objs - 1) array of points within the convex hull defined by A and b. |
Source code in desdeo/tools/generateReferencePoints.py
rotate
Calculate the rotation matrix that rotates the initial_vector...
...to the rotated_vector. Apply that rotation on other_vectors and return. Uses Householder reflections twice to achieve this.
Source code in desdeo/tools/generateReferencePoints.py
rotate_in
Project the vertices to a lower dimensional space.
First, the vertices are rotated such that the plane perpendicular to the ideal-nadir line becomes perpendicular to one of the axes. Essentially, (1,1,...,1) is rotated to (0,0,...,0,1). Then, the last dimension is dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
ndarray
|
The vertices to be projected. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The projected vertices. |
Source code in desdeo/tools/generateReferencePoints.py
rotate_out
Undo the rotate_in operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
ndarray
|
The points to be projected back. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The projected points. |
Source code in desdeo/tools/generateReferencePoints.py
Non-dominated sorting
This module contains functions for non-dominated sorting of solutions.
dominates
Returns true if x dominates y.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
First solution. Should be a 1-D array of numerics. |
required |
y
|
ndarray
|
Second solution. Should be the same shape as x. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if x dominates y, false otherwise. |
Source code in desdeo/tools/non_dominated_sorting.py
fast_non_dominated_sort
Conduct fast non-dominated sorting on a population of solutions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
2-D array of solutions, with each row being a single solution. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: n x f boolean array. n is the number of solutions, f is the number of fronts. The value of an array element is true if the corresponding solution id (column) belongs in the corresponding front (row). |
Source code in desdeo/tools/non_dominated_sorting.py
fast_non_dominated_sort_indices
Conduct fast non-dominated sorting on a population of solutions.
This function returns identical results as fast_non_dominated_sort, but in a different format.
This function returns an array of solution indices for each front, packed in a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
2-D array of solutions, with each row being a single solution. |
required |
Returns:
| Type | Description |
|---|---|
list[list[int]]
|
list[list[int]]: A list with f elements where f is the number of fronts in the data, arranged in ascending order. Each element is a list of the indices of solutions belonging to the corresponding front. |
Source code in desdeo/tools/non_dominated_sorting.py
non_dominated
Finds the non-dominated front from a population of solutions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
2-D array of solutions, with each row being a single solution. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Boolean array of same length as number of solutions (rows). The value is true if corresponding solution is non-dominated. False otherwise |
Source code in desdeo/tools/non_dominated_sorting.py
non_dominated_merge
Merge two sets of non-dominated solutions.
This is a slightly more efficient way to merge two sets of solutions such that the resulting set only contains non-dominated solutions from the two sets. This function assumes that the two sets already only contain non-dominated solutions. I.e., each solution in each set is non-dominated with respect to all other solutions in the same set. However, the solutions in the two sets may not be non-dominated with respect to each other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
set1
|
ndarray
|
2-D array of solutions, with each row being a single solution. |
required |
set2
|
ndarray
|
2-D array of solutions, with each row being a single solution. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: A tuple of two mask arrays. The first mask array is for set1 and the second mask array is for set2. The value of an element in the mask array is True if the corresponding solution is non-dominated in the merged set. False otherwise. |
Source code in desdeo/tools/non_dominated_sorting.py
Iterative Pareto representer
Implements the Iterative Pareto Representer algorithm.
_DSS_with_pruning
One-liner implementation of the DSS algorithm using scipy.
Source code in desdeo/tools/iterative_pareto_representer.py
_find_bad_RPs
_find_bad_RPs(
reference_points_array: ndarray,
eval_results: list[_EvaluatedPoint],
thickness: float = 0.02,
) -> np.ndarray
Find the reference points that will lead to repeated evaluations according to the ASF pruning rule.
Source code in desdeo/tools/iterative_pareto_representer.py
_project
Project the solution to the reference plane defined by the reference_point and the normal vector.
Source code in desdeo/tools/iterative_pareto_representer.py
choose_reference_point
choose_reference_point(
refp_array: ndarray,
evaluated_points: list[_EvaluatedPoint] | None = None,
)
Choose the next reference point to evaluate using the Iterative Pareto Representer algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
refp_array
|
ndarray
|
The reference points to choose from. |
required |
evaluated_points
|
list[_EvaluatedPoint]
|
Already evaluated reference points and their targets. If None, a random reference point is chosen. |
None
|
Source code in desdeo/tools/iterative_pareto_representer.py
Intersection
Utility methods to check if reference vectors intersect a bounding box.
find_bad_indicesREF
Return reference points flagged as bad via line-box intersection, with the box limits.
Source code in desdeo/tools/intersection.py
find_bad_limits
Return the (max, min) box corners used to flag bad reference points around a solution.
Source code in desdeo/tools/intersection.py
line_box_intersection
line_box_intersection(
box_min: ndarray,
box_max: ndarray,
reference_points: ndarray,
thickness,
) -> np.ndarray
Find the reference directions that intersect the box defined by box_min and box_max.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box_min
|
ndarray
|
The infimum of the box. |
required |
box_max
|
ndarray
|
The supremum of the box. |
required |
reference_points
|
ndarray
|
The reference directions. |
required |
thickness
|
float
|
The threshold for thickness. Defines the thickness of the box. The thickness is added to the box_min and subtracted from the box_max to define the box. The reference directions that intersect the box are marked as bad. The thickness is a hyperparameter that needs to be tuned. The default value is 0.05. Try out some values close to 0.05. Lower values will result in lesser number of reference points being marked as bad. Note that a value of zero does not imply that only reference directions that directly intersect the box are marked as bad. Floating point shenanigans (np.isclose) happen. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: A boolean array of length num_points, where True indicates that the reference direction intersects the box. |
Source code in desdeo/tools/intersection.py
Interaction schema
The schema to represent the interactions of the user.
Interaction
Bases: BaseModel
The tree-like structure to represent the interactions of the user.
Source code in desdeo/tools/interaction_schema.py
Visualizations
Provides some visualization functions.
scatter_plot_comparison
scatter_plot_comparison(
*results: Any,
x_key: str = "f_1",
y_key: str = "f_2",
z_key: str | None = None,
reference_point: dict[str, float] | None = None,
names: list[str] | None = None,
) -> go.Figure
Plots multiple sets of data in a scatter plot (2D or 3D depending on the data).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*results
|
Any
|
Variable number of result objects, each containing outputs with keys for x, y, and optionally z. |
()
|
x_key
|
str
|
Key for the x-axis data in the outputs. |
'f_1'
|
y_key
|
str
|
Key for the y-axis data in the outputs. |
'f_2'
|
z_key
|
str | None
|
Key for the z-axis data in the outputs (optional, for 3D plots). |
None
|
reference_point
|
dict[str, float] | None
|
A dictionary with keys matching x_key, y_key, and optionally z_key, representing the reference point to plot. |
None
|
names
|
list[str] | None
|
List of names for each data set to display in the legend. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
go.Figure: A Plotly Figure containing the scatter plot. |
Source code in desdeo/tools/visualizations.py
Publisher-Subscriber pattern
This module contains the classes for the publisher-subscriber (ish) pattern.
The pattern is used in the evolutionary algorithms to send messages between the different components. This allows the components to be decoupled and the messages to be sent between them without the components knowing about each other. The pattern closely resembles the publisher-subscriber pattern, with one key difference. The subscribers can also create messages and send them to the publisher, which then forwards the messages to the other subscribers.
The pattern is implemented with two classes: Subscriber and Publisher. The Subscriber class is an abstract
class that must be inherited by the classes that want to receive (or send) messages. All evolutionary operators
must inherit the Subscriber class. Some objects that may be interested in the messages, but otherwise unrelated
to the evolutionary operators, may also inherit the Subscriber class. Examples of such objects are a logging class,
an archive class, or a class that visualizes intermediate results.
The Publisher class is a class that stores the subscribers and forwards the messages to them. The Publisher class
is not connected to the evolutionary algorithms and only serves as a message router. As mentioned earlier, the
components do not know about each other, and the Publisher class is the only class that knows about all the
connections in between components. The user of the evolutionary algorithms is responsible for creating the connections.
However, the implementations of the operators do provide default, so called topics that the operator must subscribe to.
The way the pattern works is as follows. Each operator has a do method which is called by the evolutionary algorithm
when the operator is to be executed. This method has some default arguments, depending upon the class of the operator.
E.g., the do method of the mutation related classes may have a default arguments as offsprings and parents, where
each is a tuple of decision variables, objectives, and constraints. However, some special mutation operator may require
additional inputs. E.g., an adaptive mutation operator may require the current generation number as an input. To provide
this additional input, we do not change the signature of the do method.
Instead, we let the mutation operator subscribe to a topic called, e.g., current_generation. The publisher, is then
responsible for sending the current generation number to the mutation operator, whenever the generation number changes.
The mutation operator can then update its internal state based on the received generation number.
To be able to send this information, the Publisher class has a method called notify. Operators can call this method
to send messages to the subscribers. The idea is to do this at the end of the do method. That way, whenever any
operator is executed, it can send messages to the other operators (which have subscribed to the topics).
Note that the operators do not know about the other operators. The subscribers do not know the origin of the messages. This decoupling allows for a more modular design and easier extensibility of the evolutionary algorithms.
Publisher
Class for a publisher that sends messages to subscribers.
The publisher is unconnected from the evolutionary algorithms and only serves as a message router. The subscribers can subscribe to different message keys and receive messages when the publisher receives a message with the corresponding key.
Source code in desdeo/tools/patterns.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
__init__
Initialize a blank publisher.
auto_subscribe
Store a subscriber for multiple message keys. The subscriber must have the topics attribute.
Whenever the publisher receives a message with the given key, it will notify the subscriber.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subscriber
|
Subscriber
|
the subscriber to notify. |
required |
Source code in desdeo/tools/patterns.py
check_consistency
Check if all subscribed topics have also been registered by a source.
Returns:
| Type | Description |
|---|---|
tuple[bool, dict[MessageTopics, list[str]]]
|
tuple[bool, dict[MessageTopics, list[str]]]: Returns a tuple. The first element is a bool. True if all subscribed topics have been registered by a source. False otherwise. The second element is a dictionary of unregistered topics that have been subscribed to. |
Source code in desdeo/tools/patterns.py
force_unsubscribe
Remove a subscriber from all message keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subscriber
|
Subscriber
|
the subscriber to remove. |
required |
Source code in desdeo/tools/patterns.py
notify
Notify subscribers of the received message/messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
Sequence[BaseMessage]
|
the messages to send to the subscribers. Each message is a pydantic model with a topic, value, and a source. |
required |
Source code in desdeo/tools/patterns.py
register_topics
Register topics provided to the publisher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topics
|
list[MessageTopics]
|
the topics to register. |
required |
source
|
str
|
the source of the topics. |
required |
Source code in desdeo/tools/patterns.py
relationship_map
Make a diagram connecting sources to subscribers based on topics.
Source code in desdeo/tools/patterns.py
subscribe
Store a subscriber for a given message key.
Whenever the publisher receives a message with the given key, it will notify the subscriber. This method can be used to subscribe to multiple topics by calling it multiple times. Moreover, the user can force the subscriber to receive all messages by setting the topic to "ALL".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subscriber
|
Subscriber
|
the subscriber to notify. |
required |
topic
|
str
|
the message topic (key in message dictionary) to subscribe to. If "ALL", the subscriber is notified of all messages. |
required |
Source code in desdeo/tools/patterns.py
unsubscribe
Remove a subscriber from a given message key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subscriber
|
Subscriber
|
the subscriber to remove. |
required |
topic
|
str
|
the key of the message to unsubscribe from. |
required |
Source code in desdeo/tools/patterns.py
unsubscribe_multiple
unsubscribe_multiple(
subscriber: Subscriber,
topics: Sequence[MessageTopics | Literal["ALL"]],
) -> None
Remove a subscriber from multiple message keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subscriber
|
Subscriber
|
the subscriber to remove. |
required |
topics
|
list[str]
|
the keys of the messages to unsubscribe from. |
required |
Source code in desdeo/tools/patterns.py
Subscriber
Bases: ABC
Base class for both subscriber and message sender.
These are used in the evolutionary algorithms to send messages between the different components. The pattern closely resembles the publisher-subscriber pattern, with one key difference. The subscribers can also create messages and send them to the publisher, which then forwards the messages to the other subscribers.
Source code in desdeo/tools/patterns.py
interested_topics
abstractmethod
property
Return the topics the subscriber is interested in.
provided_topics
abstractmethod
property
Return the topics the subscriber provides to the publisher, grouped by verbosity level.
__init__
Initialize a subscriber.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
publisher
|
Callable
|
the publisher to send messages to. |
required |
verbosity
|
int
|
the verbosity level of the messages. A value of 0 means no messages at all. |
required |
Source code in desdeo/tools/patterns.py
notify
Notify the publisher of changes in the subject.
The contents of the message (a dictionary) are defined in the state method. The state method can return
different messages depending on the verbosity level.
Source code in desdeo/tools/patterns.py
state
abstractmethod
update
abstractmethod
Update self as a result of messages from the publisher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
Message
|
the message from the publisher. Note that each message is a pydantic model with a topic, value, and a source. |
required |
Source code in desdeo/tools/patterns.py
createblanksubs
Create a blank subscriber for testing purposes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
interested_topics
|
list[MessageTopics]
|
the topics the subscriber is interested in. |
required |
Returns:
| Type | Description |
|---|---|
type[Subscriber]
|
type[Subscriber]: the blank subscriber class. |
Source code in desdeo/tools/patterns.py
Message Topics
Defines the messaging protocol used by the various EMO operators.
Array2DMessage
Bases: BaseMessage
A message containing a 2D array value, such as a population or a set of objectives.
Source code in desdeo/tools/message.py
BaseMessage
Bases: BaseModel
A message containing an integer value.
Source code in desdeo/tools/message.py
BoolMessage
CrossoverMessageTopics
Bases: Enum
Topics for messages related to crossover operators.
Source code in desdeo/tools/message.py
LAMBDA
class-attribute
instance-attribute
Lambda parameter used in crossover. Primarily used in the bounded exponential xover.
OFFSPRINGS
class-attribute
instance-attribute
The offsprings generated from the crossover.
TEST
class-attribute
instance-attribute
A message topic used only for testing the crossover operators.
XOVER_DISTRIBUTION
class-attribute
instance-attribute
The current crossover distribution index. Primary used in the SBX crossover.
DictMessage
EvaluatorMessageTopics
Bases: Enum
Topics for messages related to evaluator operators.
Source code in desdeo/tools/message.py
CONSTRAINTS
class-attribute
instance-attribute
The constraints of the population.
NEW_EVALUATIONS
class-attribute
instance-attribute
The number of new evaluations.
OBJECTIVES
class-attribute
instance-attribute
The true objective values of the population.
OUTPUTS
class-attribute
instance-attribute
The outputs of the population. Contains objectives, targets, constraints.
TARGETS
class-attribute
instance-attribute
The targets, i.e., objective values seen by the evolutionary operators.
TEST
class-attribute
instance-attribute
A message topic used only for testing the evaluator operators.
FloatMessage
GeneratorMessageTopics
Bases: Enum
Topics for messages related to population generator operators.
Source code in desdeo/tools/message.py
CONSTRAINTS
class-attribute
instance-attribute
The constraints of the population.
NEW_EVALUATIONS
class-attribute
instance-attribute
The number of new evaluations.
OBJECTIVES
class-attribute
instance-attribute
The true objective values of the population.
OUTPUTS
class-attribute
instance-attribute
The outputs of the population generation. Contains objectives, targets, and constraints.
TARGETS
class-attribute
instance-attribute
The targets, i.e., objective values seen by the evolutionary operators.
TEST
class-attribute
instance-attribute
A message topic used only for testing the evaluator operators.
GenericMessage
IntMessage
MutationMessageTopics
Bases: Enum
Topics for messages related to mutation operators.
Source code in desdeo/tools/message.py
MUTATION_DISTRIBUTION
class-attribute
instance-attribute
The current mutation distribution index. Primary used in the polynomial mutation.
MUTATION_PROBABILITY
class-attribute
instance-attribute
The current mutation probability.
OFFSPRINGS
class-attribute
instance-attribute
The offsprings after mutation.
OFFSPRING_ORIGINAL
class-attribute
instance-attribute
The original offsprings before mutation.
NumpyArrayMessage
Bases: BaseMessage
A message containing a numpy array value.
Source code in desdeo/tools/message.py
PolarsDataFrameMessage
Bases: BaseMessage
A message containing a 2D array value, such as a population or a set of objectives.
Source code in desdeo/tools/message.py
ReferenceVectorMessageTopics
SelectorMessageTopics
Bases: Enum
Topics for messages related to selector operators.
Source code in desdeo/tools/message.py
CONSTRAINTS
class-attribute
instance-attribute
The constraints of the individuals.
INDIVIDUALS
class-attribute
instance-attribute
The individuals to select from.
REFERENCE_VECTORS
class-attribute
instance-attribute
The reference vectors used in the selection in decomposition-based EMO algorithms.
SELECTED_FITNESS
class-attribute
instance-attribute
The fitness of the selected individuals. This is the fitness calculated by the selector, not the objectives.
SELECTED_INDIVIDUALS
class-attribute
instance-attribute
The individuals selected by the selector.
SELECTED_OUTPUTS
class-attribute
instance-attribute
The targets of the selected individuals.
SELECTED_VERBOSE_OUTPUTS
class-attribute
instance-attribute
Same as SELECTED_OUTPUTS + SELECTED_INDIVIDUALS
STATE
class-attribute
instance-attribute
The state of the parameters of the selector.
StringMessage
TerminatorMessageTopics
Bases: Enum
Topics for messages related to terminator operators.
Source code in desdeo/tools/message.py
EVALUATION
class-attribute
instance-attribute
The current number of evaluations.
GENERATION
class-attribute
instance-attribute
The current generation number.
MAX_EVALUATIONS
class-attribute
instance-attribute
The maximum number of evaluations.
MAX_GENERATIONS
class-attribute
instance-attribute
The maximum number of generations.
STATE
class-attribute
instance-attribute
The state of the parameters of the terminator.
TERMINATION
class-attribute
instance-attribute
The value of the termination condition.
Description generator
An utility function to generate descriptions related to UTOPIA matters.
generate_descriptions
Generate human-readable stand descriptions for UTOPIA forest map features.
Source code in desdeo/tools/desc_gen.py
Utilities
General utilities related to solvers.
find_compatible_solvers
Find solvers that are compatible with the problem that is being solved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
The problem being solved. |
required |
Returns:
| Type | Description |
|---|---|
list[BaseSolver]
|
list[BaseSolver]: A list of solvers that are compatible with the problem. |
Source code in desdeo/tools/utils.py
flip_maximized_objective_values
flip_maximized_objective_values(
problem: Problem, objective_values: dict[str, float]
) -> dict[str, float]
Flips the objective values if the objective function is to be maximized.
Flips the objective values if the objective function is to be maximized by multiplying the values related to maximized objective functions by -1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the objective values are related to. |
required |
objective_values
|
dict[str, float]
|
the objective values to be flipped. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
dict[str, float]: the flipped objective values. |
Source code in desdeo/tools/utils.py
get_corrected_ideal
Compute the corrected ideal point depending if an objective function is to be maximized or not.
I.e., the ideal point element for objectives to be maximized will be multiplied by -1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem with the ideal point. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
some of the ideal point components have not been defined for some of the objectives. |
Returns:
| Type | Description |
|---|---|
dict[str, float | None]
|
list[float]: a list with the corrected ideal point. Will return None for missing elements. |
Source code in desdeo/tools/utils.py
get_corrected_ideal_and_nadir
get_corrected_ideal_and_nadir(
problem: Problem,
) -> tuple[
dict[str, float | None], dict[str, float | None] | None
]
Compute the corrected ideal and nadir points depending if an objective function is to be maximized or not.
I.e., the ideal and nadir point element for objectives to be maximized will be multiplied by -1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem with the ideal and nadir points. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
some of the ideal or nadir point components have not been defined for some of the objectives. |
Returns:
| Type | Description |
|---|---|
tuple[dict[str, float | None], dict[str, float | None] | None]
|
tuple[list[float], list[float]]: a list with the corrected ideal point and a list with the corrected nadir point. Will return None for missing elements. |
Source code in desdeo/tools/utils.py
get_corrected_nadir
Compute the corrected nadir point depending if an objective function is to be maximized or not.
I.e., the nadir point element for objectives to be maximized will be multiplied by -1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem with the nadir points. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
some of the nadir point components have not been defined for some of the objectives. |
Returns:
| Type | Description |
|---|---|
dict[str, float | None]
|
list[float]: a list with the corrected nadir point. Will return None for missing elements. |
Source code in desdeo/tools/utils.py
guess_best_solver
Given a problem, tries to guess the best solver to handle it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem being solved. |
required |
Note
Needs to be extended as new solvers are implemented.
Returns:
| Name | Type | Description |
|---|---|---|
BaseSolver |
BaseSolver
|
a solver class that uses BaseSolver as a base class |
Source code in desdeo/tools/utils.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
payoff_table_method
payoff_table_method(
problem: Problem, solver: BaseSolver = None
) -> tuple[dict[str, float], dict[str, float]]
Solves a representation for the ideal and nadir points for a multiobjective optimization problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
The problem for which the ideal and nadir are solved. |
required |
solver
|
BaseSolver
|
The solver to be used in solving the points. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[dict[str, float], dict[str, float]]
|
tuple[dict[str, float], dict[str, float]]: The estimated ideal and nadir points. |
Source code in desdeo/tools/utils.py
repair
repair(
lower_bounds: dict[str, float],
upper_bounds: dict[str, float],
) -> Callable[[pl.DataFrame], pl.DataFrame]
Repairs the offspring by clipping the values to be within the specified bounds.
Useful in evolutionary algorithms where offspring may go out of bounds due to crossover or mutation operations. This also fills any NaN values with the mean of the lower and upper bounds for that variable. Certain operators are known to produce NaN values, e.g., the Bounded Exponential Crossover operator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lower_bounds
|
dict[str, float]
|
The lower bounds for each variable. |
required |
upper_bounds
|
dict[str, float]
|
The upper bounds for each variable. |
required |
Returns:
| Type | Description |
|---|---|
Callable[[DataFrame], DataFrame]
|
Callable[[pl.DataFrame], pl.DataFrame]: A function that takes a DataFrame and returns a repaired DataFrame. |
Source code in desdeo/tools/utils.py
Generics
Defines generic classes, functions, and objects utilized in the tools module.
BaseSolver
Bases: ABC
Defines a schema for a solver base class.
Source code in desdeo/tools/generics.py
__init__
Initializer for the persistent solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
The problem for the solver. |
required |
options
|
dict[str, any]
|
Dictionary of parameters to set. What these should be depends on the solver used. |
None
|
Source code in desdeo/tools/generics.py
solve
abstractmethod
Solves the current problem with the specified target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
a str representing the symbol of the target function. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults
|
The results of the solver |
Source code in desdeo/tools/generics.py
EMOResult
Bases: BaseModel
Defines a schema for a dataclass to store the results of an EMO method.
Source code in desdeo/tools/generics.py
optimal_outputs
class-attribute
instance-attribute
The objective vectors, constraint vectors, extra_funcs, and targets of the final population.
PersistentSolver
Defines a schema for a persistent solver class.
Can be used when reinitializing the solver every time the problem is changed is not practical.
Source code in desdeo/tools/generics.py
__init__
Initializer for the persistent solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
The problem for the solver. |
required |
options
|
dict[str, any]
|
Dictionary of parameters to set. What these should be depends on the solver used. |
None
|
Source code in desdeo/tools/generics.py
add_constraint
Add a constraint expression to the solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
constraint
|
Constraint
|
the constraint function expression. |
required |
add_objective
Adds an objective function expression to the solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objective
|
Objective
|
an objective function expression to be added. |
required |
add_scalarization_function
Adds a scalrization expression to the solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scalarization
|
ScalarizationFunction
|
A scalarization function to be added. |
required |
add_variable
Add a variable to the solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
Variable
|
The definition of the variable to be added. |
required |
remove_constraint
Removes a constraint from the solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
a str representing the symbol of the constraint to be removed. |
required |
remove_variable
Removes a variable from the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
a str representing the symbol of the variable to be removed. |
required |
solve
Solves the current problem with the specified target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
a str representing the symbol of the target function. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolverResults |
SolverResults | None
|
The results of the solver |
Source code in desdeo/tools/generics.py
SolverError
SolverResults
Bases: BaseModel
Defines a schema for a dataclass to store the results of a solver.
Source code in desdeo/tools/generics.py
SCORE Bands
Use the auto_SCORE function to generate the SCORE bands visualization.
This module contains the functions which generate SCORE bands visualizations. It also contains functions to calculate the order and positions of the objective axes, as well as a heatmap of correlation matrix.
To run the SCORE bands visualization, use the score_json function to generate the data for the visualization, and then
use the plot_score function to generate the figure. You can also pass the result of score_json to other frontends
for visualization.
CustomClusterOptions
Bases: BaseModel
Options for custom clustering provided by the user.
Source code in desdeo/tools/score_bands.py
DBSCANOptions
Bases: BaseModel
Options for DBSCAN clustering algorithm.
Source code in desdeo/tools/score_bands.py
DimensionClusterOptions
Bases: BaseModel
Options for clustering by one of the objectives/decision variables.
Source code in desdeo/tools/score_bands.py
kind
class-attribute
instance-attribute
Kind of clustering to use. Either "EqualWidth", which divides the dimension range into equal width intervals, or "EqualFrequency", which divides the dimension values into intervals with equal number of solutions. Defaults to "EqualWidth".
n_clusters
class-attribute
instance-attribute
Number of clusters to use. Defaults to 5.
DistanceFormula
GMMOptions
Bases: BaseModel
Options for Gaussian Mixture Model clustering algorithm.
Source code in desdeo/tools/score_bands.py
name
class-attribute
instance-attribute
Gaussian Mixture Model clustering algorithm.
KMeansOptions
Bases: BaseModel
Options for KMeans clustering algorithm.
Source code in desdeo/tools/score_bands.py
SCOREBandsConfig
Bases: BaseModel
Configuration options for SCORE bands visualization.
Source code in desdeo/tools/score_bands.py
axis_colours
class-attribute
instance-attribute
Optional dictionary to set the colour of the axes corresponding to each objective. The keys should be the same as in the 'dimensions' field. The values should be a valid plotly color string. Defaults to None.
Valid plotly color strings include
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color: see https://plotly.com/python/css-colors/ for a list
axis_positions
class-attribute
instance-attribute
Dictionary mapping objective names to their positions on the axes in the SCORE bands visualization. The first objective is at position 0.0, and the last objective is at position 1.0. Use this option if you want to manually set the axis positions. If None, the axis positions are calculated automatically based on correlations. Defaults to None.
clustering_algorithm
class-attribute
instance-attribute
Clustering algorithm to use. Currently supports one of ClusteringOptions.
descriptive_names
class-attribute
instance-attribute
Optional dictionary mapping dimensions to descriptive names for display in the visualization. If None, the original dimension names are used. Defaults to None.
dimensions
class-attribute
instance-attribute
List of variable/objective names (i.e., column names in the data) to include in the visualization. If None, all columns in the data are used. Defaults to None.
distance_formula
class-attribute
instance-attribute
Distance formula to use. The value should be 1 or 2. Check the paper for details. Defaults to 1.
distance_parameter
class-attribute
instance-attribute
Change the relative distances between the objective axes. Increase this value if objectives are placed too close together. Decrease this value if the objectives are equidistant in a problem with objective clusters. Defaults to 0.05.
highlight_cluster
class-attribute
instance-attribute
Cluster ID to highlight in the visualization. If None, no cluster is highlighted. Defaults to None. If a cluster ID is provided, the corresponding cluster is highlighted in the visualization by having a pattern fill in the band.
include_medians
class-attribute
instance-attribute
Whether to include cluster medians. Defaults to False. If True, the median traces are hidden by default, but can be viewed interactively in the figure.
include_solutions
class-attribute
instance-attribute
Whether to include individual solutions. Defaults to False. If True, the size of the resulting figure may be very large for datasets with many solutions. Moreover, the individual traces are hidden by default, but can be viewed interactively in the figure.
interval_size
class-attribute
instance-attribute
The size (as a fraction) of the interval to use for the bands. Defaults to 0.95, meaning that 95% of the middle solutions in a cluster will be included in the band. The rest will be considered outliers.
scales
class-attribute
instance-attribute
Optional dictionary specifying the min and max values for each objective. The keys should be the objective names (i.e., column names in the data), and the values should be tuples of (min, max). If not provided, the min and max will be calculated from the data.
units
class-attribute
instance-attribute
Optional dictionary mapping dimensions to their units for display in the visualization. If None, no units are displayed. Defaults to None.
SCOREBandsResult
Bases: BaseModel
Pydantic/JSON model for representing SCORE Bands.
Source code in desdeo/tools/score_bands.py
axis_positions
instance-attribute
Dictionary mapping objective names to their positions on the axes in the SCORE bands visualization. The first objective is at position 0.0, and the last objective is at position 1.0.
bands
instance-attribute
Dictionary mapping cluster IDs to dictionaries of objective names and their corresponding band extremes (min, max).
cardinalities
instance-attribute
Dictionary mapping cluster IDs to the number of solutions in each cluster.
cluster_hover_info
class-attribute
instance-attribute
Optional dictionary mapping cluster IDs to hover information for display in the visualization. If None, no additional hover information is displayed. Defaults to None.
cluster_names
class-attribute
instance-attribute
Optional dictionary mapping cluster IDs to descriptive names for display in the visualization. If None, the cluster IDs themselves are used as names. Defaults to None.
clusters
instance-attribute
List of cluster IDs (one for each solution) indicating the cluster to which each solution belongs.
medians
instance-attribute
Dictionary mapping cluster IDs to dictionaries of objective names and their corresponding median values.
options
instance-attribute
Configuration options used to generate the SCORE bands.
_DBSCANClustering
Cluster the data using DBSCAN with silhouette scoring to choose eps.
Source code in desdeo/tools/score_bands.py
_gaussianmixtureclusteringwithBIC
Cluster the data using Gaussian Mixture Model with BIC scoring.
Source code in desdeo/tools/score_bands.py
_gaussianmixtureclusteringwithsilhouette
Cluster the data using Gaussian Mixture Model with silhouette scoring.
Source code in desdeo/tools/score_bands.py
annotated_heatmap
annotated_heatmap(
correlation_matrix: ndarray,
col_names: list,
order: list | ndarray,
) -> go.Figure
Create a heatmap of the correlation matrix. Probably should be named something else.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
correlation_matrix
|
ndarray
|
2-D square array of correlation values between pairs of objectives. |
required |
col_names
|
List
|
Objective names. |
required |
order
|
Union[List, ndarray]
|
Order in which the objectives are shown in SCORE bands. |
required |
Returns:
| Type | Description |
|---|---|
Figure
|
go.Figure: The heatmap |
Source code in desdeo/tools/score_bands.py
calculate_axes_positions
calculate_axes_positions(
dimension_order: list[int],
corr: ndarray,
dist_parameter: float,
distance_formula: DistanceFormula = DistanceFormula.FORMULA_1,
) -> np.ndarray
Calculate the position of the axes for the SCORE bands visualization based on correlations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension_order
|
list[int]
|
Order of the variables to be plotted. |
required |
corr
|
ndarray
|
Correlation (pearson) matrix. |
required |
dist_parameter
|
float
|
Change the relative distances between the axes. Increase this value if the axes are placed too close together. Decrease this value if the axes are equidistant. |
required |
distance_formula
|
DistanceFormula
|
The value should be 1 or 2. Check the paper for details. Defaults to DistanceFormula.FORMULA_1. |
FORMULA_1
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Positions of the axes in the range [0, 1]. |
Source code in desdeo/tools/score_bands.py
cluster
Cluster the data using the specified clustering algorithm and options.
Source code in desdeo/tools/score_bands.py
cluster_by_dimension
Cluster the data by a specific dimension.
Source code in desdeo/tools/score_bands.py
order_dimensions
order_dimensions(
data: DataFrame, use_absolute_corr: bool = False
) -> tuple[np.ndarray, list[int]]
Calculate the order of objectives.
Also returns the correlation matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Data to be visualized. |
required |
use_absolute_corr
|
bool
|
Use absolute value of the correlation to calculate order. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[ndarray, list[int]]
|
The first element is the correlation matrix. The second element is the order of the objectives. |
Source code in desdeo/tools/score_bands.py
plot_score
Generate the SCORE Bands figure from the SCOREBandsResult data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Dataframe of objective values. The column names should be the objective names. Each row should be an objective vector. |
required |
result
|
SCOREBandsResult
|
The result containing all relevant data for the SCORE bands visualization. |
required |
Returns:
| Type | Description |
|---|---|
Figure
|
go.Figure: The SCORE bands plot. |
Source code in desdeo/tools/score_bands.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 | |
score_json
Generate the SCORE Bands data for a given dataset and configuration options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Dataframe of variable (decision or objective) values. The column names should be the names of the variables to be plotted. Each row should be a solution. |
required |
options
|
SCOREBandsConfig
|
Configuration options for generating the SCORE bands. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SCOREBandsResult |
SCOREBandsResult
|
The result containing all relevant data for the SCORE bands visualization. |
Source code in desdeo/tools/score_bands.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | |
smart_axis_tick_placement
smart_axis_tick_placement(
axis_min: float,
axis_max: float,
num_ticks: int,
max_dist_percent: float,
) -> tuple[list[str], list[float]]
Calculate smart tick placement for the axes in the SCORE bands visualization.