def create_classic_params(agents_count, agent_population, time_matrix, stages): JOBS_COUNT = len(time_matrix[0]) return { "agents": generate_agents("flowshop", agents_count, Agent), "initializer": lambda: PermutationInitializer(JOBS_COUNT, agent_population), "evaluation": lambda: FlowShopEvaluation(time_matrix), "operators": lambda: [ FirstHalfSwapsCrossover(), PermutationMutation(2) if stages == 0 else MemeticPermutationMutation(stages, 8, 2), FlowShopEvaluation(time_matrix), TournamentSelection(agent_population, agent_population) ], "migration": NoMigration }
def create_classic_params(agents_count, agent_population, time_matrix, incoming_problems_feed, distortion_factor): JOBS_COUNT = len(time_matrix[0]) return { "agents": masters_factory(1, l_conf.window_time, time_matrix, distortion_factor), "manufacture": lambda: Manufacture(len(time_matrix)), "timeKeeper": lambda: TimeKeeper(1, 1), "slaves": generate_agents("flowshop", agents_count, Agent), "initializer": lambda: PermutationInitializer(JOBS_COUNT, agent_population), "evaluation": lambda: FlowShopEvaluation(time_matrix), "operators": lambda: [ FirstHalfSwapsCrossover(), PermutationMutation(2), FlowShopEvaluation(time_matrix), TournamentSelection(agent_population, agent_population) ], "migration": NoMigration, "problem_provider": lambda: ProblemProvider(incoming_problems_feed) }
from pyage.core.locator import RandomLocator from pyage.core.migration import Pyro4Migration from pyage.core.statistics import TimeStatistics from pyage.core.stop_condition import StepLimitStopCondition from pyage.solutions.evolution.crossover import AverageFloatCrossover from pyage.solutions.evolution.evaluation import FloatRastriginEvaluation from pyage.solutions.evolution.initializer import FloatInitializer from pyage.solutions.evolution.mutation import UniformFloatMutation from pyage.solutions.evolution.selection import TournamentSelection logger = logging.getLogger(__name__) agents_count = int(os.environ['AGENTS']) logger.debug("AGGREGATE, %s agents", agents_count) agents = generate_agents("agent", agents_count, AggregateAgent) aggregated_agents = unnamed_agents(2, Agent) stop_condition = lambda: StepLimitStopCondition(100) size = 500 operators = lambda: [ FloatRastriginEvaluation(), TournamentSelection(size=55, tournament_size=30), AverageFloatCrossover(size=size), UniformFloatMutation(probability=0.05, radius=1) ] initializer = lambda: FloatInitializer(500, size, -10, 10) address_provider = address.SequenceAddressProvider
from pyage.core.migration import Pyro4Migration from pyage.core.stats.statistics import TimeStatistics from pyage.core.stop_condition import StepLimitStopCondition from pyage.solutions.evolution.crossover import AverageFloatCrossover from pyage.solutions.evolution.evaluation import FloatRastriginEvaluation from pyage.solutions.evolution.initializer import FloatInitializer from pyage.solutions.evolution.mutation import UniformFloatMutation from pyage.solutions.evolution.selection import TournamentSelection logger = logging.getLogger(__name__) agents_count = int(os.environ['AGENTS']) logger.debug("AGGREGATE, %s agents", agents_count) agents = generate_agents("agent", agents_count, AggregateAgent) aggregated_agents = unnamed_agents(2, Agent) stop_condition = lambda: StepLimitStopCondition(100) size = 500 operators = lambda: [FloatRastriginEvaluation(), TournamentSelection(size=55, tournament_size=30), AverageFloatCrossover(size=size), UniformFloatMutation(probability=0.05, radius=1)] initializer = lambda: FloatInitializer(500, size, -10, 10) address_provider = address.SequenceAddressProvider migration = Pyro4Migration locator = RandomLocator ns_hostname = lambda: os.environ['NS_HOSTNAME']
[10, 15, 20, 9, 9], [30, 9, 11, 5, 6], [12, 13, 14, 15, 16], [16, 15, 13, 11, 10] ] JOBS_COUNT = len(time_matrix()[0]) AGENTS_COUNT = 5 POPULATION_SIZE = 20 WINDOW_TIME = 250 machines_number = len(time_matrix()) timeKeeper = lambda: TimeKeeper(1, 1) manufacture = lambda: Manufacture(machines_number) stop_condition = lambda: StepLimitStopCondition(1000) slaves = generate_agents("flowshop", AGENTS_COUNT, Agent) agents = masters_factory(AGENTS_COUNT, WINDOW_TIME, time_matrix()) evaluation = lambda: FlowShopEvaluation(time_matrix()) initializer = lambda: PermutationInitializer(JOBS_COUNT, POPULATION_SIZE) operators = lambda: [ FirstHalfSwapsCrossover(), PermutationMutation(2), evaluation(), TournamentSelection(POPULATION_SIZE, POPULATION_SIZE)] address_provider = address.SequenceAddressProvider stats = GanttStatistics migration = NoMigration
from pyage.solutions.evolution.selection import TournamentSelection time_matrix = lambda: [ [54, 83, 15, 71, 77, 36, 53, 38, 27, 87, 76, 91, 14, 29, 12, 77, 32, 87, 68, 94], [79, 3, 11, 99, 56, 70, 99, 60, 5, 56, 3, 61, 73, 75, 47, 14, 21, 86, 5, 77], [16, 89, 49, 15, 89, 45, 60, 23, 57, 64, 7, 1, 63, 41, 63, 47, 26, 75, 77, 40], [66, 58, 31, 68, 78, 91, 13, 59, 49, 85, 85, 9, 39, 41, 56, 40, 54, 77, 51, 31], [58, 56, 20, 85, 53, 35, 53, 41, 69, 13, 86, 72, 8, 49, 47, 87, 58, 18, 68, 28] ] JOBS_COUNT = len(time_matrix()[0]) PROCESSORS_COUNT = len(time_matrix()) AGENTS_COUNT = 50 POPULATION_SIZE = 20 agents = generate_agents("openshop", AGENTS_COUNT, Agent) stop_condition = lambda: TimeLimitStopCondition(10) evaluation = lambda: OpenShopEvaluation(time_matrix()) initializer = lambda: PermutationInitializer(JOBS_COUNT * PROCESSORS_COUNT, POPULATION_SIZE) operators = lambda: [ FirstHalfSwapsCrossover(), PermutationMutation(2), evaluation(), TournamentSelection(POPULATION_SIZE, POPULATION_SIZE)] address_provider = address.SequenceAddressProvider migration = NoMigration locator = RandomLocator