hots.allocation
Provide resource allocation related functions to handle this problem.
- hots.allocation.change_df_max(my_instance, c_id, max_c)[source]
Change the DataFrame (resources values) after changing max.
- Parameters:
my_instance (Instance) – The Instance object of the current run
c_id (str) – ID of container to change values
max_c (float) – New bound value for c_id data
- hots.allocation.change_max_bound(my_instance, config, min_time)[source]
Change max possible resource usage by containers.
- Parameters:
my_instance (Instance) – The Instance object of the current run
config (Dict) – Current HOTS run parameters
min_time (int) – T0 of current time window
- hots.allocation.check_constraints(my_instance, working_df_indiv, config)[source]
Check if allocation constraints are satisfied or not.
- Parameters:
my_instance (Instance) – The Instance object of the current run
working_df_indiv (pd.DataFrame) – Dataframe with current window individual data
config (Dict) – Current HOTS run parameters
- Returns:
True if all constraints are satisfied, False otherwise
- Return type:
bool
- hots.allocation.get_abs_goal_load(my_instance, config)[source]
Get the load goal in absolute value.
- Parameters:
my_instance (Instance) – The Instance object of the current run
config (Dict) – Current HOTS run parameters
- Returns:
Load value to achieve from parameters
- Return type:
float
- hots.allocation.get_max_by_node(df_indiv)[source]
Get the max possible usage of every container, by node.
- Parameters:
df_indiv (pd.DataFrame) – Dataframe storing individual data
- Returns:
Max container value for each node
- Return type:
Dict
- hots.allocation.get_total_max(max_by_node)[source]
Get the total amount of max resources.
- Parameters:
max_by_node (Dict) – Dict object of max container value in each node
- Returns:
Sum of every container max value from each node
- Return type:
float
- hots.allocation.is_max_goal_ok(current_max_by_node, max_goal)[source]
Check is the max usage objective is satisfied.
- Parameters:
current_max_by_node (Dict) – Max container value for each node
max_goal (float) – Max value objective (not to exceed)
- Returns:
True if objective is satisfied, False otherwise
- Return type:
bool
- hots.allocation.move_containers(my_instance, config)[source]
Move containers in order to satisfy number open nodes target.
- Parameters:
my_instance (Instance) – The Instance object of the current run
config (Dict) – Current HOTS run parameters
- hots.allocation.resources_to_remove(max_goal, max_by_node)[source]
Compute the amount of resources to remove to reach the load goal.
- Parameters:
max_goal (float) – Load value to achieve from parameters
max_by_node (Dict) – Max container value for each node
- Returns:
Value to retrieve for reaching load goal
- Return type:
float
- hots.allocation.round_decimals_up(number, decimals=2)[source]
Return a value rounded up to a specific number of decimal places.
- Parameters:
number (float) – Value to round up
decimals (int, optional) – Wanted numbers after comma, defaults to 2
- Raises:
TypeError – Wrong type for decimals
ValueError – Non-positive value for decimals
- Returns:
Rounded up value
- Return type:
float