gadget_model
¶
The decision cactus model consists of multiple gadgets.
-
class
vnep_approx.gadget_model.
AbstractGadget
(name, request, in_node, out_nodes)¶ An abstract gadget used by
GadgetContainerRequest
.Gadgets are connected by sharing a common node. Nodes that are designated to be used by multiple gadgets are called interface nodes.
A gadget has exactly one in-node and one or multiple out-nodes.
-
adapt_model_objective_according_to_local_profits
(obj_expr)¶
-
extend_load_constraints
(constraint_dict, nodes_handled_by_other_gadgets)¶
-
extend_mapping_by_own_solution
(mapping, load, nodes_handled_by_other_gadgets)¶
-
generate_constraints
(model)¶
-
generate_flow_induction_at_root_constraint
(model)¶
-
generate_variables
(model)¶
-
in_node
= None¶ in-node of the gadget
-
interface_nodes
= None¶ all interface nodes (in- and out-nodes)
-
name
= None¶ gadget name
-
out_nodes
= None¶ out-nodes of the gadget
-
reduce_flow_on_last_returned_mapping
(used_flow)¶
-
request
= None¶ the request graph of the gadget
-
set_substrate
(substrate)¶
-
substrate
= None¶ the substrate
-
verify_mapping
(mapping)¶ Perform certain sanity checks usually performed by the
alib.solutions.Mapping
class.Parameters: mapping (solutions.Mapping) – the request mapping Returns: a list of out-nodes that are mapped
-
-
class
vnep_approx.gadget_model.
CactusGadget
(name, request, in_node, out_nodes, parent_name=None)¶ -
adapt_model_objective_according_to_local_profits
(obj_expr)¶
-
extend_load_constraints
(constraint_dict, nodes_handled_by_other_gadgets)¶
-
extend_mapping_by_own_solution
(mapping, load, nodes_handled_by_other_gadgets)¶
-
generate_constraints
(model)¶
-
generate_flow_induction_at_root_constraint
(model)¶
-
generate_variables
(model)¶
-
reduce_flow_on_last_returned_mapping
(used_flow)¶
-
verify_mapping
(mapping)¶ For a cactus gadget, each node and each edge must be mapped.
Parameters: mapping – Returns:
-
-
class
vnep_approx.gadget_model.
DecisionGadget
(name, request, in_node, out_nodes)¶ -
adapt_model_objective_according_to_local_profits
(obj_expr)¶
-
extend_load_constraints
(constraint_dict, nodes_handled_by_other_gadgets)¶
-
extend_mapping_by_own_solution
(mapping, load, nodes_handled_by_other_gadgets)¶
-
generate_constraints
(model)¶
-
generate_flow_induction_at_root_constraint
(model)¶
-
generate_variables
(model)¶
-
reduce_flow_on_last_returned_mapping
(used_flow)¶
-
verify_mapping
(mapping)¶
-
-
exception
vnep_approx.gadget_model.
DecisionModelError
¶
-
class
vnep_approx.gadget_model.
ExtendedDecisionGraph
(parent_gadget)¶
-
class
vnep_approx.gadget_model.
GadgetContainerRequest
(name, profit, rounding_threshold=0.001)¶ A request that consists of several gadgets.
The gadgets form a tree, there is exactly one root gadget and cycles are forbidden. Gadgets are connected by sharing a common node. Nodes that are designated to be used by multiple gadgets are called interface nodes.
-
adapt_objective
(obj_expr)¶ Adapt the objective.
Parameters: obj_expr (gurobipy.LinExpr) – the objective expression Returns: the modified objective expression Return type: gurobipy.LinExpr
-
add_gadget
(gadget)¶ Add a gadget to the request.
Parameters: gadget (AbstractGadget) – the new gadget
-
add_node_flow_var
(model, i, u)¶ Return a node flow variable of a model.
Creates the variable if it does not exist.
Parameters: - model (gurobipy.Model) – LP model
- i (str) – request node
- u (str) – substrate node
Returns: the node flow variable
Return type: gurobipy.Var
-
check_and_update
()¶ Check if gadgets form a tree and set the root gadget.
Raises: GadgetError – if a check fails
-
check_gadget_tree
()¶ Check if the gadgets are connected as a tree.
Raises: GadgetError – if a check fails
-
check_nodes
()¶ Check interface nodes and inner nodes.
Raises: GadgetError – if a check fails
-
extract_mappings
()¶ Generator that yields mappings of this
GadgetContainerRequest
.Returns: yields tuples of (mapping, flow_value, load_dictionary)
-
gadgets
= None¶ gadgets by name
-
gadgets_by_in_nodes
= None¶ map in-nodes to a corresponding list of gadgets
-
generate_constraints
(model)¶ Generate LP constraints for each gadget and induce flow at root gadget.
Parameters: model (gurobipy.Model) – LP model
-
generate_variables
(model)¶ Generate LP variables for each gadget.
Parameters: model (gurobipy.Model) – LP model
-
get_gadget_tree_graph
()¶
-
name
= None¶ request name
-
profit
= None¶ request profit
-
root_gadget
= None¶ the root gadget
-
rounding_threshold
= None¶ rounding threshold
-
set_substrate
(substrate)¶
-
update_root
()¶ Update root gadget.
A root gadget is a gadget with in-nodes that are not out-nodes of other gadgets.
Raises: GadgetError – if there is not exactly one root gadget
-
verify_request_mapping
(mapping)¶ Verify a request mapping.
Parameters: mapping (solutions.Mapping) – the request mapping
-
-
exception
vnep_approx.gadget_model.
GadgetError
¶
-
class
vnep_approx.gadget_model.
GadgetModelCreator
(scenario, gurobi_settings=None, optimization_callback=None, lp_output_file=None, potential_iis_filename=None, logger=None)¶ -
create_constraints_other_than_bounding_loads_by_capacities
()¶
-
create_objective
()¶
-
create_variables_other_than_embedding_decision_and_request_load
()¶
-
post_process_fractional_computation
()¶
-
post_process_integral_computation
()¶
-
recover_fractional_solution_from_variables
()¶
-
recover_integral_solution_from_variables
()¶
-
-
exception
vnep_approx.gadget_model.
MappingCombinationError
¶