Polarith AI
1.8

◆ FindOptimal()

static int [] FindOptimal ( int  costs[,])
static

Finds optimal assignments for a matrix of agents and costed tasks.

The optimization looks for the best assignment of the first index from the input data using the Hungarian Method.

Note that the column/row model for agents and tasks is just a mental model. It depends on your input data, whether the first index or the second index represents the agent or the task. However, we will optimize for the first index. Original code provided in 2010 by Alex Regueiro under MIT License.

Parameters
costsA cost matrix; each row contains elements that represent the associated costs of each task for the agent.
Returns
An array of assignments; element i is the index of the assigned task/position (column) for an agent (row).
Imprint