Data update
This commit is contained in:
parent
796d366b97
commit
35bcdeebf8
504 changed files with 7045 additions and 610 deletions
|
|
@ -27,39 +27,39 @@ extension evoHelper
|
|||
|
||||
class EvoAlgorithm : Enumerator
|
||||
{
|
||||
object theTarget;
|
||||
object theCurrent;
|
||||
object theVariantCount;
|
||||
object _target;
|
||||
object _current;
|
||||
object _variantCount;
|
||||
|
||||
constructor new(s,count)
|
||||
{
|
||||
theTarget := s;
|
||||
theVariantCount := count.toInt();
|
||||
_target := s;
|
||||
_variantCount := count.toInt();
|
||||
}
|
||||
|
||||
get() = theCurrent;
|
||||
get Value() = _current;
|
||||
|
||||
bool next()
|
||||
{
|
||||
if (nil == theCurrent)
|
||||
{ theCurrent := theTarget.Length.randomString(); ^ true };
|
||||
if (nil == _current)
|
||||
{ _current := _target.Length.randomString(); ^ true };
|
||||
|
||||
if (theTarget == theCurrent)
|
||||
if (_target == _current)
|
||||
{ ^ false };
|
||||
|
||||
auto variants := Array.allocate(theVariantCount).populate:(x => theCurrent.mutate:P );
|
||||
auto variants := Array.allocate(_variantCount).populate:(x => _current.mutate:P );
|
||||
|
||||
theCurrent := variants.sort:(a,b => a.fitnessOf:Target > b.fitnessOf:Target ).at:0;
|
||||
_current := variants.sort:(a,b => a.fitnessOf:Target > b.fitnessOf:Target ).at:0;
|
||||
|
||||
^ true
|
||||
}
|
||||
|
||||
reset()
|
||||
{
|
||||
theCurrent := nil
|
||||
_current := nil
|
||||
}
|
||||
|
||||
enumerable() => theTarget;
|
||||
enumerable() => _target;
|
||||
}
|
||||
|
||||
public program()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue