problem
Test problems
desdeo.problem.testproblems
Pre-defined multiobjective optimization problems.
Pre-defined problems for, e.g., testing and illustration purposed are defined here.
best_cake_problem
Defines the best cake problem.
Source code in desdeo/problem/testproblems/cake_problem.py
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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
binh_and_korn
Create a pydantic dataclass representation of the Binh and Korn problem.
The function has two objective functions, two variables, and two constraint functions. For testing purposes, it can be chosen whether the firs and second objective should be maximized instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
maximize
|
tuple[bool]
|
whether the first or second objective should be maximized or not. Defaults to (False, False). |
(False, False)
|
References
Binh T. and Korn U. (1997) MOBES: A Multiobjective Evolution Strategy for Constrained Optimization Problems. In: Proceedings of the Third International Conference on Genetic Algorithms. Czech Republic. pp. 176-182.
Source code in desdeo/problem/testproblems/binh_and_korn_problem.py
dmitry_forest_problem_disc
Implements the dmitry forest problem using Pareto front representation.
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
A problem instance representing the forest problem. |
Source code in desdeo/problem/testproblems/dmitry_forest_problem_discrete.py
dtlz2
Defines the DTLZ2 test problem.
The objective functions for DTLZ2 are defined as follows, for \(i = 1\) to \(M\):
where
and \(\mathbf{x}_M\) represents the last \(n-k\) dimensions of the decision vector. Pareto optimal solutions to the DTLZ2 problem consist of \(x_i = 0.5\) for all \(x_i \in\mathbf{x}_{M}\), and \(\sum{i=1}^{M} f_i^2 = 1\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_variables
|
int
|
number of variables. |
required |
n_objectives
|
int
|
number of objective functions. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
an instance of the DTLZ2 problem with |
References
Deb, K., Thiele, L., Laumanns, M., Zitzler, E. (2005). Scalable Test Problems for Evolutionary Multiobjective Optimization. In: Abraham, A., Jain, L., Goldberg, R. (eds) Evolutionary Multiobjective Optimization. Advanced Information and Knowledge Processing. Springer.
Source code in desdeo/problem/testproblems/dtlz2_problem.py
forest_problem_discrete
Implements the forest problem using Pareto front representation.
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
A problem instance representing the forest problem. |
Source code in desdeo/problem/testproblems/forest_problem.py
mcwb_equilateral_tbeam_problem
Defines the multiobjective cantilever welded beam (MCWB) optimization problem...
Defines the multiobjective cantilever welded beam (MCWB) optimization problem using an equilateral T-beam cross-section.
The objective functions and constraints for the MCWB design problem are defined as follows:
Objectives: 1. Minimize the total cost, \( f_1 = W_c + B_c \), where \( W_c \) is the weld cost and \( B_c \) is the beam cost. 2. Minimize the deflection of the beam, \( f_2 = \frac{P L^3}{3 E I_x} \), where \( P \) is the applied load, \( L \) is the beam length, \( E \) is the Young's modulus, and \( I_x \) is the moment of inertia.
Constraints: 1. Shear stress constraint: \( \tau \leq \tau_{max} \), where \( \tau \) is the combined shear stress and \( \tau_{max} \) is the maximum shear stress. 2. Normal stress constraint: \( \sigma_x \leq \sigma_{max} \), where \( \sigma_x \) is the bending stress and \( \sigma_{max} \) is the maximum allowable normal stress. 3. Buckling constraint: \( P \leq P_c \), where \( P_c \) is the critical buckling load. 4. Weld height constraint: \( x_1 \leq x_4 \), ensuring that the weld height \( x_1 \) is less than or equal to the flange/web thickness \( x_4 \). 5. Flange thickness constraint: \( x_4 \geq x_3 \), ensuring that the flange thickness \( x_4 \) is greater than or equal to the beam height \( x_3 \).
Where: - \( x_1 \) is the weld height. - \( x_2 \) is the weld length. - \( x_3 \) is the beam height. - \( x_4 \) is the beam thickness (flange/web thickness).
The parameters are defined as: - \( P = 30000 \, \text{N} \) (load), - \( L = 0.5 \, \text{m} \) (beam length), - \( E = 200 \times 10^9 \, \text{Pa} \) (Young's modulus), - \( \tau_{max} = 95 \times 10^6 \, \text{Pa} \) (max shear stress), - \( \sigma_{max} = 200 \times 10^6 \, \text{Pa} \) (max normal stress), - \( C_w = 209600 \, \text{\$/m}^3 \) (welding cost factor), - \( C_s = 0.7 \, \text{\$/kg} \) (price of HRC steel), - \( \rho_s = 7850 \, \text{kg/m}^3 \) (steel density), - \( C_b = 0.7 \times 7850 \, \text{\$/m}^3 \) (beam material cost factor), - \( K = 2 \) (cantilever beam coefficient), - \( \pi = 3.141592653589793 \) (constant for calculations), - \( \delta_t = 0.045 \) (tolerance factor for calculations).
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
An instance of the multiobjective cantilever welded beam optimization problem using an equilateral T-beam cross-section. |
Source code in desdeo/problem/testproblems/mcwb_problem.py
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 | |
mcwb_hollow_rectangular_problem
Defines the multiobjective cantilever welded beam (MCWB) optimization problem...
Defines the multiobjective cantilever welded beam (MCWB) optimization problem using a hollow rectangular cross-section.
The objective functions and constraints for the MCWB design problem are defined as follows:
Objectives: 1. Minimize the total cost, \( f_1 = W_c + B_c \), where \( W_c \) is the weld cost and \( B_c \) is the beam cost. 2. Minimize the deflection of the beam, \( f_2 = \frac{P L^3}{3 E I_x} \), where \( P \) is the applied load, \( L \) is the beam length, \( E \) is the Young's modulus, and \( I_x \) is the moment of inertia.
Constraints: 1. Shear stress constraint: \( \tau \leq \tau_{max} \), where \( \tau \) is the combined shear stress and \( \tau_{max} \) is the maximum shear stress. 2. Normal stress constraint: \( \sigma_x \leq \sigma_{max} \), where \( \sigma_x \) is the bending stress and \( \sigma_{max} \) is the maximum allowable normal stress. 3. Buckling constraint: \( P \leq P_c \), where \( P_c \) is the critical buckling load. 4. Weld height constraint: \( x_1 \leq x_4 \), ensuring that the weld height \( x_1 \) is less than or equal to the flange thickness \( x_4 \). 5. Wall thickness constraint: \( t \geq h \), where \( t \) is the wall thickness and \( h \) is the outer height.
Where: - \( x_1 \) is the weld height. - \( x_2 \) is the weld length. - \( x_3 \) is the outer height of the beam. - \( x_4 \) is the outer width of the beam. - \( x_5 \) is the wall thickness of the hollow beam.
The parameters are defined as: - \( P = 30000 \, \text{N} \) (load), - \( L = 0.5 \, \text{m} \) (beam length), - \( E = 200 \times 10^9 \, \text{Pa} \) (Young's modulus), - \( \tau_{max} = 95 \times 10^6 \, \text{Pa} \) (max shear stress), - \( \sigma_{max} = 200 \times 10^6 \, \text{Pa} \) (max normal stress), - \( C_w = 209600 \, \text{\$/m}^3 \) (welding cost factor), - \( C_s = 0.7 \, \text{\$/kg} \) (price of HRC steel), - \( \rho_s = 7850 \, \text{kg/m}^3 \) (steel density), - \( C_b = 0.7 \times 7850 \, \text{\$/m}^3 \) (beam material cost factor), - \( K = 2 \) (cantilever beam coefficient), - \( \pi = 3.141592653589793 \) (constant for calculations), - \( \delta_t = 0.045 \) (tolerance factor for calculations).
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
An instance of the multiobjective cantilever welded beam optimization problem using a hollow rectangular cross-section. |
Source code in desdeo/problem/testproblems/mcwb_problem.py
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 | |
mcwb_ragsdell1976_problem
Defines the multiobjective cantilever welded beam (MCWB) optimization problem...
Defines the multiobjective cantilever welded beam (MCWB) optimization problem based on the framework proposed by Ragsdell (1976).
This problem involves optimizing the design of a welded cantilever beam considering welding costs, material costs, and stress constraints. The goal is to minimize both the total cost and the deflection of the beam, while adhering to the given constraints on material properties, geometry, and loading conditions.
Objectives: 1. Minimize the total cost, \( f_1 = W_c + B_c \), where: - \( W_c \) is the weld cost, calculated as the sum of welding labor cost and material cost. - \( B_c \) is the beam material cost, based on the beam's dimensions and the cost of the steel used. 2. Minimize the deflection of the beam, \( f_2 = \frac{P L^3}{3 E I_x} \), where: - \( P \) is the applied load. - \( L \) is the beam length. - \( E \) is the Young's modulus. - \( I_x \) is the moment of inertia of the beam's cross-section.
Constraints: 1. Weld height constraint: \( x_1 \leq x_4 \), ensuring that the weld height \( x_1 \) is less than or equal to the beam width \( x_4 \) (flange thickness). 2. The problem also considers the material constraints on maximum shear stress and normal stress, but these are not explicitly listed as constraints in this setup.
Where: - \( x_1 \) is the height of the weld. - \( x_2 \) is the length of the weld. - \( x_3 \) is the height of the beam. - \( x_4 \) is the width of the beam.
Constants: - \( P = 30000 \, \text{N} \) (load), - \( L = 0.5 \, \text{m} \) (beam length), - \( E = 200 \times 10^9 \, \text{Pa} \) (Young's modulus), - \( \tau_{\text{max}} = 95 \times 10^6 \, \text{Pa} \) (maximum shear stress), - \( \sigma_{\text{max}} = 200 \times 10^6 \, \text{Pa} \) (maximum normal stress), - \( C_{\text{wl}} = 1 \, \text{\$/in} \) (welding labor cost), - \( C_{\text{wm}} = 0.10471 \, \text{\$/in} \) (welding material cost), - \( C_{\text{w}} = 1 \times 0.10471 \, \text{\$/in} \) (total welding cost), - \( C_s = 0.7 \, \text{\$/kg} \) (steel price), - \( \rho_s = 7850 \, \text{kg/m}^3 \) (steel density), - \( C_b = 0.04811 \, \text{\$/in} \) (beam material cost), - \( K = 2 \) (cantilever beam coefficient), - \( \pi = 3.141592653589793 \) (constant), - \( \delta_t = 0.05 - 0.005 \) (tolerance factor).
Intermediate Functions: 1. Cross-sectional area: \( A = x_3 \times x_4 \). 2. Moment of inertia: \( I_x = \frac{x_4 \times x_3^3}{12} \), representing the beam's resistance to bending.
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
An instance of the multiobjective cantilever welded beam optimization problem based on Ragsdell's method (1976). |
Source code in desdeo/problem/testproblems/mcwb_problem.py
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 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 | |
mcwb_solid_rectangular_problem
Defines the multiobjective cantilever welded beam (MCWB) optimization problem.
The objective functions and constraints for the MCWB design problem are defined as follows:
Objectives: 1. Minimize the total cost, \( f_1 = W_c + B_c \), where \( W_c \) is the weld cost and \( B_c \) is the beam cost. 2. Minimize the deflection of the beam, \( f_2 = \frac{P L^3}{3 E I_x} \), where \( P \) is the applied load, \( L \) is the beam length, \( E \) is the Young's modulus, and \( I_x \) is the moment of inertia.
Constraints: 1. Shear stress constraint: \( \tau \leq \tau_{max} \), where \( \tau \) is the combined shear stress and \( \tau_{max} \) is the maximum shear stress. 2. Normal stress constraint: \( \sigma_x \leq \sigma_{max} \), where \( \sigma_x \) is the bending stress and \( \sigma_{max} \) is the maximum allowable normal stress. 3. Buckling constraint: \( P \leq P_c \), where \( P_c \) is the critical buckling load. 4. Weld height constraint: \( x_1 \leq x_4 \), ensuring that the weld height \( x_1 \) is less than or equal to the flange thickness \( x_4 \).
Where: - \( x_1 \) is the weld height. - \( x_2 \) is the weld length. - \( x_3 \) is the beam height. - \( x_4 \) is the beam width.
The parameters are defined as: - \( P = 30000 \, \text{N} \) (load), - \( L = 0.5 \, \text{m} \) (beam length), - \( E = 200 \times 10^9 \, \text{Pa} \) (Young's modulus), - \( \tau_{max} = 95 \times 10^6 \, \text{Pa} \) (max shear stress), - \( \sigma_{max} = 200 \times 10^6 \, \text{Pa} \) (max normal stress), - \( C_w = 209600 \, \text{\$/m}^3 \) (welding cost factor), - \( C_s = 0.7 \, \text{\$/kg} \) (price of HRC steel), - \( \rho_s = 7850 \, \text{kg/m}^3 \) (steel density), - \( C_b = 0.7 \times 7850 \, \text{\$/m}^3 \) (beam material cost factor), - \( K = 2 \) (cantilever beam coefficient), - \( \pi = 3.141592653589793 \) (constant for calculations), - \( \delta_t = 0.045 \) (tolerance factor for calculations).
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
An instance of the multiobjective cantilever welded beam optimization problem. |
Source code in desdeo/problem/testproblems/mcwb_problem.py
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 164 165 166 167 168 169 170 171 172 | |
mcwb_square_channel_problem
Defines the multiobjective cantilever welded beam (MCWB) optimization problem...
Defines the multiobjective cantilever welded beam (MCWB) optimization problem using a square channel cross-section.
The objective functions and constraints for the MCWB design problem are defined as follows:
Objectives: 1. Minimize the total cost, \( f_1 = W_c + B_c \), where \( W_c \) is the weld cost and \( B_c \) is the beam cost. 2. Minimize the deflection of the beam, \( f_2 = \frac{P L^3}{3 E I_x} \), where \( P \) is the applied load, \( L \) is the beam length, \( E \) is the Young's modulus, and \( I_x \) is the moment of inertia.
Constraints: 1. Weld height constraint: \( x_1 \leq x_4 \), ensuring that the weld height \( x_1 \) is less than or equal to the flange thickness \( x_4 \). 2. Beam width constraint: \( x_4 \geq x_3 \), ensuring that the beam width \( x_4 \) is greater than or equal to the beam height \( x_3 \). 3. Web thickness constraint: \( x_6 \geq \frac{x_3}{2} \), ensuring that the web thickness \( x_6 \) is greater than or equal to half the beam height \( x_3 \). 4. Flange thickness constraint: \( x_5 \geq x_4 \), ensuring that the flange thickness \( x_5 \) is greater than or equal to the beam width \( x_4 \).
Where: - \( x_1 \) is the weld height. - \( x_2 \) is the weld length. - \( x_3 \) is the beam height. - \( x_4 \) is the beam width. - \( x_5 \) is the flange thickness. - \( x_6 \) is the web thickness.
The parameters are defined as: - \( P = 30000 \, \text{N} \) (load), - \( L = 0.5 \, \text{m} \) (beam length), - \( E = 200 \times 10^9 \, \text{Pa} \) (Young's modulus), - \( \tau_{max} = 95 \times 10^6 \, \text{Pa} \) (max shear stress), - \( \sigma_{max} = 200 \times 10^6 \, \text{Pa} \) (max normal stress), - \( C_w = 209600 \, \text{\$/m}^3 \) (welding cost factor), - \( C_s = 0.7 \, \text{\$/kg} \) (price of HRC steel), - \( \rho_s = 7850 \, \text{kg/m}^3 \) (steel density), - \( C_b = 0.7 \times 7850 \, \text{\$/m}^3 \) (beam material cost factor), - \( K = 2 \) (cantilever beam coefficient), - \( \pi = 3.141592653589793 \) (constant for calculations), - \( \delta_t = 0.045 \) (tolerance factor for calculations).
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
An instance of the multiobjective cantilever welded beam optimization problem using a square channel cross-section. |
Source code in desdeo/problem/testproblems/mcwb_problem.py
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 | |
mcwb_tapered_channel_problem
Defines the multiobjective cantilever welded beam (MCWB) optimization problem...
Defines the multiobjective cantilever welded beam (MCWB) optimization problem using a tapered channel cross-section.
The objective functions and constraints for the MCWB design problem are defined as follows:
Objectives: 1. Minimize the total cost, \( f_1 = W_c + B_c \), where \( W_c \) is the weld cost and \( B_c \) is the beam cost. 2. Minimize the deflection of the beam, \( f_2 = \frac{P L^3}{3 E I_x} \), where \( P \) is the applied load, \( L \) is the beam length, \( E \) is the Young's modulus, and \( I_x \) is the moment of inertia.
Constraints: 1. Weld height constraint: \( x_1 \leq x_5 \), ensuring that the weld height \( x_1 \) is less than or equal to the outer flange thickness \( x_5 \). 2. Beam width constraint: \( x_4 \geq x_3 \), ensuring that the beam width \( x_4 \) is greater than or equal to the beam height \( x_3 \). 3. Inner flange height constraint: \( x_6 \geq \frac{x_3}{2} \), ensuring that the inner flange height \( x_6 \) is greater than or equal to half the beam height \( x_3 \). 4. Web thickness constraint: \( x_7 \leq x_4 \), ensuring that the web thickness \( x_7 \) is less than or equal to the beam width \( x_4 \). 5. Outer flange thickness constraint: \( x_5 \leq x_6 \), ensuring that the outer flange thickness \( x_5 \) is less than or equal to the inner flange thickness \( x_6 \).
Where: - \( x_1 \) is the weld height. - \( x_2 \) is the weld length. - \( x_3 \) is the beam height. - \( x_4 \) is the beam width. - \( x_5 \) is the outer flange thickness. - \( x_6 \) is the inner flange thickness. - \( x_7 \) is the web thickness.
The parameters are defined as: - \( P = 30000 \, \text{N} \) (load), - \( L = 0.5 \, \text{m} \) (beam length), - \( E = 200 \times 10^9 \, \text{Pa} \) (Young's modulus), - \( \tau_{max} = 95 \times 10^6 \, \text{Pa} \) (max shear stress), - \( \sigma_{max} = 200 \times 10^6 \, \text{Pa} \) (max normal stress), - \( C_w = 209600 \, \text{\$/m}^3 \) (welding cost factor), - \( C_s = 0.7 \, \text{\$/kg} \) (price of HRC steel), - \( \rho_s = 7850 \, \text{kg/m}^3 \) (steel density), - \( C_b = 0.7 \times 7850 \, \text{\$/m}^3 \) (beam material cost factor), - \( K = 2 \) (cantilever beam coefficient), - \( \pi = 3.141592653589793 \) (constant for calculations), - \( \delta_t = 0.045 \) (tolerance factor for calculations).
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
An instance of the multiobjective cantilever welded beam optimization problem using a tapered channel cross-section. |
Source code in desdeo/problem/testproblems/mcwb_problem.py
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 | |
mixed_variable_dimensions_problem
Defines a problem with variables with mixed dimensions.
Has both Variable and TensorVariable types of variables, where the TensorVariables have varying number of dimensions. Mostly for testing purposes.
Source code in desdeo/problem/testproblems/mixed_variable_dimenrions_problem.py
momip_ti2
Defines the mixed-integer multiobjective optimization problem test instance 2 (TI2).
The problem has four variables, two continuous and two integer. The Pareto optimal solutions hold for solutions with x_1^2 + x_2^2 = 0.25 and (x_3, x_4) = {(0, -1), (-1, 0)}.
References
Eichfelder, G., Gerlach, T., & Warnow, L. (n.d.). Test Instances for Multiobjective Mixed-Integer Nonlinear Optimization.
Source code in desdeo/problem/testproblems/momip_problem.py
momip_ti7
Defines the mixed-integer multiobjective optimization problem test instance 7 (T7).
The problem is defined as follows:
In the problem, \(x_1, x_2, x_3\) are real-valued and \(x_4, x_5, x_6\) are integer-valued. The problem is convex and differentiable.
The Pareto optimal integer assignments are \((x_4, x_5, x_6) \in {(0,0,-1), (0, -1, 0), (-1,0,0)}\), and the real-valued assignments are \(\{x_1, x_2, x_3 \in \mathbb{R}^3 | x_1^2 + x_2^2 + x_3^2 = 1, x_1 \leq 0, x_2 \leq 0, x_3 \leq 0\}\). Unlike in the original definition, \(f_2\) is formulated to be maximized instead of minimized.
References
Eichfelder, G., Gerlach, T., & Warnow, L. (n.d.). Test Instances for Multiobjective Mixed-Integer Nonlinear Optimization.
Source code in desdeo/problem/testproblems/momip_problem.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 164 165 166 167 168 169 170 171 172 | |
multi_valued_constraint_problem
Defines a test problem with a multi-valued constraint.
The problem has two objectives, two variables, and two constraints, the other of which, is multi-valued. The problem is defined as follows:
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
the problem model. |
Source code in desdeo/problem/testproblems/multi_valued_constraints.py
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 | |
nimbus_test_problem
Defines the test problem utilized in the article describing Synchronous NIMBUS.
Defines the following multiobjective optimization problem:
with the following ideal point \(\mathbf{z}^\star = \left[9.0, 2.0, -6.0, -2.0, 60.0, 480.0 \right]\) and nadir point \(\mathbf{z}^\text{nad} = \left[ 1.0, 18.0, -2.0, 2.0, 4860.0, 9280.0 \right]\).
References
Miettinen, K., & Mäkelä, M. M. (2006). Synchronous approach in interactive multiobjective optimization. European Journal of Operational Research, 170(3), 909–922. https://doi.org/10.1016/j.ejor.2004.07.052
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
the NIMBUS test problem. |
Source code in desdeo/problem/testproblems/nimbus_problem.py
9 10 11 12 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 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
pareto_navigator_test_problem
Defines the problem utilized in the (convex) Pareto navigator article.
The problem is defined as follows:
The problem comes with seven pre-defined Pareto optimal solutions that were utilized in the original article as well. From these, the ideal and nadir points of the problem are approximated also.
References
Eskelinen, P., Miettinen, K., Klamroth, K., & Hakanen, J. (2010). Pareto navigator for interactive nonlinear multiobjective optimization. OR Spectrum, 32(1), 211-227.
Source code in desdeo/problem/testproblems/pareto_navigator_problem.py
re21
re21(
f: float = 10.0,
sigma: float = 10.0,
e: float = 2.0 * 100000.0,
l: float = 200.0,
) -> Problem
Defines the four bar truss design problem.
The objective functions and constraints for the four bar truss design problem are defined as follows:
where \(x_1, x_4 \in [a, 3a]\), \(x_2, x_3 \in [\sqrt{2}a, 3a]\), and \(a = F/\sigma\). The parameters are defined as \(F = 10\) \(kN\), \(E = 2e^5\) \(kN/cm^2\), \(L = 200\) \(cm\), and \(\sigma = 10\) \(kN/cm^2\).
References
Cheng, F. Y., & Li, X. S. (1999). Generalized center method for multiobjective engineering optimization. Engineering Optimization, 31(5), 641-661.
Tanabe, R. & Ishibuchi, H. (2020). An easy-to-use real-world multi-objective optimization problem suite. Applied soft computing, 89, 106078. https://doi.org/10.1016/j.asoc.2020.106078.
https://github.com/ryojitanabe/reproblems/blob/master/reproblem_python_ver/reproblem.py
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
float
|
Force (kN). Defaults to 10.0. |
10.0
|
sigma
|
optional
|
Stress (kN/cm^2). Defaults to 10.0. |
10.0
|
e
|
float
|
Young modulus? (kN/cm^2). Defaults to 2.0 * 1e5. |
2.0 * 100000.0
|
l
|
float
|
Length (cm). Defaults to 200.0. |
200.0
|
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
an instance of the four bar truss design problem. |
Source code in desdeo/problem/testproblems/re_problem.py
re22
The reinforced concrete beam design problem.
The objective functions and constraints for the reinforced concrete beam design problem are defined as follows:
where \(x_2 \in [0, 20]\) and \(x_3 \in [0, 40]\).
References
Amir, H. M., & Hasegawa, T. (1989). Nonlinear mixed-discrete structural optimization. Journal of Structural Engineering, 115(3), 626-646.
Tanabe, R. & Ishibuchi, H. (2020). An easy-to-use real-world multi-objective optimization problem suite. Applied soft computing, 89, 106078. https://doi.org/10.1016/j.asoc.2020.106078.
https://github.com/ryojitanabe/reproblems/blob/master/reproblem_python_ver/reproblem.py
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
an instance of the reinforced concrete beam design problem. |
Source code in desdeo/problem/testproblems/re_problem.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 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 | |
re23
The pressure vessel design problem.
The objective functions and constraints for the pressure vessel design problem are defined as follows:
where $x_1, x_2 \in \{1,\dots,100\}$, $x_3 \in [10, 200]$, and $x_4 \in [10, 240]$. $x_1$ and $x_2$ are
integer multiples of 0.0625. $x_1$, $x_2$, $x_3$, and $x_4$ represent the thicknesses of
the shell, the head of a pressure vessel, the inner radius, and the length of
the cylindrical section, respectively. We determined the ranges of $x_2$ and $x_3$
according to [S.3].
References
Kannan, B. K., & Kramer, S. N. (1994). An augmented Lagrange multiplier based method for mixed integer discrete continuous optimization and its applications to mechanical design.
Tanabe, R. & Ishibuchi, H. (2020). An easy-to-use real-world multi-objective optimization problem suite. Applied soft computing, 89, 106078. https://doi.org/10.1016/j.asoc.2020.106078.
https://github.com/ryojitanabe/reproblems/blob/master/reproblem_python_ver/reproblem.py
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
an instance of the pressure vessel design problem. |
Source code in desdeo/problem/testproblems/re_problem.py
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 | |
re24
The hatch cover design problem.
The objective functions and constraints for the hatch cover design problem are defined as follows:
where \(x_1 \in [0.5, 4]\) and \(x_2 \in [4, 50]\). The parameters are defined as \(\sigma_{b,max} = 700 kg/cm^2\), \(\tau_{max} = 450 kg/cm\), \(\delta_{max} = 1.5 cm\), \(\sigma_k = Ex_1^2/100 kg/cm^2\), \(\sigma_b = 4500/(x_1x_2) kg/cm^2\), \(\tau = 1800/x_2 kg/cm^2\), \(\delta = 56.2 \times 10^4/(Ex_1x_2^2)\), and \(E = 700\,000 kg/cm^2\).
References
Amir, H. M., & Hasegawa, T. (1989). Nonlinear mixed-discrete structural optimization. Journal of Structural Engineering, 115(3), 626-646.
Tanabe, R. & Ishibuchi, H. (2020). An easy-to-use real-world multi-objective optimization problem suite. Applied soft computing, 89, 106078. https://doi.org/10.1016/j.asoc.2020.106078.
https://github.com/ryojitanabe/reproblems/blob/master/reproblem_python_ver/reproblem.py
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
an instance of the hatch cover design problem. |
Source code in desdeo/problem/testproblems/re_problem.py
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 | |
river_pollution_problem
Create a pydantic dataclass representation of the river pollution problem with either five or four variables.
The objective functions "DO city" (\(f_1\)), "DO municipality" (\(f_2), and "ROI fishery" (\)f_3\() and "ROI city" (\)f_4\() are to be maximized. If the four variant problem is used, the the "BOD deviation" objective function (\)f_5$) is not present, but if it is, it is to be minimized. The problem is defined as follows:
where the fifth objective is part of the problem definition only if
five_objective_variant = True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
five_objective_variant
|
bool
|
Whether to use to five objective function variant of the problem or not. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
the river pollution problem. |
References
Narula, Subhash C., and HRoland Weistroffer. "A flexible method for nonlinear multicriteria decision-making problems." IEEE Transactions on Systems, Man, and Cybernetics 19.4 (1989): 883-887.
Miettinen, Kaisa, and Marko M. Mäkelä. "Interactive method NIMBUS for nondifferentiable multiobjective optimization problems." Multicriteria Analysis: Proceedings of the XIth International Conference on MCDM, 1-6 August 1994, Coimbra, Portugal. Berlin, Heidelberg: Springer Berlin Heidelberg, 1997.
Source code in desdeo/problem/testproblems/river_pollution_problems.py
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 131 132 133 134 135 136 137 138 | |
river_pollution_problem_discrete
Create a pydantic dataclass representation of the river pollution problem with either five or four variables.
The objective functions "DO city" (\(f_1\)), "DO municipality" (\(f_2), and "ROI fishery" (\)f_3\() and "ROI city" (\)f_4\() are to be maximized. If the four variant problem is used, the the "BOD deviation" objective function (\)f_5$) is not present, but if it is, it is to be minimized. This version of the problem uses discrete representation of the variables and objectives and does not provide the analytical functions for the objectives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
five_objective_variant
|
bool
|
Whether to use to five objective function variant of the problem or not. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
the river pollution problem. |
References
Narula, Subhash C., and HRoland Weistroffer. "A flexible method for nonlinear multicriteria decision-making problems." IEEE Transactions on Systems, Man, and Cybernetics 19.4 (1989): 883-887.
Miettinen, Kaisa, and Marko M. Mäkelä. "Interactive method NIMBUS for nondifferentiable multiobjective optimization problems." Multicriteria Analysis: Proceedings of the XIth International Conference on MCDM, 1-6 August 1994, Coimbra, Portugal. Berlin, Heidelberg: Springer Berlin Heidelberg, 1997.
Source code in desdeo/problem/testproblems/river_pollution_problems.py
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 | |
river_pollution_scenario
Defines the scenario-based uncertain variant of the river pollution problem.
The river pollution problem considers a river close to a city. There are two sources of pollution: industrial pollution from a fishery and municipal waste from the city. Two treatment plants (in the fishery and the city) are responsible for managing the pollution. Pollution is reported in pounds of biochemical oxygen demanding material (BOD), and water quality is measured in dissolved oxygen concentration (DO).
Cleaning water in the city increases the tax rate, and cleaning in the
fishery reduces the return on investment. The problem is to improve
the DO level in the city and at the municipality border (f1 and f2, respectively),
while, at the same time, maximizing the percent return on investment at the fishery (f3)
and minimizing additions to the city tax (f4).
Decision variables are:
x1: The proportional amount of BOD removed from water after the fishery (treatment plant 1).x2: The proportional amount of BOD removed from water after the city (treatment plant 2).
The original problem considered specific values for all parameters. However, in this formulation, some parameters are deeply uncertain, and only a range of plausible values is known for each. These deeply uncertain parameters are as follows:
α ∈ [3, 4.24]: Water quality index after the fishery.β ∈ [2.25, 2.4]: BOD reduction rate at treatment plant 1 (after the fishery).δ ∈ [0.075, 0.092]: BOD reduction rate at treatment plant 2 (after the city).ξ ∈ [0.067, 0.083]: Effective rate of BOD reduction at treatment plant 1 after the city.η ∈ [1.2, 1.50]: Parameter used to calculate the effective BOD reduction rate at the second treatment plant.r ∈ [5.1, 12.5]: Investment return rate.
The uncertain version of the river problem is formulated as follows:
where \(\\gamma = \\log\\left(\\frac{\\alpha}{2} - 1\\right) + \\frac{\\alpha}{2} + 1.5\).
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
the scenario-based river pollution problem. |
References
Narula, Subhash C., and HRoland Weistroffer. "A flexible method for nonlinear multicriteria decision-making problems." IEEE Transactions on Systems, Man, and Cybernetics 19.4 (1989): 883-887.
Miettinen, Kaisa, and Marko M. Mäkelä. "Interactive method NIMBUS for nondifferentiable multiobjective optimization problems." Multicriteria Analysis: Proceedings of the XIth International Conference on MCDM, 1-6 August 1994, Coimbra, Portugal. Berlin, Heidelberg: Springer Berlin Heidelberg, 1997.
Source code in desdeo/problem/testproblems/river_pollution_problems.py
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 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 429 430 431 432 433 434 435 436 437 438 439 440 | |
rocket_injector_design
The rocekt injector design problem as published in Vaidyanathan, et al. (2003).
The original version of the problem has 4 objectives. In Goel et al. (2007), the TW4 objective is dropped due to high correlation with one of the other objectives. Hence, the default version of the problem is the modified version with 3 objectives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
original_version
|
bool
|
If True, the original version of the problem with 4 objectives is returned. |
False
|
References
R. Vaidyanathan, K. Tucker, N. Papila, W. Shyy, CFD-Based Design Optimization For Single Element Rocket Injector, in: AIAA Aerospace Sciences Meeting, 2003, pp. 1-21.
Goel, T., Vaidyanathan, R., Haftka, R. T., Shyy, W., Queipo, N. V., & Tucker, K. (2007). Response surface approximation of Pareto optimal front in multi-objective optimization. Computer methods in applied mechanics and engineering, 196(4-6), 879-893.
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
The rocket injector design problem. |
Source code in desdeo/problem/testproblems/rocket_injector_design_problem.py
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 131 132 133 134 135 136 137 138 139 140 | |
simple_constrained_quadratic_tensor_test_problem
Defines a simple constrained quadratic problem with tensor variables, suitable for testing purposes.
Source code in desdeo/problem/testproblems/simple_problem.py
simple_data_problem
Defines a simple problem with only data-based objective functions.
Source code in desdeo/problem/testproblems/simple_problem.py
simple_integer_test_problem
Defines a simple integer problem suitable for testing purposes.
Source code in desdeo/problem/testproblems/simple_problem.py
simple_knapsack
Defines a simple multiobjective knapsack problem.
Given a set of 4 items, each with a weight and three values corresponding to different objectives, the problem is defined as follows:
- Item 1: weight = 2, values = (5, 10, 15)
- Item 2: weight = 3, values = (4, 7, 9)
- Item 3: weight = 1, values = (3, 5, 8)
- Item 4: weight = 4, values = (2, 3, 5)
The problem is then to maximize the following functions:
where the inequality constraint is a weight constraint. The problem is a binary variable problem.
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
the simple knapsack problem. |
Source code in desdeo/problem/testproblems/knapsack_problem.py
simple_knapsack_vectors
Define a simple variant of the knapsack problem that utilizes vectors (TensorVariable and TensorConstant).
Source code in desdeo/problem/testproblems/knapsack_problem.py
simple_linear_test_problem
Defines a simple single objective linear problem suitable for testing purposes.
Source code in desdeo/problem/testproblems/simple_problem.py
simple_scenario_test_problem
Returns a simple, scenario-based multiobjective optimization test problem.
Source code in desdeo/problem/testproblems/simple_problem.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 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 | |
simple_test_problem
Defines a simple problem suitable for testing purposes.
Source code in desdeo/problem/testproblems/simple_problem.py
spanish_sustainability_problem_discrete
Implements the Spanish sustainability problem using Pareto front representation.
Source code in desdeo/problem/testproblems/spanish_sustainability_problem.py
zdt1
Defines the ZDT1 test problem.
The problem has a variable number of decision variables and two objective functions to be minimized as follows:
where \(f_1\) and \(f_2\) are objective functions, \(x_1,\dots,x_n\) are decision variable, \(n\) is the number of decision variables, and \(g\) and \(h\) are auxiliary functions.
Source code in desdeo/problem/testproblems/zdt_problem.py
zdt2
Defines the ZDT2 test problem.
The problem has a variable number of decision variables and two objective functions to be minimized as follows:
where \(f_1\) and \(f_2\) are objective functions, \(x_1,\dots,x_n\) are decision variable, \(n\) is the number of decision variables, and \(g\) and \(h\) are auxiliary functions.
Source code in desdeo/problem/testproblems/zdt_problem.py
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 | |
zdt3
Defines the ZDT3 test problem.
The problem has a variable number of decision variables and two objective functions to be minimized as follows:
where \(f_2\) and \(f_2\) are objective functions, \(x_1,\dots,x_n\) are decision variable, \(n\) is the number of decision variables, and \(g\) and \(h\) are auxiliary functions.
Source code in desdeo/problem/testproblems/zdt_problem.py
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 | |
Problem schema
desdeo.problem.schema
Schema for the problem definition.
The problem definition is a JSON file that contains the following information:
- Constants
- Variables
- Objectives
- Extra functions
- Scalarization functions
- Evaluated solutions and their info
Constant
Bases: BaseModel
Model for a constant.
Source code in desdeo/problem/schema.py
name
class-attribute
instance-attribute
name: str = Field(
description="Descriptive name of the constant. This can be used in UI and visualizations. Example: 'maximum cost'."
)
Descriptive name of the constant. This can be used in UI and visualizations." " Example: 'maximum cost'.
symbol
class-attribute
instance-attribute
symbol: str = Field(
description="Symbol to represent the constant. This will be used in the rest of the problem definition. It may also be used in UIs and visualizations. Example: 'c_1'."
)
Symbol to represent the constant. This will be used in the rest of the problem definition. It may also be used in UIs and visualizations. Example: 'c_1'.
Constraint
Bases: BaseModel
Model for a constraint function.
Source code in desdeo/problem/schema.py
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 | |
cons_type
class-attribute
instance-attribute
cons_type: ConstraintTypeEnum = Field(
description="The type of the constraint. Constraints are assumed to be in a standard form where the supplied 'func' expression is on the left hand side of the constraint's expression, and on the right hand side a zero value is assume. The comparison between the left hand side and right hand side is either and quality comparison ('=') or lesser than equal comparison ('<=')."
)
The type of the constraint. Constraints are assumed to be in a standard form where the supplied 'func' expression is on the left hand side of the constraint's expression, and on the right hand side a zero value is assume. The comparison between the left hand side and right hand side is either and quality comparison ('=') or lesser than equal comparison ('<=').
func
class-attribute
instance-attribute
func: list | None = Field(
description="Function of the constraint. This is a JSON object that can be parsed into a function.Must be a valid MathJSON object. The symbols in the function must match objective/variable/constant symbols.Can be 'None' if either 'simulator_path' or 'surrogates' is not 'None'. If 'None', either 'simulator_path' or 'surrogates' must not be 'None'.",
default=None,
)
Function of the constraint. This is a JSON object that can be parsed into a function. Must be a valid MathJSON object. The symbols in the function must match objective/variable/constant symbols. Can be 'None' if either 'simulator_path' or 'surrogates' is not 'None'. If 'None', either 'simulator_path' or 'surrogates' must not be 'None'.
is_convex
class-attribute
instance-attribute
is_convex: bool = Field(
description="Whether the function expression is convex or not (non-convex). Defaults to `False`.",
default=False,
)
Whether the function expression is convex or not (non-convex). Defaults to False.
is_linear
class-attribute
instance-attribute
is_linear: bool = Field(
description="Whether the constraint is linear or not. Defaults to True, e.g., a linear constraint is assumed.",
default=True,
)
Whether the constraint is linear or not. Defaults to True, e.g., a linear
constraint is assumed. Defaults to True.
is_twice_differentiable
class-attribute
instance-attribute
is_twice_differentiable: bool = Field(
description="Whether the function expression is twice differentiable or not. Defaults to `False`",
default=False,
)
Whether the function expression is twice differentiable or not. Defaults to False
name
class-attribute
instance-attribute
name: str = Field(
description="Descriptive name of the constraint. This can be used in UI and visualizations. Example: 'maximum length'."
)
Descriptive name of the constraint. This can be used in UI and visualizations. Example: 'maximum length'
scenario_keys
class-attribute
instance-attribute
scenario_keys: list[str] | None = Field(
description="Optional. The keys of the scenarios the constraint belongs to.",
default=None,
)
Optional. The keys of the scenarios the constraint belongs to.
simulator_path
class-attribute
instance-attribute
simulator_path: Path | Url | None = Field(
description="Path to a python file with the connection to simulators. Must be a valid Path.Can be 'None' for if either 'func' or 'surrogates' is not 'None'.If 'None', either 'func' or 'surrogates' must not be 'None'.",
default=None,
)
Path to a python file with the connection to simulators. Must be a valid Path. Can be 'None' for if either 'func' or 'surrogates' is not 'None'. If 'None', either 'func' or 'surrogates' must not be 'None'.
surrogates
class-attribute
instance-attribute
surrogates: list[Path] | None = Field(
description="A list of paths to models saved on disk. Can be 'None' for if either 'func' or 'simulator_path' is not 'None'. If 'None', either 'func' or 'simulator_path' must not be 'None'.",
default=None,
)
A list of paths to models saved on disk. Can be 'None' for if either 'func' or 'simulator_path' is not 'None'. If 'None', either 'func' or 'simulator_path' must not be 'None'.
symbol
class-attribute
instance-attribute
symbol: str = Field(
description="Symbol to represent the constraint. This will be used in the rest of the problem definition. It may also be used in UIs and visualizations. Example: 'g_1'."
)
Symbol to represent the constraint. This will be used in the rest of the problem definition. It may also be used in UIs and visualizations. Example: 'g_1'.
ConstraintTypeEnum
Bases: str, Enum
An enumerator for supported constraint expression types.
Source code in desdeo/problem/schema.py
DiscreteRepresentation
Bases: BaseModel
Model to represent discrete objective function and decision variable pairs.
Can be used alongside an analytical representation as well.
Used with Objectives of type 'data_based' by default. Each of the decision
variable values and objective functions values are ordered in their
respective dict entries. This means that the decision variable values found
at variable_values['x_i'][j] correspond to the objective function values
found at objective_values['f_i'][j] for all i and some j.
Source code in desdeo/problem/schema.py
non_dominated
class-attribute
instance-attribute
non_dominated: bool = Field(
description="Indicates whether the representation consists of non-dominated points or not.If False, some method can employ non-dominated sorting, which might slow an interactive method down.",
default=False,
)
Indicates whether the representation consists of non-dominated points or
not. If False, some method can employ non-dominated sorting, which might
slow an interactive method down. Defaults to False.
objective_values
class-attribute
instance-attribute
objective_values: dict[str, list[float]] = Field(
description="A dictionary with objective function values. Each dict key points to a list of all the objective function values available for the objective function given in the key. The keys must match the 'symbols' defined for the objective functions."
)
A dictionary with objective function values. Each dict key points to a list of all the objective function values available for the objective function given in the key. The keys must match the 'symbols' defined for the objective functions.
variable_values
class-attribute
instance-attribute
variable_values: dict[str, list[VariableType]] = Field(
description="A dictionary with decision variable values. Each dict key points to a list of all the decision variable values available for the decision variable given in the key. The keys must match the 'symbols' defined for the decision variables."
)
A dictionary with decision variable values. Each dict key points to a list of all the decision variable values available for the decision variable given in the key. The keys must match the 'symbols' defined for the decision variables.
ExtraFunction
Bases: BaseModel
Model for extra functions.
These functions can, e.g., be functions that are re-used in the problem formulation, or they are needed for other computations related to the problem.
Source code in desdeo/problem/schema.py
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 | |
func
class-attribute
instance-attribute
func: list | None = Field(
description="The string representing the function. This is a JSON object that can be parsed into a function.Must be a valid MathJSON object. The symbols in the function must match symbols defined for objective/variable/constant.Can be 'None' if either 'simulator_path' or 'surrogates' is not 'None'. If 'None', either 'simulator_path' or 'surrogates' must not be 'None'.",
default=None,
)
The string representing the function. This is a JSON object that can be parsed into a function. Must be a valid MathJSON object. The symbols in the function must match symbols defined for objective/variable/constant. Can be 'None' if either 'simulator_path' or 'surrogates' is not 'None'. If 'None', either 'simulator_path' or 'surrogates' must not be 'None'.
is_convex
class-attribute
instance-attribute
is_convex: bool = Field(
description="Whether the function expression is convex or not (non-convex). Defaults to `False`.",
default=False,
)
Whether the function expression is convex or not (non-convex). Defaults to False.
is_linear
class-attribute
instance-attribute
is_linear: bool = Field(
description="Whether the function expression is linear or not. Defaults to `False`.",
default=False,
)
Whether the function expression is linear or not. Defaults to False.
is_twice_differentiable
class-attribute
instance-attribute
is_twice_differentiable: bool = Field(
description="Whether the function expression is twice differentiable or not. Defaults to `False`",
default=False,
)
Whether the function expression is twice differentiable or not. Defaults to False
name
class-attribute
instance-attribute
Descriptive name of the function. Example: 'normalization'.
scenario_keys
class-attribute
instance-attribute
scenario_keys: list[str] | None = Field(
description="Optional. The keys of the scenario the extra functions belongs to.",
default=None,
)
Optional. The keys of the scenarios the extra functions belongs to.
simulator_path
class-attribute
instance-attribute
simulator_path: Path | None = Field(
description="Path to a python file with the connection to simulators. Must be a valid Path.Can be 'None' for 'analytical', 'data_based' or 'surrogate' functions.If 'None', either 'func' or 'surrogates' must not be 'None'.",
default=None,
)
Path to a python file with the connection to simulators. Must be a valid Path. Can be 'None' for 'analytical', 'data_based' or 'surrogate' functions. If 'None', either 'func' or 'surrogates' must not be 'None'.
surrogates
class-attribute
instance-attribute
surrogates: list[Path] | None = Field(
description="A list of paths to models saved on disk. Can be 'None' for 'analytical', 'data_based or 'simulator' functions. If 'None', either 'func' or 'simulator_path' must not be 'None'.",
default=None,
)
A list of paths to models saved on disk. Can be 'None' for 'analytical', 'data_based or 'simulator' functions. If 'None', either 'func' or 'simulator_path' must not be 'None'.
symbol
class-attribute
instance-attribute
symbol: str = Field(
description="Symbol to represent the function. This will be used in the rest of the problem definition. It may also be used in UIs and visualizations. Example: 'avg'."
)
Symbol to represent the function. This will be used in the rest of the problem definition. It may also be used in UIs and visualizations. Example: 'avg'.
Objective
Bases: BaseModel
Model for an objective function.
Source code in desdeo/problem/schema.py
782 783 784 785 786 787 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 | |
func
class-attribute
instance-attribute
func: list | None = Field(
description="The objective function. This is a JSON object that can be parsed into a function.Must be a valid MathJSON object. The symbols in the function must match the symbols defined for variable/constant/extra function. Can be 'None' for 'data_based', 'simulator' or 'surrogate' objective functions. If 'None', either 'simulator_path' or 'surrogates' must not be 'None'.",
default=None,
)
The objective function. This is a JSON object that can be parsed into a function. Must be a valid MathJSON object. The symbols in the function must match the symbols defined for variable/constant/extra function. Can be 'None' for 'data_based', 'simulator' or 'surrogate' objective functions. If 'None', either 'simulator_path' or 'surrogates' must not be 'None'.
ideal
class-attribute
instance-attribute
ideal: float | None = Field(
description="Ideal value of the objective. This is optional.",
default=None,
)
Ideal value of the objective. This is optional. Defaults to None.
is_convex
class-attribute
instance-attribute
is_convex: bool = Field(
description="Whether the function expression is convex or not (non-convex). Defaults to `False`.",
default=False,
)
Whether the function expression is convex or not (non-convex). Defaults to False.
is_linear
class-attribute
instance-attribute
is_linear: bool = Field(
description="Whether the function expression is linear or not. Defaults to `False`.",
default=False,
)
Whether the function expression is linear or not. Defaults to False.
is_twice_differentiable
class-attribute
instance-attribute
is_twice_differentiable: bool = Field(
description="Whether the function expression is twice differentiable or not. Defaults to `False`",
default=False,
)
Whether the function expression is twice differentiable or not. Defaults to False
maximize
class-attribute
instance-attribute
maximize: bool = Field(
description="Whether the objective function is to be maximized or minimized.",
default=False,
)
Whether the objective function is to be maximized or minimized. Defaults to False.
model_config
class-attribute
instance-attribute
A longer description for the objective.
nadir
class-attribute
instance-attribute
nadir: float | None = Field(
description="Nadir value of the objective. This is optional.",
default=None,
)
Nadir value of the objective. This is optional. Defaults to None.
name
class-attribute
instance-attribute
name: str = Field(
description="Descriptive name of the objective function. This can be used in UI and visualizations. Example: 'time'."
)
Descriptive name of the objective function. This can be used in UI and visualizations.
objective_type
class-attribute
instance-attribute
objective_type: ObjectiveTypeEnum = Field(
description="The type of objective function. 'analytical' means the objective function value is calculated based on 'func'. 'data_based' means the objective function value should be retrieved from a table. In case of 'data_based' objective function, the 'func' field is ignored. Defaults to 'analytical'.",
default=analytical,
)
The type of objective function. 'analytical' means the objective function value is calculated based on 'func'. 'data_based' means the objective function value should be retrieved from a table. In case of 'data_based' objective function, the 'func' field is ignored. Defaults to 'analytical'. Defaults to 'analytical'.
scenario_keys
class-attribute
instance-attribute
scenario_keys: list[str] | None = Field(
description="Optional. The keys of the scenarios the objective function belongs to.",
default=None,
)
Optional. The keys of the scenarios the objective function belongs to.
simulator_path
class-attribute
instance-attribute
simulator_path: Path | Url | None = Field(
description="Path to a python file or http server with the connection to simulators. Must be a valid Path or url.Can be 'None' for 'analytical', 'data_based' or 'surrogate' objective functions.If 'None', either 'func' or 'surrogates' must not be 'None'.",
default=None,
)
Path to a python file with the connection to simulators. Must be a valid Path. Can be 'None' for 'analytical', 'data_based' or 'surrogate' objective functions. If 'None', either 'func' or 'surrogates' must not be 'None'.
surrogates
class-attribute
instance-attribute
surrogates: list[Path] | None = Field(
description="A list of paths to models saved on disk. Can be 'None' for 'analytical', 'data_based or 'simulator' objective functions. If 'None', either 'func' or 'simulator_path' must not be 'None'.",
default=None,
)
A list of paths to models saved on disk. Can be 'None' for 'analytical', 'data_based or 'simulator' objective functions. If 'None', either 'func' or 'simulator_path' must not be 'None'.
symbol
class-attribute
instance-attribute
symbol: str = Field(
description="Symbol to represent the objective function. This will be used in the rest of the problem definition. It may also be used in UIs and visualizations. Example: 'f_1'."
)
Symbol to represent the objective function. This will be used in the rest of the problem definition. It may also be used in UIs and visualizations. Example: 'f_1'.
unit
class-attribute
instance-attribute
unit: str | None = Field(
description="The unit of the objective function. This is optional. Used in UIs and visualizations. Example: 'seconds' or 'millions of hectares'.",
default=None,
)
The unit of the objective function. This is optional. Used in UIs and visualizations. Example: 'seconds' or
'millions of hectares'. Defaults to None.
ObjectiveTypeEnum
Bases: str, Enum
An enumerator for supported objective function types.
Source code in desdeo/problem/schema.py
analytical
class-attribute
instance-attribute
An objective function with an analytical formulation. E.g., it can be expressed with mathematical expressions, such as x_1 + x_2.
data_based
class-attribute
instance-attribute
A data-based objective function. It is assumed that when such an
objective is present in a Problem, then there is a
DiscreteRepresentation available with values representing the objective
function.
simulator
class-attribute
instance-attribute
A simulator based objective function. It is assumed that a Path (str)
to a simulator file that connects a simulator to DESDEO is present in
the Objective and also in the list of simulators in the Problem.
Problem
Bases: BaseModel
Model for a problem definition.
Source code in desdeo/problem/schema.py
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 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 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 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 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 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 | |
constants
class-attribute
instance-attribute
constants: list[Constant | TensorConstant] | None = Field(
description="Optional list of the constants present in the problem.",
default=None,
)
List of the constants present in the problem. Defaults to None.
constraints
class-attribute
instance-attribute
constraints: list[Constraint] | None = Field(
description="Optional list of constraints present in the problem.",
default=None,
)
Optional list of constraints present in the problem. Defaults to None.
description
class-attribute
instance-attribute
Description of the problem.
discrete_representation
class-attribute
instance-attribute
discrete_representation: DiscreteRepresentation | None = (
Field(
description="Optional. Required when there are one or more 'data_based' Objectives. The corresponding values of the 'data_based' objective function will be fetched from this with the given variable values. Is also utilized for methods which require both an analytical and discrete representation of a problem.",
default=None,
)
)
Optional. Required when there are one or more 'data_based' Objectives.
The corresponding values of the 'data_based' objective function will be
fetched from this with the given variable values. Is also utilized for
methods which require both an analytical and discrete representation of a
problem. Defaults to None.
extra_funcs
class-attribute
instance-attribute
extra_funcs: list[ExtraFunction] | None = Field(
description="Optional list of extra functions. Use this if some function is repeated multiple times.",
default=None,
)
Optional list of extra functions. Use this if some function is repeated multiple times. Defaults to None.
is_convex
property
Check if all the functions expressions in the problem are convex.
Note
If the field "is_convex" is explicitly set, then the provided value is returned.
Otherwise, this method just checks all the functions expressions present in the problem and return true if all of them are convex. For complicated problems, this might result in an incorrect results. User discretion is advised.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
whether the problem is convex or not. |
is_convex_
class-attribute
instance-attribute
is_convex_: bool | None = Field(
description="Optional. Used to manually indicate if the problem, as a whole, can be considered to be convex. If set to `None`, this property will be automatically inferred from the respective properties of other attributes.",
default=None,
alias="is_convex",
)
Optional. Used to manually indicate if the problem, as a whole, can be considered to be convex. "
"If set to None, this property will be automatically inferred from the "
"respective properties of other attributes.
is_linear
property
Check if all the functions expressions in the problem are linear.
Note
If the field "is_linear" is explicitly set, then the provided value is returned.
Otherwise, this method just checks all the functions expressions present in the problem and return true if all of them are linear. For complicated problems, this might result in an incorrect results. User discretion is advised.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
whether the problem is linear or not. |
is_linear_
class-attribute
instance-attribute
is_linear_: bool | None = Field(
description="Optional. Used to manually indicate if the problem, as a whole, can be considered to be linear. If set to `None`, this property will be automatically inferred from the respective properties of other attributes.",
default=None,
alias="is_linear",
)
Optional. Used to manually indicate if the problem, as a whole, can be considered to be linear. "
"If set to None, this property will be automatically inferred from the "
"respective properties of other attributes.
is_twice_differentiable
property
Check if all the functions expressions in the problem are twice differentiable.
Note
If the field "is_twice_differentiable" is explicitly set, then the provided value is returned.
Otherwise, this method just checks all the functions expressions present in the problem and return true if all of them are twice differentiable. For complicated problems, this might result in an incorrect results. User discretion is advised.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
whether the problem is twice differentiable or not. |
is_twice_differentiable_
class-attribute
instance-attribute
is_twice_differentiable_: bool | None = Field(
description="Optional. Used to manually indicate if the problem, as a whole, can be considered to be twice differentiable. If set to `None`, this property will be automatically inferred from the respective properties of other attributes.",
default=None,
alias="is_twice_differentiable",
)
Optional. Used to manually indicate if the problem, as a whole, can be considered to be twice "
"differentiable. If set to None, this property will be automatically inferred from the "
"respective properties of other attributes.
name
class-attribute
instance-attribute
Name of the problem.
objectives
class-attribute
instance-attribute
List of the objectives present in the problem.
scalarization_funcs
class-attribute
instance-attribute
scalarization_funcs: list[ScalarizationFunction] | None = (
Field(
description="Optional list of scalarization functions of the problem.",
default=None,
)
)
Optional list of scalarization functions of the problem. Defaults to None.
scenario_keys
class-attribute
instance-attribute
scenario_keys: list[str] | None = Field(
description="Optional. The scenario keys defined for the problem. Each key will point to a subset of objectives, constraints, extra functions, and scalarization functions that have the same scenario key defined to them.If None, then the problem is assumed to not contain scenarios.",
default=None,
)
Optional. The scenario keys defined for the problem. Each key will point to a subset of objectives, " "constraints, extra functions, and scalarization functions that have the same scenario key defined to them." "If None, then the problem is assumed to not contain scenarios.
simulators
class-attribute
instance-attribute
simulators: list[Simulator] | None = Field(
description="Optional. The simulators used by the problem. Required when there are one or more Objectives defined by simulators. The corresponding values of the 'simulator' objective function will be fetched from these simulators with the given variable values.",
default=None,
)
Optional. The simulators used by the problem. Required when there are one or more
Objectives defined by simulators. The corresponding values of the 'simulator' objective
function will be fetched from these simulators with the given variable values.
Defaults to None.
variable_domain
property
Check the variables defined for the problem and returns the type of their domain.
Checks the variable types defined for the problem and tells if the problem is continuous, integer, binary, or mixed-integer.
Returns:
| Name | Type | Description |
|---|---|---|
VariableDomainEnum |
VariableDomainTypeEnum
|
whether the problem is continuous, integer, binary, or mixed-integer. |
variables
class-attribute
instance-attribute
variables: list[Variable | TensorVariable] = Field(
description="List of variables present in the problem."
)
List of variables present in the problem.
add_constraints
Adds new constraints to the problem model.
Does not modify the original problem model, but instead returns a copy of it with the added constraints. The symbols of the new constraints to be added must be unique.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_constraints
|
list[Constraint]
|
the new |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
when the |
ValueError
|
when duplicate symbols are found among the new_constraints, or any of the new constraints utilized an existing symbol in the problem's model. |
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
a copy of the problem with the added constraints. |
Source code in desdeo/problem/schema.py
add_scalarization
Adds a new scalarization function to the model.
If no symbol is defined, adds a name with the format 'scal_i'.
Does not modify the original problem model, but instead returns a copy of it with the added scalarization function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_scal
|
ScalarizationFunction
|
Scalarization functions to be added to the model. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when a ScalarizationFunction is given with a symbol that already exists in the model. |
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
a copy of the problem with the added scalarization function. |
Source code in desdeo/problem/schema.py
add_variables
Adds new variables to the problem model.
Does not modify the original problem model, but instead returns a copy of it with the added variables. The symbols of the new variables to be added must be unique.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_variables
|
list[Variable | TensorVariable]
|
the new variables to be added to the model. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
when the |
ValueError
|
when duplicate symbols are found among the new_variables, or any of the new variables utilized an existing symbol in the problem's model. |
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
a copy of the problem with the added variables. |
Source code in desdeo/problem/schema.py
check_for_non_unique_symbols
Check that all the symbols defined in the different fields are unique.
Source code in desdeo/problem/schema.py
from_problemdb
classmethod
.
Source code in desdeo/problem/schema.py
get_all_symbols
Collects and returns all the symbols symbols currently defined in the model.
Source code in desdeo/problem/schema.py
get_constraint
Return a copy of a Constant with the given symbol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
the symbol of the constraint. |
required |
Returns:
| Type | Description |
|---|---|
Constraint | None
|
Constant | None: the copy of the constraint with the given symbol, or |
Source code in desdeo/problem/schema.py
get_flattened_variables
Return a list of the (flattened) variables of the problem.
Returns a list of the variables defined for the problem so that any TensorVariables are flattened.
Returns:
| Type | Description |
|---|---|
list[Variable]
|
list[Variable]: list of (flattened) variables. |
Source code in desdeo/problem/schema.py
get_ideal_point
Get the ideal point of the problem as an objective dict.
Returns an objective dict containing the ideal values of the
the problem for each objective function. These values may be None.
Returns:
| Type | Description |
|---|---|
dict[str, float | None]
|
dict[str, float | None] | None: an objective dict with the ideal
point values (which may be |
Source code in desdeo/problem/schema.py
get_nadir_point
Get the nadir point of the problem as an objective dict.
Returns an objective dict containing the nadir values of the
the problem for each objective function. These values may be None.
Returns:
| Type | Description |
|---|---|
dict[str, float | None]
|
dict[str, float | None] | None: an objective dict with the nadir
point values (which may be |
Source code in desdeo/problem/schema.py
get_objective
Return a copy of an Objective with the given symbol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
the symbol of the objective. |
required |
copy
|
bool
|
if True, return a copy of the objective, otherwise, return a reference. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
Objective | None
|
Objective | None: the copy of the objective with the given symbol, or |
Source code in desdeo/problem/schema.py
get_scalarization
Return a copy of a ScalarizationFunction with the given symbol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
the symbol of the scalarization function. |
required |
Returns:
| Type | Description |
|---|---|
ScalarizationFunction | None
|
ScalarizationFunction | None: the copy of the scalarization function with the given symbol, or |
Source code in desdeo/problem/schema.py
get_scenario_problem
Returns a new Problem with fields belonging to a specified scenario.
The new problem will have the fields objectives, constraints, extra_funcs,
and scalarization_funcs with only the entries that belong to the specified
scenario. The other entries will remain unchanged.
Note
Fields with their scenario_key being None are assumed to belong to all scenarios,
and are thus always included in each scenario.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_keys
|
str | list[str]
|
the key or keys of the scenario(s) we wish to get. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
(some of) the given |
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
a new problem with only the field that belong to the specified scenario. |
Source code in desdeo/problem/schema.py
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 | |
get_variable
Return a copy of a Variable with the given symbol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
the symbol of the variable. |
required |
Returns:
| Type | Description |
|---|---|
Variable | TensorVariable | None
|
Variable | TensorVariable | None: the copy of the variable with the given symbol,
or |
Source code in desdeo/problem/schema.py
load_json
classmethod
Load a Problem model stored in a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
path to file storing a Problem model in JSON format. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Problem |
Problem
|
the as defined in the data. |
Source code in desdeo/problem/schema.py
save_to_json
Save the Problem model in JSON format to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
path to the file the model should be saved to. |
required |
Source code in desdeo/problem/schema.py
set_default_scalarization_names
Check the scalarization functions for symbols with value 'None'.
If found, names them systematically 'scal_i', where 'i' is a running index stored in an instance attribute.
Source code in desdeo/problem/schema.py
update_ideal_and_nadir
update_ideal_and_nadir(
new_ideal: dict[str, VariableType | None] | None = None,
new_nadir: dict[str, VariableType | None] | None = None,
) -> Problem
Update the ideal and nadir values of the problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_ideal
|
dict[str, VariableType | None] | None
|
description |
None
|
new_nadir
|
dict[str, VariableType | None] | None
|
description |
None
|
Source code in desdeo/problem/schema.py
ScalarizationFunction
Bases: BaseModel
Model for scalarization of the problem.
Source code in desdeo/problem/schema.py
func
class-attribute
instance-attribute
func: list = Field(
description="Function representation of the scalarization. This is a JSON object that can be parsed into a function.Must be a valid MathJSON object. The symbols in the function must match the symbols defined for objective/variable/constant/extra function."
)
Function representation of the scalarization. This is a JSON object that can be parsed into a function. Must be a valid MathJSON object. The symbols in the function must match the symbols defined for objective/variable/constant/extra function.
is_convex
class-attribute
instance-attribute
is_convex: bool = Field(
description="Whether the function expression is convex or not (non-convex). Defaults to `False`.",
default=False,
)
Whether the function expression is convex or not (non-convex). Defaults to False.
is_linear
class-attribute
instance-attribute
is_linear: bool = Field(
description="Whether the function expression is linear or not. Defaults to `False`.",
default=False,
)
Whether the function expression is linear or not. Defaults to False.
is_twice_differentiable
class-attribute
instance-attribute
is_twice_differentiable: bool = Field(
description="Whether the function expression is twice differentiable or not. Defaults to `False`",
default=False,
)
Whether the function expression is twice differentiable or not. Defaults to False
name
class-attribute
instance-attribute
Name of the scalarization function.
scenario_keys
class-attribute
instance-attribute
scenario_keys: list[str] = Field(
description="Optional. The keys of the scenarios the scalarization function belongs to.",
default=None,
)
Optional. The keys of the scenarios the scalarization function belongs to.
symbol
class-attribute
instance-attribute
symbol: str | None = Field(
description="Optional symbol to represent the scalarization function. This may be used in UIs and visualizations.",
default=None,
)
Optional symbol to represent the scalarization function. This may be used
in UIs and visualizations. Defaults to None.
Simulator
Bases: BaseModel
Model for simulator data.
One of file or url must be provided, but not both.
Source code in desdeo/problem/schema.py
file
class-attribute
instance-attribute
file: Path | None = Field(
description="Path to a python file with the connection to simulators.",
default=None,
)
Path to a python file with the connection to simulators.
name
class-attribute
instance-attribute
name: str = Field(
description="Descriptive name of the simulator. This can be used in UI and visualizations."
)
Descriptive name of the simulator. This can be used in UI and visualizations.
parameter_options
class-attribute
instance-attribute
parameter_options: dict | None = Field(
description="Parameters to the simulator that are not decision variables, but affect the results.Format is similar to decision variables. Can be 'None'.",
default=None,
)
Parameters to the simulator that are not decision variables, but affect the results. Format is similar to decision variables. Can be 'None'.
url
class-attribute
instance-attribute
url: Url | None = Field(
description="Optional. URL to the simulator. A GET request to this URL should be used to evaluate solutions in batches.",
default=None,
)
Optional. A URL to the simulator. A GET request to this URL should be used to evaluate solutions in batches.
check_file_or_url
Ensure that either file or url is provided, but not both.
Source code in desdeo/problem/schema.py
TensorConstant
Bases: BaseModel
Model for a tensor containing constant values.
Source code in desdeo/problem/schema.py
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 | |
name
class-attribute
instance-attribute
name: str = Field(
description="Descriptive name of the tensor representing the values. E.g., 'distances'"
)
Descriptive name of the tensor representing the values. E.g., 'distances'
shape
class-attribute
instance-attribute
shape: list[int] = Field(
description="A list of the dimensions of the tensor, e.g., `[2, 3]` would indicate a matrix with 2 rows and 3 columns."
)
A list of the dimensions of the tensor, e.g., [2, 3] would indicate a matrix with 2 rows and 3 columns.
symbol
class-attribute
instance-attribute
symbol: str = Field(
description="Symbol to represent the constant. This will be used in the rest of the problem definition. Notice that the elements of the tensor will be represented with the symbol followed by indices. E.g., the first element of the third element of a 2-dimensional tensor, is represented by 'x_1_3', where 'x' is the symbol given to the TensorVariable. Note that indexing starts from 1."
)
Symbol to represent the constant. This will be used in the rest of the problem definition. Notice that the elements of the tensor will be represented with the symbol followed by indices. E.g., the first element of the third element of a 2-dimensional tensor, is represented by 'x_1_3', where 'x' is the symbol given to the TensorVariable. Note that indexing starts from 1.
values
class-attribute
instance-attribute
values: Tensor = Field(
description="A list of lists, with the elements representing the values of each constant element in the tensor. E.g., `[[5, 22, 0], [14, 5, 44]]`."
)
A list of lists, with the elements representing the initial values of each constant element in the tensor.
E.g., [[5, 22, 0], [14, 5, 44]].
__getitem__
Implements random access for TensorConstant.
Note
Indexing is assumed to start at 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
int | Tuple[int]
|
a single integer or tuple of integers. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Constant |
Constant
|
A new instance of Constant that has been setup with information found at the specified indices in the TensorConstant. |
Source code in desdeo/problem/schema.py
get_values
get_values() -> (
Iterable[VariableType | Iterable[VariableType]]
| Iterable[None, Iterable[None]]
)
Return the constant values as a Python iterable (e.g., list of list).
Source code in desdeo/problem/schema.py
to_constants
Flatten the tensor into a list of Constants.
Returns:
| Type | Description |
|---|---|
list[Constant]
|
list[Constant]: a list of Constants. |
Source code in desdeo/problem/schema.py
TensorVariable
Bases: BaseModel
Model for a tensor, e.g., vector variable.
Source code in desdeo/problem/schema.py
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 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 | |
initial_values
class-attribute
instance-attribute
initial_values: Tensor | VariableType | None = Field(
description="A list of lists, with the elements representing the initial values of each element. E.g., `[[1, 2, 3], [4, 5, 6]]`. If a single value is supplied, that value is assumed to be the initial value of each element. Defaults to None.",
default=None,
)
A list of lists, with the elements representing the initial values of
each element. E.g., [[1, 2, 3], [4, 5, 6]]. If a single value is
supplied, that value is assumed to be the initial value of each element.
Defaults to None.
lowerbounds
class-attribute
instance-attribute
lowerbounds: Tensor | None = Field(
description="A list of lists, with the elements representing the lower bounds of each element. E.g., `[[1, 2, 3], [4, 5, 6]]`. If a single value is supplied, that value is assumed to be the lower bound of each element. Defaults to None.",
default=None,
)
A list of lists, with the elements representing the lower bounds of each
element. E.g., [[1, 2, 3], [4, 5, 6]]. If a single value is supplied,
that value is assumed to be the lower bound of each element. Defaults to
None.
name
class-attribute
instance-attribute
name: str = Field(
description="Descriptive name of the variable. This can be used in UI and visualizations. Example: 'velocity'."
)
Descriptive name of the variable. This can be used in UI and visualizations. Example: 'velocity'.
shape
class-attribute
instance-attribute
shape: list[int] = Field(
description="A list of the dimensions of the tensor, e.g., `[2, 3]` would indicate a matrix with 2 rows and 3 columns."
)
A list of the dimensions of the tensor,
e.g., [2, 3] would indicate a matrix with 2 rows and 3 columns.
symbol
class-attribute
instance-attribute
symbol: str = Field(
description="Symbol to represent the variable. This will be used in the rest of the problem definition. Notice that the elements of the tensor will be represented with the symbol followed by indices. E.g., the first element of the third element of a 2-dimensional tensor, is represented by 'x_1_3', where 'x' is the symbol given to the TensorVariable. Note that indexing starts from 1."
)
Symbol to represent the variable. This will be used in the rest of the problem definition. Notice that the elements of the tensor will be represented with the symbol followed by indices. E.g., the first element of the third element of a 2-dimensional tensor, is represented by 'x_1_3', where 'x' is the symbol given to the TensorVariable. Note that indexing starts from 1.
upperbounds
class-attribute
instance-attribute
upperbounds: Tensor | VariableType | None = Field(
description="A list of lists, with the elements representing the upper bounds of each element. E.g., `[[1, 2, 3], [4, 5, 6]]`. If a single value is supplied, that value is assumed to be the upper bound of each element. Defaults to None.",
default=None,
)
A list of lists, with the elements representing the upper bounds of each
element. E.g., [[1, 2, 3], [4, 5, 6]]. If a single value is supplied,
that value is assumed to be the upper bound of each element. Defaults to
None.
variable_type
class-attribute
instance-attribute
variable_type: VariableTypeEnum = Field(
description="Type of the variable. Can be real, integer, or binary. Note that each element of a TensorVariable is assumed to be of the same type."
)
Type of the variable. Can be real, integer, or binary. Note that each element of a TensorVariable is assumed to be of the same type.
__getitem__
Implements random access for TensorVariable.
Note
Indexing is assumed to start at 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
int | Tuple[int]
|
a single integer or tuple of integers. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Variable |
Variable
|
A new instance of Variable that has been setup with information found at the specified indices in the TensorVariable. |
Source code in desdeo/problem/schema.py
get_initial_values
get_initial_values() -> (
Iterable[VariableType | Iterable[VariableType]]
| Iterable[None | Iterable[None]]
)
Return the initial values, if any, as a Python iterable (list of list).
Source code in desdeo/problem/schema.py
get_lowerbound_values
get_lowerbound_values() -> (
Iterable[VariableType | Iterable[VariableType]]
| Iterable[None | Iterable[None]]
)
Return the lowerbounds values, if any, as a Python iterable (list of list).
Source code in desdeo/problem/schema.py
get_upperbound_values
get_upperbound_values() -> (
Iterable[VariableType | Iterable[VariableType]]
| Iterable[None | Iterable[None]]
)
Return the upperbounds values, if any, as a Python iterable (list of list).
Source code in desdeo/problem/schema.py
to_variables
Flatten the tensor into a list of Variables.
Returns:
| Type | Description |
|---|---|
list[Variable]
|
list[Variable]: a list of Variables. |
Source code in desdeo/problem/schema.py
Url
Bases: BaseModel
Model for a URL.
Source code in desdeo/problem/schema.py
auth
class-attribute
instance-attribute
auth: tuple[str, str] | None = Field(
description="Optional. A tuple of username and password to be used for authentication when making requests to the URL.",
default=None,
)
Optional. A tuple of username and password to be used for authentication when making requests to the URL.
Variable
Bases: BaseModel
Model for a variable.
Source code in desdeo/problem/schema.py
initial_value
class-attribute
instance-attribute
initial_value: VariableType | None = Field(
description="Initial value of the variable. This is optional.",
default=None,
)
Initial value of the variable. This is optional. Defaults to None.
lowerbound
class-attribute
instance-attribute
Lower bound of the variable. Defaults to None.
name
class-attribute
instance-attribute
name: str = Field(
description="Descriptive name of the variable. This can be used in UI and visualizations. Example: 'velocity'."
)
Descriptive name of the variable. This can be used in UI and visualizations. Example: 'velocity'.
symbol
class-attribute
instance-attribute
symbol: str = Field(
description="Symbol to represent the variable. This will be used in the rest of the problem definition. It may also be used in UIs and visualizations. Example: 'v_1'."
)
Symbol to represent the variable. This will be used in the rest of the problem definition. It may also be used in UIs and visualizations. Example: 'v_1'.
upperbound
class-attribute
instance-attribute
Upper bound of the variable. Defaults to None.
VariableDomainTypeEnum
Bases: str, Enum
An enumerator for the possible variable type domains of a problem.
Source code in desdeo/problem/schema.py
continuous
class-attribute
instance-attribute
All variables are real valued.
integer
class-attribute
instance-attribute
All variables are integer or binary valued.
VariableTypeEnum
Bases: str, Enum
An enumerator for possible variable types.
Source code in desdeo/problem/schema.py
get_tensor_values
get_tensor_values(
values: Iterable[VariableType | Iterable[VariableType]]
| VariableType
| None,
) -> (
Iterable[VariableType | Iterable[VariableType]]
| VariableType
| None
)
Return the values for a given attribute as a nested Python list or single value.
Removes the 'List' entries from the JSON format to give a Python compatible list. If the values are a single value or None, then a single value or None is returned instead, respectively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
Iterable[VariableType | Iterable[VariableType]] | VariableType | None
|
the values that should be extracted as a Python list. |
required |
Returns:
| Type | Description |
|---|---|
Iterable[VariableType | Iterable[VariableType]] | VariableType | None
|
list[VariableType] | Iterable[list[VariableType]] | VariableType| None: a list with shape |
Source code in desdeo/problem/schema.py
parse_infix_to_func
Validator that checks if the 'func' field is of type str or list.
If str, then it is assumed the string represents the func in infix notation. The string is parsed in the validator. If list, then the func is assumed to be represented in Math JSON format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
Problem
|
the class of the pydantic model the validator is applied to. |
required |
v
|
str | list
|
The func to be validated. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
v is neither an instance of str or a list. |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
The func represented in Math JSON format. |
Source code in desdeo/problem/schema.py
parse_list_to_mathjson
Validator that makes sure a nested Python list is represented as tensor following the MathJSON convention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
TensorVariable
|
the class of the pydantic model the validator is applied to. |
required |
v
|
Tensor | VariableType | None
|
the nested lists to be validated. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
a tensor following the MathJSON conventions; or a single value or None, if v was assigned to one of these types. |
Source code in desdeo/problem/schema.py
parse_scenario_key_singleton_to_list
Validator that checks the type of a scenario key.
If the type is a list, it will be returned as it is. If it is a string, then a list with the single string is returned. Else, a ValueError is raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
Problem
|
the class of the pydantic model the validator is applied to. |
required |
v
|
str | list[str]
|
the scenario key, or keys, to be validated. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
raised when |
Returns:
| Type | Description |
|---|---|
list[str] | None
|
list[str]: a list with scenario keys. |
Source code in desdeo/problem/schema.py
tensor_custom_error_validator
tensor_custom_error_validator(
value: Any,
handler: ValidatorFunctionWrapHandler,
_info: ValidationInfo,
) -> Any
Custom error handler to simplify error messages related to recursive tensor types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
input value to be validated. |
required |
handler
|
ValidatorFunctionWrapHandler
|
handler to check the values. |
required |
_info
|
ValidationInfo
|
info related to the validation of the value. |
required |
Raises:
| Type | Description |
|---|---|
PydanticCustomError
|
when the value is an invalid tensor type. |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
a valid tensor. |
Source code in desdeo/problem/schema.py
JSON parser
desdeo.problem.json_parser
Defines a parser to parse multiobjective optimziation problems defined in a JSON format.
FormatEnum
Bases: str, Enum
Enumerates the supported formats the JSON format may be parsed to.
Source code in desdeo/problem/json_parser.py
MathParser
A class to instantiate MathJSON parsers.
Currently only parses MathJSON to polars expressions. Pyomo WIP.
Source code in desdeo/problem/json_parser.py
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 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 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 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 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 786 787 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 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 | |
__init__
Create a parser instance for parsing MathJSON notation into polars expressions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_format
|
FormatEnum
|
to which format a JSON representation should be parsed to. Defaults to "polars". |
'polars'
|
Source code in desdeo/problem/json_parser.py
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 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 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 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 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 786 787 788 | |
_parse_to_cvxpy
_parse_to_cvxpy(
expr: list | str | int | float,
callback: Callable[[str], cvxpyexpression],
) -> cvxpyexpression
Parses the MathJSON format recursively into a CVXPY expression.
CVXPY supports a much broader range of expressions compared to gurobipy, including exponentials, logarithms, and trigonometric functions. However, some operations still have restrictions due to DCP (Disciplined Convex Programming) rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr
|
list | str | int | float
|
a list with a Polish notation expression that describes a, e.g., ["Multiply", ["Sqrt", 2], "x2"] |
required |
callback
|
Callable
|
A function that can return a CVXPY expression associated with the correct model when called with symbol str. |
required |
Returns:
| Type | Description |
|---|---|
cvxpyexpression
|
Returns a CVXPY expression equivalent to the original expression. |
Source code in desdeo/problem/json_parser.py
_parse_to_gurobipy
_parse_to_gurobipy(
expr: list | str | int | float,
callback: Callable[[str], gpexpression | int | float],
) -> gpexpression | int | float
Parses the MathJSON format recursively into a gurobipy expression.
Gurobi only fundamentally supports linear and quadratic expressions, and this parser does not check that the inputs are valid. If you try to input something else, you will likely encounter an error at some point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr
|
list | str | int | float
|
a list with a Polish notation expression that describes a, e.g., ["Multiply", ["Sqrt", 2], "x2"] |
required |
callback
|
Callable
|
A function that can return a gurobipy expression associated with the correct model when called with symbol str. |
required |
Returns:
| Type | Description |
|---|---|
gpexpression | int | float
|
Returns a gurobipy expression (that can belong into one of multiple types) equivalent to the original |
gpexpression | int | float
|
expressions. |
gpexpression | int | float
|
All possible output types should be supported as parts of gurobipy constraints. gurobipy.GenExpr at |
gpexpression | int | float
|
least isn't supported as an objective function. |
Source code in desdeo/problem/json_parser.py
_parse_to_polars
Recursively parses JSON math expressions and returns a polars expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr
|
list
|
A list with a Polish notation expression that describes a, e.g., ["Multiply", ["Sqrt", 2], "x2"] |
required |
Raises:
| Type | Description |
|---|---|
ParserError
|
when a unsupported operator type is encountered. |
Returns:
| Type | Description |
|---|---|
Expr
|
pl.Expr: A polars expression that may be evaluated further. |
Source code in desdeo/problem/json_parser.py
_parse_to_pyomo
Parses the MathJSON format recursively into a Pyomo expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr
|
list | str | int | float
|
a list with a Polish notation expression that describes a, e.g., ["Multiply", ["Sqrt", 2], "x2"] |
required |
model
|
Model
|
a pyomo model with the symbols defined appearing in the expression. E.g., "x2" -> model.x2 must be defined. |
required |
Raises:
| Type | Description |
|---|---|
ParserError
|
when a unsupported operator type is encountered. |
Returns:
| Type | Description |
|---|---|
Expression
|
pyomo.Expression: returns a pyomo expression equivalent to the original expressions. |
Source code in desdeo/problem/json_parser.py
_parse_to_sympy
Parse the MathJSON format recursively into a sympy expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr
|
list | str | int | float | Basic
|
base call should be a list in Polish notation representing a mathematical expression. Recursion calls can be of various types. |
required |
Raises:
| Type | Description |
|---|---|
ParserError
|
when a unsupported operator type is encountered. |
Returns:
| Type | Description |
|---|---|
Basic
|
sp.Basic: a sympy expression that represents the original mathematical expression in the supplied MathJSON format. |
Source code in desdeo/problem/json_parser.py
ParserError
replace_str
Replace a target in list with a substitution recursively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lst
|
list or str
|
The list where the substitution is to be made. |
required |
target
|
str
|
The target of the substitution. |
required |
sub
|
list or str
|
The content to substitute the target. |
required |
Return
list or str: The list or str with the substitution.
Example
replace_str("["Max", "g_i", ["Add","g_i","f_i"]]]", "_i", "_1") ---> ["Max", "g_1", ["Add","g_1","f_1"]]]
Source code in desdeo/problem/json_parser.py
Infix parser
desdeo.problem.infix_parser
Defines parsers for parsing mathematical expression in an infix format and expressed as string.
Currently, mostly parses to MathJSON, e.g., "n / (1 + n)" -> ['Divide', 'n', ['Add', 1, 'n']].
InfixExpressionParser
A class for defining infix notation parsers.
Source code in desdeo/problem/infix_parser.py
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 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 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 | |
__init__
A parser for infix notation, e.g., the huma readable way of notating mathematical expressions.
The parser can parse infix notation stored in a string to different formats. For instance, "Cos(2 + f_1) - 7.2 + Max(f_2, -f_3)" is first parsed to the list: ['Cos', [[2, '+', 'f_1']]], '-', 7.2, '+', ['Max', ['f_2', ['-', 'f_3']]. Then, if parsed to the MathJSON format, it will be parsed to the list: [ [["Subtract", ["Cos", ["Add", 2, "f_1"]], ["Add", 7.2, ["Max", ["f_2", ["Negate", "f_3"]]]]]] ].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
The target format to parse an infix expression to. Currently only "MathJSON" is supported. Defaults to "MathJSON". |
'MathJSON'
|
Source code in desdeo/problem/infix_parser.py
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 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 | |
_remove_extra_brackets
Removes recursively extra brackets from a nested list that may have been left when parsing an expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lst
|
list
|
A (nested) list that needs extra bracket removal. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
A list with extra brackets removed. |
Source code in desdeo/problem/infix_parser.py
_to_math_json
Converts a list of expressions into a MathJSON compliant format.
The conversion happens recursively. Each list of recursed until a terminal character is reached. Terminal characters are integers (int), floating point numbers (float), or non-keyword strings (str). Keyword strings are reserved for operations, such as 'Cos' or 'Max'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parsed
|
list
|
A list possibly containing other lists. Represents a mathematical expression. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
A list representing a mathematical expression in a MathJSON compliant format. |
Source code in desdeo/problem/infix_parser.py
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 | |
parse
The method to call when parsing an infix expression in represented by a string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
str_expr
|
str
|
A string expression to be parsed. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
A list representing the parsed expression. |
Source code in desdeo/problem/infix_parser.py
Generic evaluator
desdeo.problem.evaluator
Defines a Polars-based evaluator.
PolarsEvaluator
A class for creating Polars-based evaluators for multiobjective optimization problems.
The evaluator is to be used with different optimizers. PolarsEvaluator is specifically for solvers that do not require an exact formulation of the problem, but rather work solely on the input and output values of the problem being solved. This evaluator might not be suitable for computationally expensive problems, or mixed-integer problems. This evaluator is suitable for many Python-based solvers.
Source code in desdeo/problem/evaluator.py
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 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 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 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 | |
__init__
__init__(
problem: Problem,
evaluator_mode: PolarsEvaluatorModesEnum = PolarsEvaluatorModesEnum.variables,
)
Create a Polars-based evaluator for a multiobjective optimization problem.
By default, the evaluator expects a set of decision variables to evaluate the given problem. However, if the problem is purely based on data (e.g., it represents an approximation of a Pareto optimal front), then the evaluator should be run in 'discrete' mode instead. In this mode, it will return the whole problem with all of its objectives, constraints, and scalarization functions evaluated with the current data representing the problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
The problem as a pydantic 'Problem' data class. |
required |
evaluator_mode
|
str
|
The mode of evaluator used to parse the problem into a format that can be evaluated. Default 'variables'. |
variables
|
Source code in desdeo/problem/evaluator.py
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 | |
_from_discrete_data
Evaluates the problem based on its discrete representation only.
Assumes that all the objective functions in the problem are of type 'data-based'. In this case, the problem is evaluated based on its current discrete representation. Therefore, no decision variable values are expected.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: a polars dataframe with the evaluation results. |
Source code in desdeo/problem/evaluator.py
_polars_evaluate
Evaluate the problem with the given decision variable values utilizing a polars dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xs
|
DataFrame | dict[str, list[float | int | bool]]
|
a Polars dataframe or
dict with the decision variable symbols as the columns (keys)
followed by the corresponding decision variable values stored in
an array (list). The symbols must match the symbols defined for
the decision variables defined in the |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: the polars dataframe with the computed results. |
Note
At least self.objective_expressions must be defined before calling this method.
Source code in desdeo/problem/evaluator.py
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 | |
_polars_evaluate_flat
Evaluate the problem with flattened variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xs
|
DataFrame | dict[str, list[float | int | bool]]
|
a polars dataframe
or dict with flattened variables.
E.g., if the original problem has a tensor variable 'X' with shape (2,2),
then the input is expected to have entries with columns (keys) 'X_1_1', 'X_1_2',
'X_2_1', and 'X_2_2'. The input is rebuilt and passed to
|
required |
Note
Each flattened variable is assumed to contain the same number of samples.
This means that if the entry 'X_1_1' of xs is, for example
[1,2,3], this means that 'X_1_1' and all the other flattened
variables have three samples. This means also that the original
problem will be evaluated with a tensor variable with shape (2,2)
and three samples,
e.g., 'X=[[[1, 1], [1,1]], [[2, 2], [2, 2]], [[3, 3], [3, 3]]]'.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: a dataframe with the original problem's evaluated functions. |
Source code in desdeo/problem/evaluator.py
_polars_init
Initialization of the evaluator for parser type 'polars'.
Source code in desdeo/problem/evaluator.py
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 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 | |
PolarsEvaluatorError
PolarsEvaluatorModesEnum
Bases: str, Enum
Defines the supported modes for the PolarsEvaluator.
Source code in desdeo/problem/evaluator.py
discrete
class-attribute
instance-attribute
Indicates that the problem is defined by discrete decision variable vector and objective vector pairs and those should be evaluated. In this mode, the evaluator does not expect any decision variables as arguments when evaluating.
mixed
class-attribute
instance-attribute
Indicates that the problem has analytical and simulator and/or surrogate based objectives, constraints and extra functions. In this mode, the evaluator only handles data-based and analytical functions. For data-based objectives, it assumes that the variables are to be evaluated by finding the closest variables values in the data compare to the input, and evaluating the result to be the matching objective function values that match to the closest variable values found. The evaluator should expect decision variables vectors and evaluate the problem with them.
VariableDimensionEnum
Bases: str, Enum
An enumerator for the possible dimensions of the variables of a problem.
Source code in desdeo/problem/evaluator.py
find_closest_points
find_closest_points(
xs: DataFrame,
discrete_df: DataFrame,
variable_symbols: list[str],
objective_symbol: list[str],
) -> pl.DataFrame
Finds the closest points between the variable columns in xs and discrete_df.
For each row in xs, compares the variable_symbols columns and find the closest
point in discrete_df. Returns the objective value in the objective_symbol column in
discrete_df for each variable defined in xs, where the objective value
corresponds to the closest point of each variable in xs compared to discrete_df.
Both xs and discrete_df must have the columns variable_symbols. discrete_df must
also have the column objective_symbol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xs
|
DataFrame
|
a polars dataframe with the variable values we are
interested in finding the closest corresponding variable values in
|
required |
discrete_df
|
DataFrame
|
a polars dataframe to compare the rows in |
required |
variable_symbols
|
list[str]
|
the names of the columns with decision variable values. |
required |
objective_symbol
|
str
|
the name of the column in |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: a dataframe with the columns |
Source code in desdeo/problem/evaluator.py
variable_dimension_enumerate
Return a VariableDimensionEnum based on the problems variables' dimensions.
This is needed as different evaluators and solvers can handle different dimensional variables.
If there are no TensorVariables in the problem, will return scalar. If there are, at the highest, one dimensional TensorVariables, will return vector. Else, there is at least a TensorVariable with a higher dimension, will return tensor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
The problem being solved or evaluated. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
VariableDimensionEnum |
VariableDimensionEnum
|
The enumeration of the problems variable dimensions. |
Source code in desdeo/problem/evaluator.py
Pyomo evaluator
desdeo.problem.pyomo_evaluator
Defines an evaluator compatible with the Problem JSON format and transforms it into a Pyomo model.
PyomoEvaluator
Defines an evaluator that transforms an instance of Problem into a pyomo model.
Source code in desdeo/problem/pyomo_evaluator.py
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 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 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 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 | |
__init__
Initializes the evaluator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem to be transformed in a pyomo model. |
required |
Source code in desdeo/problem/pyomo_evaluator.py
evaluate
evaluate(
xs: dict[
str,
float | int | bool | Iterable[float | int | bool],
],
) -> dict[
str,
float
| int
| bool
| list[dict[str, float | int | bool]],
]
Evaluate the current pyomo model with the given decision variable values.
Warning
This should not be used for actually solving the pyomo model! For debugging mostly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xs
|
dict[str, float | int | bool | Iterable[float | int | bool]]
|
a dict with the decision variable symbols
as the keys followed by the corresponding decision variable values, which can also
be represented by a list for multiple values. The symbols
must match the symbols defined for the decision variables defined in the |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float | int | bool | list[dict[str, float | int | bool]]]
|
dict | list[dict]: the results of evaluating the pyomo model with its variable values set to the values found in xs. |
Source code in desdeo/problem/pyomo_evaluator.py
get_values
Get the values from the pyomo model in dict.
The keys of the dict will be the symbols defined in the problem utilized to initialize the evaluator.
Returns:
| Type | Description |
|---|---|
dict[str, float | int | bool]
|
dict[str, float | int | bool]: a dict with keys equivalent to the symbols defined in self.problem. |
Source code in desdeo/problem/pyomo_evaluator.py
init_constants
Add constants to a pyomo model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
problem from which to extract the constants. |
required |
model
|
Model
|
the pyomo model to add the constants to. |
required |
Raises:
| Type | Description |
|---|---|
PyomoEvaluatorError
|
when the domain of a constant cannot be figured out. |
Returns:
| Type | Description |
|---|---|
Model
|
pyomo.Model: the pyomo model with the constants added as attributes. |
Source code in desdeo/problem/pyomo_evaluator.py
init_constraints
Add constraint expressions to a pyomo model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem from which to extract the constraint function expressions. |
required |
model
|
Model
|
the pyomo model to add the exprssions to. |
required |
Raises:
| Type | Description |
|---|---|
PyomoEvaluatorError
|
when an unsupported constraint type is encountered. |
Returns:
| Type | Description |
|---|---|
Model
|
pyomo.Model: the pyomo model with the constraint expressions added as pyomo Constraints. |
Source code in desdeo/problem/pyomo_evaluator.py
init_extras
Add extra function expressions to a pyomo model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
problem from which the extract the extra function expressions. |
required |
model
|
Model
|
the pyomo model to add the extra function expressions to. |
required |
Returns:
| Type | Description |
|---|---|
Model
|
pyomo.Model: the pyomo model with the expressions added as attributes. |
Source code in desdeo/problem/pyomo_evaluator.py
init_objectives
Add objective function expressions to a pyomo model.
Does not yet add any actual pyomo objectives, only the expressions of the objectives. A pyomo solved must add the appropiate pyomo objective before solving.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
problem from which to extract the objective function expresions. |
required |
model
|
Model
|
the pyomo model to add the expressions to. |
required |
Returns:
| Type | Description |
|---|---|
Model
|
pyomo.Model: the pyomo model with the objective expressions added as pyomo Objectives. The objectives are deactivated by default. |
Source code in desdeo/problem/pyomo_evaluator.py
init_scalarizations
Add scalrization expressions to a pyomo model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem from which to extract thescalarization function expressions. |
required |
model
|
Model
|
the pyomo model to add the expressions to. |
required |
Returns:
| Type | Description |
|---|---|
Model
|
pyomo.Model: the pyomo model with the scalarization expressions addedd as pyomo Objectives. The objectives are deactivated by default. Scalarization functions are always minimized. |
Source code in desdeo/problem/pyomo_evaluator.py
init_variables
Add variables to the pyomo model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
problem from which to extract the variables. |
required |
model
|
Model
|
the pyomo model to add the variables to. |
required |
Raises:
| Type | Description |
|---|---|
PyomoEvaluator
|
when a problem in extracting the variables is encountered. I.e., the bounds of the variables are incorrect or of a non supported type. |
Returns:
| Type | Description |
|---|---|
Model
|
pyomo.Model: the pyomo model with the variables added as attributes. |
Source code in desdeo/problem/pyomo_evaluator.py
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 | |
set_optimization_target
Creates a minimization objective from the target attribute of the pyomo model.
The attribute name of the pyomo objective will be target + _objective, e.g., 'f_1' will become 'f_1_objective'. This is done so that the original f_1 expressions attribute does not get reassigned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
an str representing a symbol. |
required |
Raises:
| Type | Description |
|---|---|
PyomoEvaluatorError
|
the given target was not an attribute of the pyomo model. |
Source code in desdeo/problem/pyomo_evaluator.py
Simulator evaluator
desdeo.problem.simulator_evaluator
Evaluators are defined to evaluate simulator based and surrogate based objectives, constraints and extras.
EvaluatorError
SimulatorEvaluator
A class for creating evaluators for simulator based and surrogate based objectives, constraints and extras.
Source code in desdeo/problem/simulator_evaluator.py
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 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 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 | |
__init__
__init__(
problem: Problem,
params: dict[str, dict] | ProviderParams | None = None,
surrogate_paths: dict[str, Path] | None = None,
)
Creating an evaluator for simulator based and surrogate based objectives, constraints and extras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
The problem as a pydantic 'Problem' data class. |
required |
params
|
dict[str, dict]
|
Parameters for the different simulators used in the problem. Given as dict with the simulators' symbols as keys and the corresponding simulator parameters as a dict as values. Defaults to None. |
None
|
surrogate_paths
|
dict[str, Path]
|
A dictionary where the keys are the names of the objectives, constraints and extra functions and the values are the paths to the surrogate models saved on disk. The names of the objectives, constraints and extra functions should match the names of the objectives, constraints and extra functions in the problem JSON. Defaults to None. |
None
|
Source code in desdeo/problem/simulator_evaluator.py
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 | |
_evaluate_simulator
Evaluate the problem for the given decision variables using the problem's simulators.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xs
|
dict[str, list[int | float]]
|
The decision variables for which the functions are to be evaluated. Given as a dictionary with the decision variable symbols as keys and a list of decision variable values as the values. The length of the lists is the number of samples and each list should have the same length (same number of samples). |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: The objective, constraint and extra function values for the given decision variables as a polars dataframe. The symbols of the objectives, constraints and extra functions are the column names and the length of the columns is the number of samples. Will return those objective, constraint and extra function values that are gained from simulators listed in the problem object. |
Source code in desdeo/problem/simulator_evaluator.py
_evaluate_surrogates
Evaluate the problem for the given decision variables using the surrogate models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xs
|
dict[str, list[int | float]]
|
The decision variables for which the functions are to be evaluated. Given as a dictionary with the decision variable symbols as keys and a list of decision variable values as the values. The length of the lists is the number of samples and each list should have the same length (same number of samples). |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: The values of the evaluated objectives, constraints and extra functions as a polars dataframe. The uncertainty prediction values are also returned. If a model does not provide uncertainty predictions, then they are set as NaN. |
Source code in desdeo/problem/simulator_evaluator.py
_load_surrogates
Load the surrogate models from disk and store them within the evaluator.
This is used during initialization of the evaluator or when the analyst wants to replace the current surrogate models with other models. However if a new model is trained after initialization of the evaluator, the problem JSON should be updated with the new model paths and the evaluator should be re-initialized. This can happen with any solver that does model management.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
surrogate_paths
|
dict[str, Path]
|
A dictionary where the keys are the names of the objectives, constraints and extra functions and the values are the paths to the surrogate models saved on disk. The names of the objectives should match the names of the objectives in the problem JSON. At the moment the supported file format is .skops (through skops.io). TODO: if skops.io used, should be added to pyproject.toml. |
None
|
Source code in desdeo/problem/simulator_evaluator.py
evaluate
Evaluate the functions for the given decision variables.
Evaluates analytical, simulation based and surrogate based functions. For now, the evaluator assumes that there are no data based objectives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xs
|
dict[str, list[int | float]]
|
The decision variables for which the functions are to be evaluated. Given as a dictionary with the decision variable symbols as keys and a list of decision variable values as the values. The length of the lists is the number of samples and each list should have the same length (same number of samples). |
required |
flat
|
bool
|
whether the valuation is done using flattened variables or not. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: polars dataframe with the evaluated function values. |
Source code in desdeo/problem/simulator_evaluator.py
Utilities
desdeo.problem.utils
Various utilities used across the framework related to the Problem formulation.
ProblemUtilsError
Bases: Exception
Raised when an exception occurs in one of the utils function.
Raised when an exception occurs in one of the utils functions defined in the Problem module.
flatten_variable_dict
Flatten a dictionary representing variable values of an instance of Problem into a numpy array.
Flattens a dictionary representing variable values of an instance of Problem into a numpy array.
The flattening follows a C-like order. Support the flattening of both Variable and TensorVariable
types. Note that it is assumed that no more than one value is defined for each symbol in variable_dict
that correspond to the required shape of the underlying variable type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem instance the decision variables are associated with. |
required |
variable_dict
|
dict[str, float | list]
|
a dictionary with its keys being the symbols
of the variables defined in the instance of |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
the |
TypeError
|
unsupported variable type encountered in the variables defined in the
instance of |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: a 1D numpy array with the variable values unflattened in C-like order. |
Source code in desdeo/problem/utils.py
get_ideal_dict
Return a dict representing a problem's ideal point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem with the ideal point. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
dict[str, float]: key are objective funciton symbols, values are ideal values. |
Source code in desdeo/problem/utils.py
get_nadir_dict
Return a dict representing a problem's nadir point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem with the nadir point. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
dict[str, float]: key are objective funciton symbols, values are nadir values. |
Source code in desdeo/problem/utils.py
numpy_array_to_objective_dict
Takes a numpy array with objective function values and return a dict.
The reverse of objective_dict_to_numpy_array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the numpy array represents an objective vector of. |
required |
numpy_array
|
ndarray
|
the objective vector as a numpy array. The array is squeezed, i.e., axes or length one are removed: [[42]] -> [42]. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
dict[str, float]: a dict with keys being objective function symbols and value being objective function values. |
Source code in desdeo/problem/utils.py
objective_dict_to_numpy_array
Takes a dict with an objective vector and returns a numpy array.
Takes a dict with the keys being objective function symbols and the values being the corresponding objective function values. Returns a numpy array with the objective function values in the same order they have been defined in the original problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem the objective dict belongs to. |
required |
objective_dict
|
dict[str, float]
|
the dict with the objective function values. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: a numpy array with the objective function values in the order they are present in problem. |
Source code in desdeo/problem/utils.py
tensor_constant_from_dataframe
tensor_constant_from_dataframe(
df: DataFrame,
name: str,
symbol: str,
n_rows: int,
column_names: list[str],
) -> TensorConstant
Create a TensorConstant from a Polars dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
a Polars dataframe with at least the columns in |
required |
name
|
str
|
name attribute of the created TensorConstant. |
required |
symbol
|
str
|
symbol attribute of the created TensorConstant. |
required |
n_rows
|
int
|
the number of rows to read from the dataframe. |
required |
column_names
|
list[str]
|
the column names in the dataframe from which the constant values will be picked. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
TensorConstant |
TensorConstant
|
A TensorConstant instance with values taken from the a given
Polars dataframe. The shape of the TensorConstant will be
( |
Note
In the argument shape the first element must be either less or equal to the
number of rows in df. The second element in shape must be equal
to the number of element in column_names.
Source code in desdeo/problem/utils.py
unflatten_variable_array
Unflatten a numpy array representing decision variable values.
Unflatten a numpy array that represent decision variable values. It is assumed
that the unflattened values follow a C-like order when it comes to unflattening
values for TensorVariables. Note that var_array must be of dimension 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
the problem instance the decision variables are associated with. |
required |
var_array
|
ndarray
|
a flat 1D array of numerical values representing decision variable values. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
IndexError
|
|
TypeError
|
unsupported variable type encountered in the variables defined in the
instance of |
Returns:
| Type | Description |
|---|---|
dict[str, float | list]
|
dict[str, float | list]: a dict with keys equal to the symbols of the variables
defined in the |