Exemple #1
0
from pyage.core.stop_condition import StepLimitStopCondition

from pyage.elect.el_crossover import Crossover
from pyage.elect.el_eval import kApprovalEvaluator
from pyage.elect.el_init import EmasInitializer, root_agents_factory, VotesInitializer
from pyage.elect.el_mutation import Mutation
from pyage.elect.naming_service import NamingService

votes = [[5, 4, 3, 2, 1], [5, 2, 3, 4, 1], [3, 4, 5, 2, 1], [1, 2, 3, 5, 4],
         [3, 1, 4, 5, 2], [5, 2, 1, 4, 3]]
votes_nr = len(votes)
logger = logging.getLogger(__name__)
agents_count = 5
logger.debug("EMAS, %s agents", agents_count)

agents = root_agents_factory(agents_count, AggregateAgent)
agg_size = 40
aggregated_agents = EmasInitializer(votes=votes,
                                    candidate=1,
                                    size=agg_size,
                                    energy=40)
stop_condition = lambda: StepLimitStopCondition(10000)

emas = EmasService

minimal_energy = lambda: 10
reproduction_minimum = lambda: 90
migration_minimum = lambda: 120
newborn_energy = lambda: 100
transferred_energy = lambda: 40
Exemple #2
0
logger = logging.getLogger(__name__)

chosen_candidate = 2
k_approval_coeff = 2
number_of_cand = 5
number_of_votes = 30
votes, init_c_places = VotesInitializer(number_of_cand,number_of_votes, chosen_candidate,0)()
logger.info("Initial votes:\n%s", "\n".join(map(str,votes)))

votes_nr = len(votes)


agents_count = 2
logger.debug("EMAS, %s agents", agents_count)
agents = root_agents_factory(agents_count, AggregateAgent)

stop_condition = lambda: StepLimitStopCondition(20000)

agg_size = 40
aggregated_agents = EmasInitializer(votes=votes, candidate = chosen_candidate, size=agg_size, energy=40 )

emas = EmasService

minimal_energy = lambda: 10
reproduction_minimum = lambda: 100
migration_minimum = lambda: 120
newborn_energy = lambda: 100
transferred_energy = lambda: 40

budget = 0