<reponame>sansbacon/pangadfs<filename>pangadfs/base.py<gh_stars>1-10
# gadfs/gadfs/base.py
# -*- coding: utf-8 -*-
# Copyright (C) 2020 <NAME>
# Licensed under the MIT License

import abc
import logging


class CrossoverBase(metaclass=abc.ABCMeta):
    """Base class for crossover plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def crossover(self, *args, **kwargs):
        """Implement crossover."""


class FitnessBase(metaclass=abc.ABCMeta):
    """Base class for fitness plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def fitness(self, *args, **kwargs):
        """Implement fitness."""


class MutateBase(metaclass=abc.ABCMeta):
    """Base class for crossover plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def mutate(self, *args, **kwargs):
        """Mutates population at given mutation rate."""


class OptimizeBase(metaclass=abc.ABCMeta):
    """Base class for optimize plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def optimize(self, *args, **kwargs):
        """Implements optimize."""


class PenaltyBase(metaclass=abc.ABCMeta):
    """Base class for penalty plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def penalty(self, *args, **kwargs):
        """Calculates penalty for population fitness."""


class PopulateBase(metaclass=abc.ABCMeta):
    """Base class for populate plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def populate(self, *args, **kwargs):
        """Creates initial population from pool."""


class PoolBase(metaclass=abc.ABCMeta):
    """Base class for pool plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def pool(self, *args, **kwargs):
        """Implement pool."""


class PospoolBase(metaclass=abc.ABCMeta):
    """Base class for pospool plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def pospool(self, *args, **kwargs):
        """Implement pospool."""


class SelectBase(metaclass=abc.ABCMeta):
    """Base class for select plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def select(self, *args, **kwargs):
        """Implement select."""


class ValidateBase(metaclass=abc.ABCMeta):
    """Base class for validate plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def validate(self, *args, **kwargs):
        """Implement validate."""

# gadfs/gadfs/base.py
# -*- coding: utf-8 -*-
# Copyright (C) 2020 <NAME>
# Licensed under the MIT License

import abc
import logging


class CrossoverBase(metaclass=abc.ABCMeta):
    """Base class for crossover plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def crossover(self, *args, **kwargs):
        """Implement crossover."""


class FitnessBase(metaclass=abc.ABCMeta):
    """Base class for fitness plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def fitness(self, *args, **kwargs):
        """Implement fitness."""


class MutateBase(metaclass=abc.ABCMeta):
    """Base class for crossover plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def mutate(self, *args, **kwargs):
        """Mutates population at given mutation rate."""


class OptimizeBase(metaclass=abc.ABCMeta):
    """Base class for optimize plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def optimize(self, *args, **kwargs):
        """Implements optimize."""


class PenaltyBase(metaclass=abc.ABCMeta):
    """Base class for penalty plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def penalty(self, *args, **kwargs):
        """Calculates penalty for population fitness."""


class PopulateBase(metaclass=abc.ABCMeta):
    """Base class for populate plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def populate(self, *args, **kwargs):
        """Creates initial population from pool."""


class PoolBase(metaclass=abc.ABCMeta):
    """Base class for pool plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def pool(self, *args, **kwargs):
        """Implement pool."""


class PospoolBase(metaclass=abc.ABCMeta):
    """Base class for pospool plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def pospool(self, *args, **kwargs):
        """Implement pospool."""


class SelectBase(metaclass=abc.ABCMeta):
    """Base class for select plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def select(self, *args, **kwargs):
        """Implement select."""


class ValidateBase(metaclass=abc.ABCMeta):
    """Base class for validate plugins."""

    def __init__(self):
        logging.getLogger(__name__).addHandler(logging.NullHandler())

    @abc.abstractmethod
    def validate(self, *args, **kwargs):
        """Implement validate."""
# gadfs/gadfs/base.py # -*- coding: utf-8 -*- # Copyright (C) 2020 <NAME> # Licensed under the MIT License Base class for crossover plugins. Implement crossover. Base class for fitness plugins. Implement fitness. Base class for crossover plugins. Mutates population at given mutation rate. Base class for optimize plugins. Implements optimize. Base class for penalty plugins. Calculates penalty for population fitness. Base class for populate plugins. Creates initial population from pool. Base class for pool plugins. Implement pool. Base class for pospool plugins. Implement pospool. Base class for select plugins. Implement select. Base class for validate plugins. Implement validate.