nocad.distances.placement_cost#

nocad.distances.placement_cost(dist, nodes, beta=0.5)[source]#

Cost of a driver or sensor configuration (MATLAB getCost).

\[\mathrm{cost}(\mathcal{S},\beta)=\beta\max_i\rho_i+(1-\beta)\frac{1}{N}\sum_i\rho_i, \qquad \rho_i=\min_{s\in\mathcal{S}} d_{s i},\]

i.e. the worst and the mean relative order of the states when every state is assigned to its closest configured node.

Parameters:
distndarray of shape (N, N)

Distances dist[s, i] from a configured node s to state i: the geodesic distances of the network for drivers, of the reversed network for sensors. Infinite entries should be replaced by a large finite value (the MATLAB code uses N).

nodesarray_like of int
betafloat, default=0.5
Returns:
cost, max_order, mean_orderfloat

Examples

>>> dist = np.array([[0, 1, 2, 3], [2, 0, 1, 2], [1, 2, 0, 1], [4, 4, 4, 0]])
>>> placement_cost(dist, [0, 2])
(0.75, 1.0, 0.5)