class RoundIntegerVariables(object):
Constructor: RoundIntegerVariables(options, round_integer_variables)
Round integer variables of solutions at the end of ask via
the round_population method and provide an archive to retrieve the
unrounded solutions with unrounded_population at the beginning of tell.
Also catch possibly changed solutions, depending on the parameters
passed to unrounded_population.
| Method | __init__ |
CMAOptions, bool, bool passed from cma.evolution_strategy module |
| Method | round |
round integer variables of solutions in pop_pheno and store |
| Method | unrounded |
revert round_population of solutions and return a new list |
| Instance Variable | archive |
Undocumented |
| Instance Variable | count |
Undocumented |
| Instance Variable | params |
Undocumented |
| Method | _catch |
catch modified solutions to revert their rounding too and/or |
| Method | _round |
round integer variables in solution if self._active. |
| Property | _active |
check 'round_integer_variables' parameter and |
round integer variables of solutions in pop_pheno and store
the original solutions in self.archive. pop_pheno should be a
list of arrays. When pop_pheno is an array, it is overwritten
and its original values may be lost.
By design, fixed variables are never changed (they were removed from the _pheno_integer_variables index list too). Hence they are not rounded either.
revert round_population of solutions and return a new list
when integer variables and archived solutions are present,
otherwise return solutions as is.
If revert_modfied, try to retrieve the nonrounded versions of
solutions even when they were modified between ask and tell.
This means that the modification is ignored in tell, while it
might have been used to compute the fitness.
Truncate the archive if necessary.
Details: this method is entirely ignorant about whether or how
solutions were rounded or transformed. However, it calls
_catch_modified which uses round_integer_variables and
_round_int_variables to compute a delta of an unexpected
modification to avoid unnecessary warnings when the delta is zero.
catch modified solutions to revert their rounding too and/or
warn of inconcistencies. This should normally do nothing as the
archive should be empty. Elements of popped_solutions are the
nonrounded versions of solutions and may be reassigned (which
changes the reference when it is a list, but the content when it
is an ndarray).
Modifications between storing and retrieving a solution are found by comparing to the unhashed key which only reflects inplace modifications.
Uses round_integer_variables which is an argument of the class
instance constructor and then ._round_int_variables to compute a
delta to warn only when the delta is nonzero.
TODO: instead of using ._round_int_variables pass an optional
transformation making this much more generic.