Real
This module contains operators defined to work with problems
whose dtype
s are real numbers (e.g. torch.float32
).
CosynePermutation
¶
Bases: CopyingOperator
Representation of permutation operation on a SolutionBatch.
For each decision variable index, a permutation operation across all or a subset of solutions, is performed. The result is returned on a new SolutionBatch. The original SolutionBatch remains unmodified.
Reference:
F.Gomez, J.Schmidhuber, R.Miikkulainen (2008).
Accelerated Neural Evolution through Cooperatively Coevolved Synapses
Journal of Machine Learning Research 9, 937-965
Source code in evotorch/operators/real.py
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 |
|
obj_index
property
¶
Objective index according to which the operator will run.
If permute_all
was given as True, objectives are irrelevant, in which case
obj_index
is returned as None.
If permute_all
was given as False, the relevant obj_index
is provided
as an integer.
__init__(problem, obj_index=None, *, permute_all=False)
¶
__init__(...)
: Initialize the CosynePermutation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
Problem
|
The problem object to work on. |
required |
obj_index
|
Optional[int]
|
The index of the objective according to which the
candidates for permutation will be selected.
Can be left as None if the problem is single-objective,
or if |
None
|
permute_all
|
bool
|
Whether or not to apply permutation on the entire population, instead of using a selective permutation. |
False
|
Source code in evotorch/operators/real.py
GaussianMutation
¶
Bases: CopyingOperator
Gaussian mutation operator.
Follows the algorithm description in:
Sean Luke, 2013, Essentials of Metaheuristics, Lulu, second edition
available for free at http://cs.gmu.edu/~sean/book/metaheuristics/
Source code in evotorch/operators/real.py
__init__(problem, *, stdev, mutation_probability=None)
¶
__init__(...)
: Initialize the GaussianMutation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
Problem
|
The problem object to work with. |
required |
stdev
|
float
|
The standard deviation of the Gaussian noise to apply on each decision variable. |
required |
mutation_probability
|
Optional[float]
|
The probability of mutation, for each decision variable. If None, the value of this argument becomes 1.0, which means that all of the decision variables will be affected by the mutation. Defatuls to None |
None
|
Source code in evotorch/operators/real.py
MultiPointCrossOver
¶
Bases: CrossOver
Representation of a multi-point cross-over operator.
When this operator is applied on a SolutionBatch, a tournament selection technique is used for selecting parent solutions from the batch, and then those parent solutions are mated via cutting from a random position and recombining. The result of these recombination operations is a new SolutionBatch, containing the children solutions. The original SolutionBatch stays unmodified.
This operator is a generalization over the standard cross-over operators OnePointCrossOver and TwoPointCrossOver. In more details, instead of having one or two cutting points, this operator is configurable in terms of how many cutting points is desired. This generalized cross-over implementation follows the procedure described in:
Sean Luke, 2013, Essentials of Metaheuristics, Lulu, second edition
available for free at http://cs.gmu.edu/~sean/book/metaheuristics/
Source code in evotorch/operators/real.py
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 |
|
__init__(problem, *, tournament_size, obj_index=None, num_points=None, num_children=None, cross_over_rate=None)
¶
__init__(...)
: Initialize the MultiPointCrossOver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
Problem
|
The problem object to work on. |
required |
tournament_size
|
int
|
What is the size (or length) of a tournament when selecting a parent candidate from a population |
required |
obj_index
|
Optional[int]
|
Objective index according to which the selection will be done. |
None
|
num_points
|
Optional[int]
|
Number of cutting points for the cross-over operator. |
None
|
num_children
|
Optional[int]
|
Optionally a number of children to produce by the
cross-over operation.
Not to be used together with |
None
|
cross_over_rate
|
Optional[float]
|
Optionally expected as a real number between
0.0 and 1.0. Specifies the number of cross-over operations
to perform. 1.0 means |
None
|
Source code in evotorch/operators/real.py
OnePointCrossOver
¶
Bases: MultiPointCrossOver
Representation of a one-point cross-over operator.
When this operator is applied on a SolutionBatch, a tournament selection technique is used for selecting parent solutions from the batch, and then those parent solutions are mated via cutting from a random position and recombining. The result of these recombination operations is a new SolutionBatch, containing the children solutions. The original SolutionBatch stays unmodified.
Let us assume that the two of the parent solutions that were selected for the cross-over operation are as follows:
For recombining parents a
and b
, a cutting point is first randomly
selected. In the case of this example, let us assume that the cutting
point was chosen as the point between the items with indices 2 and 3:
Considering this selected cutting point, the two children c
and d
will be constructed from a
and b
like this:
Note that the recombination procedure explained above is be done on all of the parents chosen from the given SolutionBatch, in a vectorized manner. For each chosen pair of parents, the cutting points will be sampled differently.
Source code in evotorch/operators/real.py
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 |
|
__init__(problem, *, tournament_size, obj_index=None, num_children=None, cross_over_rate=None)
¶
__init__(...)
: Initialize the OnePointCrossOver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
Problem
|
The problem object to work on. |
required |
tournament_size
|
int
|
What is the size (or length) of a tournament when selecting a parent candidate from a population |
required |
obj_index
|
Optional[int]
|
Objective index according to which the selection will be done. |
None
|
num_children
|
Optional[int]
|
Optionally a number of children to produce by the
cross-over operation.
Not to be used together with |
None
|
cross_over_rate
|
Optional[float]
|
Optionally expected as a real number between
0.0 and 1.0. Specifies the number of cross-over operations
to perform. 1.0 means |
None
|
Source code in evotorch/operators/real.py
PolynomialMutation
¶
Bases: CopyingOperator
Representation of the polynomial mutation operator.
Follows the algorithm description in:
Kalyanmoy Deb, Santosh Tiwari (2008).
Omni-optimizer: A generic evolutionary algorithm for single
and multi-objective optimization
The operator ensures a non-zero probability of generating offspring in the entire search space by dividing the space into two regions and using independent probability distributions associated with each region. In contrast, the original polynomial mutation formulation may render the mutation ineffective when the decision variable approaches its boundary.
Source code in evotorch/operators/real.py
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 |
|
__init__(problem, *, eta=None, mutation_probability=None)
¶
__init__(...)
: Initialize the PolynomialMutation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
Problem
|
The problem object to work with. |
required |
eta
|
Optional[float]
|
The index for polynomial mutation; a large value gives a higher
probability for creating near-parent solutions, whereas a small
value allows distant solutions to be created.
If not specified, |
None
|
mutation_probability
|
Optional[float]
|
The probability of mutation, for each decision variable. If not specified, all variables will be mutated. |
None
|
Source code in evotorch/operators/real.py
SimulatedBinaryCrossOver
¶
Bases: CrossOver
Representation of a simulated binary cross-over (SBX).
When this operator is applied on a SolutionBatch, a tournament selection technique is used for selecting parent solutions from the batch, and then those parent solutions are mated via SBX. The generated children solutions are given in a new SolutionBatch. The original SolutionBatch stays unmodified.
Reference:
Kalyanmoy Deb, Hans-Georg Beyer (2001).
Self-Adaptive Genetic Algorithms with Simulated Binary Crossover.
Source code in evotorch/operators/real.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 |
|
__init__(problem, *, tournament_size, eta, obj_index=None, num_children=None, cross_over_rate=None)
¶
__init__(...)
: Initialize the SimulatedBinaryCrossOver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
Problem
|
Problem object to work with. |
required |
tournament_size
|
int
|
What is the size (or length) of a tournament when selecting a parent candidate from a population. |
required |
eta
|
float
|
The crowding index, expected as a float. Bigger eta values result in children closer to their parents. |
required |
obj_index
|
Optional[int]
|
Objective index according to which the selection will be done. |
None
|
num_children
|
Optional[int]
|
Optionally a number of children to produce by the
cross-over operation.
Not to be used together with |
None
|
cross_over_rate
|
Optional[float]
|
Optionally expected as a real number between
0.0 and 1.0. Specifies the number of cross-over operations
to perform. 1.0 means |
None
|
Source code in evotorch/operators/real.py
TwoPointCrossOver
¶
Bases: MultiPointCrossOver
Representation of a two-point cross-over operator.
When this operator is applied on a SolutionBatch, a tournament selection technique is used for selecting parent solutions from the batch, and then those parent solutions are mated via cutting from a random position and recombining. The result of these recombination operations is a new SolutionBatch, containing the children solutions. The original SolutionBatch stays unmodified.
Let us assume that the two of the parent solutions that were selected for the cross-over operation are as follows:
For recombining parents a
and b
, two cutting points are first randomly
selected. In the case of this example, let us assume that the cutting
point were chosen as the point between the items with indices 1 and 2,
and between 3 and 4:
a: [ a0 , a1 | a2 , a3 | a4 , a5 ]
b: [ b0 , b1 | b2 , b3 | b4 , b5 ]
| |
^ ^
First Second
cutting cutting
point point
Given these two cutting points, the two children c
and d
will be
constructed from a
and b
like this:
Note that the recombination procedure explained above is be done on all of the parents chosen from the given SolutionBatch, in a vectorized manner. For each chosen pair of parents, the cutting points will be sampled differently.
Source code in evotorch/operators/real.py
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 |
|
__init__(problem, *, tournament_size, obj_index=None, num_children=None, cross_over_rate=None)
¶
__init__(...)
: Initialize the TwoPointCrossOver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
Problem
|
The problem object to work on. |
required |
tournament_size
|
int
|
What is the size (or length) of a tournament when selecting a parent candidate from a population |
required |
obj_index
|
Optional[int]
|
Objective index according to which the selection will be done. |
None
|
num_children
|
Optional[int]
|
Optionally a number of children to produce by the
cross-over operation.
Not to be used together with |
None
|
cross_over_rate
|
Optional[float]
|
Optionally expected as a real number between
0.0 and 1.0. Specifies the number of cross-over operations
to perform. 1.0 means |
None
|