geneva.actions.strategy¶
-
class
strategy.Strategy(in_actions, out_actions, environment_id=None)¶ Bases:
object-
__init__(in_actions, out_actions, environment_id=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
act_on_packet(packet, logger, direction='out')¶ Runs the strategy on a given scapy packet.
-
init_from_scratch(num_in_trees, num_out_trees, num_in_actions, num_out_actions, disabled=None)¶ Initializes this individual by drawing random actions.
-
initialize(logger, num_in_trees, num_out_trees, num_in_actions, num_out_actions, seed, disabled=None)¶ Initializes a new strategy object randomly.
-
mutate(logger)¶ Top level mutation function for a strategy. Simply mutates the out and in trees.
-
mutate_dir(trees, direction, logger)¶ Mutates a list of trees. Requires the direction the tree operates on (in or out).
-
pretty_print()¶
-
pretty_str_forest(forest)¶ Returns a string representation of a given forest (inbound or outbound)
-
run_on_packet(packet, logger, direction)¶ Runs the strategy on a given packet given the forest direction.
-
str_forest(forest)¶ Returns a string representation of a given forest (inbound or outbound)
-
-
strategy.do_mate(forest1, forest2)¶ Performs mating between two given forests (lists of trees). With 80% probability, a random tree from each forest are mated, otherwise, a random tree is swapped between them.
-
strategy.mate(ind1, ind2, indpb)¶ Executes a uniform crossover that modify in place the two individuals. The attributes are swapped according to the indpb probability.
-
strategy.swap_one(forest1, forest2)¶ Swaps a random tree from forest1 and forest2.
It picks a random element within forest1 and a random element within forest2, chooses a random index within each forest, and inserts the random element