Skip to main content

Maximize Allocation

Type: Goal

Maximize the utilization of a set of scope items. The goal rewards filling scope items as much as possible for a given dimension, which is useful when objects contribute more on some scope items than others and you want to place them where they pack best.

Parameters

ParameterTypeRequiredDefaultDescription
namestringYes-Descriptive name for logging/debugging
scopestringYes-Scope whose scope items' utilization is maximized (e.g. "host")
dimensionstringYes-Dimension whose relative utilization is maximized
filterFilterNoall scope itemsWhich scope items count toward the goal (set itemsWhitelist or itemsBlacklist)

The goal value is proportional to the negated sum of each scope item's relative utilization for dimension, so minimizing it maximizes the total fill across the selected scope items.

Example

This example uses a dynamic dimension: each task contributes 1 by default, but 5 on its preferred host. There are 3 hosts (capacity 10 each) and 6 tasks. Initially every task sits on a host where it contributes only 1, so each host is at 2/10 = 20% utilization.

Initial assignment:

Initial assignment: each host holds two tasks contributing 1 each, so 20% utilized; a table lists each task's preferred host where it contributes 5
solver.setObjectName("task");
solver.setContainerName("host");

solver.setAssignment(std::map<std::string, std::vector<std::string>>{
{"host0", {"task0", "task1"}},
{"host1", {"task2", "task3"}},
{"host2", {"task4", "task5"}},
});

// "load" is a dynamic dimension: each task contributes 1 by default, but 5 on its
// preferred host. Each host has a capacity of 10 for the same dimension.
solver.addDynamicObjectDimension(
"load", "host",
std::map<std::string, std::map<std::string, double>>{
{"host1", {{"task0", 5}, {"task1", 5}}},
{"host2", {{"task2", 5}, {"task3", 5}}},
{"host0", {{"task4", 5}, {"task5", 5}}},
},
/*defaultValue=*/1);
solver.addScopeDimension(
"load", "host",
std::map<std::string, double>{{"host0", 10}, {"host1", 10}, {"host2", 10}});

// Maximize the hosts' utilization of "load".
MaximizeAllocationSpec maximizeAllocation;
maximizeAllocation.scope() = "host";
maximizeAllocation.dimension() = "load";
solver.addGoal(maximizeAllocation);

Rebalancer moves each task to its preferred host, where it contributes 5. Each host then holds two such tasks for 10/10 = 100% utilization.

Final assignment:

Final assignment: each task moved to its preferred host, so every host is 100% utilized

Goal only

MaximizeAllocation can only be used as a goal; there is no constraint form. Its value competes with other goals, so utilization is increased only when the gain outweighs other costs. Use filter to maximize utilization on a subset of scope items---for example, draining everything else onto a chosen set.

Source