alib.scenariogeneration¶
-
class
alib.scenariogeneration.AbstractNodeMappingRestrictionGenerator(logger)¶ -
apply(scenario_parameters, scenario)¶ Apply this task to the scenario object, given the scenario_parameters.
Parameters: - scenario_parameters –
- scenario –
Returns:
-
generate_and_apply_restrictions(scenario, raw_parameters)¶
-
generate_restrictions_single_request(req, substrate, raw_parameters)¶
-
-
class
alib.scenariogeneration.AbstractProfitCalculator(logger)¶ Base class for the profit generation task.
-
apply(scenario_parameters, scenario)¶ Apply this task to the scenario object, given the scenario_parameters.
Parameters: - scenario_parameters –
- scenario –
Returns:
-
generate_and_apply_profits(scenario, raw_parameters)¶
-
-
class
alib.scenariogeneration.AbstractRequestGenerator(logger=None)¶ Base class for the request generation task. Subclasses should implement the generate_request method defined below, which should return an object of the type datamodel.Request.
-
apply(scenario_parameters, scenario)¶ Apply this task to the scenario object, given the scenario_parameters.
Parameters: - scenario_parameters –
- scenario –
Returns:
-
generate_request(name, raw_parameters, substrate)¶
-
generate_request_dictionary(raw_parameters, substrate, base_name='vnet_{id}', normalize=False)¶
-
generate_request_list(raw_parameters, substrate, base_name='vnet_{id}', normalize=False)¶
-
normalize_resource_footprint(raw_parameters, requests, substrate)¶
-
register_data_manager_dict(data_manager_dict)¶
-
verify_substrate_has_sufficient_capacity(request, substrate)¶
-
-
class
alib.scenariogeneration.CactusRequestGenerator(logger=None)¶ Generate request topologies with the cactus graph property.
First, a random tree is generated according to the “layers” and “branching_distribution” scenario parameters.
layers: an integer giving the depth of the treebranching_distribution: a list of floating point numbers, which specifies a probability distribution for the number of children: If branching_distribution[i] = p_i, then each node in the tree has probability p_i of having i many children. The elements of the branching_distribution list must add up to 1.0.Warning: if a non-zero value is assigned to the first list element of the branching distribution, the tree depth may be reduced and the request graph may degenerate to a single node
After generating the tree, edges are randomly added to the request graph in a way that maintains the cactus property according to the “max_cycles” and “probability” parameters:
max_cycles: An integer giving a hard upper limit on the number of cycles that may be includedprobability: The algorithm repeatedly picks two random nodes from a subtree of the graph and draws an edge between them according to this parameter.
To estimate the number of nodes/edges (i.e. the resource footprint), a number of graphs is generated according to the “iterations” parameter.
-
class
AdvancedInspectionResult¶
-
EXPECTED_PARAMETERS= ['probability', 'number_of_requests', 'node_resource_factor', 'edge_resource_factor', 'min_number_of_nodes', 'max_number_of_nodes', 'branching_distribution', 'layers', 'max_cycles', 'iterations', 'fix_root_mapping', 'fix_leaf_mapping', 'normalize', 'arbitrary_edge_orientations']¶
-
ROOT= 'root'¶
-
advanced_empirical_number_of_nodes_edges(raw_parameters, substrate, iterations)¶
-
expected_number_of_nodes_in_tree()¶
-
generate_request(name, raw_parameters, substrate)¶
-
class
alib.scenariogeneration.CustomizedDataManager(address=None, authkey=None, serializer='pickle')¶ -
UndirectedGraphStorage(*args, **kwds)¶
-
-
exception
alib.scenariogeneration.ExperimentSpecificationError¶
-
class
alib.scenariogeneration.ExponentialRequestGenerator(logger=None)¶ Generate requests, where the number of nodes is sampled from an exponential distribution. Edges are connected at random according to the “probability” parameter.
Warning: Request graphs may have multiple components.
-
EXPECTED_PARAMETERS= ['number_of_requests', 'min_number_of_nodes', 'max_number_of_nodes', 'probability', 'node_resource_factor', 'edge_resource_factor', 'normalize']¶
-
generate_request(name, raw_parameters, substrate)¶
-
-
class
alib.scenariogeneration.NeighborhoodSearchRestrictionGenerator(logger=None)¶ Generate node placement restrictions by traversing the substrate in a breadth-first-search, starting at a randomly chosen “center” node. Whenever a substrate node supporting the node type is encountered, it is added to the “allowed_nodes” list.
The number of allowed nodes is sampled from an exponential distribution with the mean “potential_nodes_factor”.
potential_nodes_factor: Floating point number between 0.0 and 1.0.
-
EXPECTED_PARAMETERS= ['potential_nodes_factor']¶
-
generate_restrictions_single_request(req, substrate, raw_parameters)¶
-
-
class
alib.scenariogeneration.OptimalEmbeddingProfitCalculator(logger=None)¶ Calculate profits for all new requests in a scenario.
The profit for each request is the cost of its optimal embedding in the empty substrate, multiplied by the profit_factor parameter.
-
EXPECTED_PARAMETERS= ['profit_factor', 'timelimit']¶
-
generate_and_apply_profits(scenario, raw_parameters)¶
-
-
class
alib.scenariogeneration.RandomEmbeddingProfitCalculator(logger=None)¶ Calculate profits for all new requests in a scenario.
The profit for each request is the average cost of random embeddings in the empty substrate, multiplied by the “profit_factor” parameter.
The “iterations” parameter defines the number of random embeddings.
-
EXPECTED_PARAMETERS= ['profit_factor', 'iterations']¶
-
generate_and_apply_profits(scenario, raw_parameters)¶
-
-
exception
alib.scenariogeneration.RequestGenerationError¶
-
class
alib.scenariogeneration.ScenarioGenerator(threads=1)¶ Class to generate scenarios according to a specific parameter space.
-
generate_scenarios(scenario_parameter_space, repetition=1, scenario_index_offset=0)¶
-
-
exception
alib.scenariogeneration.ScenarioGeneratorError¶
-
class
alib.scenariogeneration.ScenarioParameterContainer(scenario_parameter_room, scenario_index_offset=0)¶ Represents a set of scenarios accessible via its parameters according to which the scenarios (instances) were generated.
-
fill_reverselookup_dict(sp, currentindex)¶
-
generate_all_scenario_parameter_combinations(repetition=1)¶ Given a dictionary representing the parameter space of an experiment, this function generates a list of parameter dictionaries, each of which can be used by the ScenarioGenerator to generate a single scenario.
Parameters: repetition – how many times each scenario will be builded (Default value = 1) Returns: A list of dictionaries, where each dictionary specifies a single scenario {generation_task -> {strategy_name -> {class -> {parameter -> [values]}}}}
-
init_reverselookup_dict()¶
-
make_values_immutable(raw_parameter)¶ This converts list parameters to tuples, e.g. branching_distribution: [[0.0, 0.5, 0.5]] becomes branching_distribution: [(0.0, 0.5, 0.5)]
Parameters: raw_parameter – Returns:
-
merge_with_other_scenario_parameter_container(other)¶ self.scenarioparameter_room = self.scenario_list = [] self.scenario_parameter_combination_list = [] self.scenario_parameter_dict = {} self.scenario_triple = {}
-
-
exception
alib.scenariogeneration.ScenarioParameterError¶
-
class
alib.scenariogeneration.ScenariogenerationTask(logger)¶ Base class for all steps in the scenario generation process. Currently it just handles the instantiation of the logger.
-
apply(scenario_parameters, scenario)¶ Apply this task to the scenario object, given the scenario_parameters.
Parameters: - scenario_parameters –
- scenario –
Returns:
-
-
class
alib.scenariogeneration.ServiceChainGenerator(logger=None)¶ Generate a Request that represents a Service Chain. The Request consists of a chain connecting a source “s” and target “t”, with additional edges added at random between the intermediate nodes, according to the “probability” scenario parameter. If “probability” is set to 0.0, a datamodel.LinearRequest object will be generated instead.
The source and target nodes are each mapped to a single substrate node.
-
EXPECTED_PARAMETERS= ['number_of_requests', 'min_number_of_nodes', 'max_number_of_nodes', 'probability', 'node_resource_factor', 'edge_resource_factor']¶
-
SOURCE_NODE= 's'¶
-
TARGET_NODE= 't'¶
-
generate_request(name, raw_parameters, substrate)¶
-
-
exception
alib.scenariogeneration.SubstrateReaderError¶
-
class
alib.scenariogeneration.TopologyZooReader(path='/Users/yetian/GitHub/ml_vnep_20/alib/alib/data/topologyZoo', logger=None)¶ Casts topology zoo instances as substrates during the generation process
-
EXPECTED_PARAMETERS= ['topology', 'node_types', 'edge_capacity', 'node_cost_factor', 'node_capacity', 'node_type_distribution', 'fog_model_costs']¶
-
apply(scenario_parameters, scenario)¶ Apply this task to the scenario object, given the scenario_parameters.
Parameters: - scenario_parameters –
- scenario –
Returns:
-
read_from_yaml(raw_parameters, include_location=False)¶
-
read_substrate(raw_parameters)¶
-
-
class
alib.scenariogeneration.TreewidthRequestGenerator(logger=None)¶ Generate request topologies of bounded treewidth using a mandatory UndirectedGraphStorage. Specifically, for graphs of treewidth 1 simple trees are generated while for higher treewidths the graphs from the UndirectedGraphStorage are used.
To specify an UndirectedGraphStorage, a pickle has to be given in the yaml-file as a data manager like data_managers:
UndirectedGraphStorage: <location_of_pickle>-
EXPECTED_PARAMETERS= ['number_of_requests', 'treewidth', 'min_number_of_nodes', 'max_number_of_nodes', 'node_resource_factor', 'edge_resource_factor', 'normalize']¶
-
generate_request(name, raw_parameters, substrate)¶
-
-
class
alib.scenariogeneration.UniformEmbeddingRestrictionGenerator(logger=None)¶ Generate node placement restrictions by randomly choosing a fixed ratio of the substrate nodes with suitable type. At least one substrate node is always chosen. If the request node dictionary of a node contains the parameter “number_of_allowed_nodes”, then this number is used instead.
Example: Assuming a substrate with 20 nodes, 10 of which can support type “t1” and potential_nodes_factor=0.4. Then, each request node of type “t1” is mapped to a random sample of 4 out of the 10 supporting nodes.
potential_nodes_factor: Floating point number between 0.0 and 1.0.
-
EXPECTED_PARAMETERS= ['potential_nodes_factor']¶
-
generate_restrictions_single_request(req, substrate, raw_parameters)¶
-
-
class
alib.scenariogeneration.UniformRequestGenerator(logger=None)¶ Generate requests, where the number of nodes is sampled from a uniform distribution. Edges are connected at random according to the “probability” parameter.
Warning: Request graphs may have multiple components.
-
EXPECTED_PARAMETERS= ['number_of_requests', 'min_number_of_nodes', 'max_number_of_nodes', 'probability', 'variability', 'node_resource_factor', 'edge_resource_factor', 'normalize']¶
-
generate_request(name, raw_parameters, substrate)¶
-
-
alib.scenariogeneration.build_scenario(i_sp_tup)¶ Build a single scenario based on the scenario parameters.
This function performs the scenario generation steps in the correct order:
- generation of the substrate topologies (including capacities) from the topology zoo
- generation of the request topologies (including resource demands)
- (optional) restrict the allowed node mappings
- (optional) calculate each request’s profit. The scenario’s objective will be set to profit maximization if a profit calculator is given, otherwise it defaults to cost minimization.
The function also creates a separate logger to maintain readability when the scenario generation is done by multiple threads.
Parameters: i_sp_tup – Tuple containing the index of the scenario as first, and the scenario parameters as returned by ScenarioParameterContainer.generate_all_scenario_parameter_combinations as second element. Returns:
-
alib.scenariogeneration.convert_topology_zoo_gml_to_yml(gml_path, yml_path, consider_disconnected)¶
-
alib.scenariogeneration.generate_pickle_from_yml(parameter_file, scenario_out_pickle, threads=1, scenario_index_offset=0)¶ main function to generate a scenario pickle from a parameter file
Parameters: - parameter_file – yaml file detailing the scenario parameterds
- scenario_out_pickle – output file to write the pickle to
- threads – number of threads that shall be used for generating the scenarios
- scenario_index_offset – offset of scenario indicices to enable merging of distinct scenario storages
Returns: None
-
alib.scenariogeneration.haversine(lon1, lat1, lon2, lat2)¶ Calculate the great circle distance between two points on the earth (specified in decimal degrees)
-
alib.scenariogeneration.instantiate_class_from_name_space_dicts(class_name, class_kwargs_dict, names_space_dicts)¶
-
alib.scenariogeneration.summarize_topology_zoo_graphs(min_number_nodes=10, max_number_nodes=100)¶
-
alib.scenariogeneration.verify_completeness_of_scenario_parameters(scenario_parameter_space)¶ Checks scenario parameters for completeness and raises a warnings and exceptions if necessary.
Parameters: scenario_parameter_space – Returns: nothing