# coding=utf-8
# Copyright 2021 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Regularized Evolution controller from PyGlove. Similar to NEAT."""
import numpy as np
import pyglove as pg
from es_enas.controllers import base_controller


class RegularizedEvolutionController(base_controller.BaseController):
  """Regularized Evolution Controller."""

  def __init__(self, dna_spec, batch_size,
               **kwargs):
    """Initialization. See base class for more details."""

    super().__init__(dna_spec, batch_size)
    population_size = self._batch_size
    tournament_size = int(np.sqrt(population_size))

    self._controller = pg.generators.RegularizedEvolution(
        population_size=population_size,
        tournament_size=tournament_size,
        mutator=pg.generators.evolution_mutators.Uniform())  # pytype: disable=wrong-arg-types  # gen-stub-imports
    self._controller.setup(self._dna_spec)

@@ -1168,20 +1168,19 @@
  pg.
-generators.R
+evolution.r
 egul
@@ -1177,33 +1177,34 @@
 tion.regularized
-E
+_e
 volution(%0A      
@@ -1302,19 +1302,8 @@
 =pg.
-generators.
 evol
@@ -1307,17 +1307,17 @@
 volution
-_
+.
 mutators
@@ -1327,16 +1327,18 @@
 iform())
+  
   # pyty

Replace deprecated PyGlove symbols to new ones.