Costs

l2_cost(data[, scaling, R, C])

L2 cost

power_cost(data[, p, scaling, R, C])

Power cost.

anisotropic_power_cost(data[, p, scaling, ...])

Anisotropic power cost with anisotropy matrix data.orientation.

spherocylinders_2_cost(data[, p, b, scaling, C])

Spherocylinder cost.

iceshot.costs.l2_cost(data, scaling=None, R=1.0, C=1.0, **kwargs)

L2 cost

\[c(x,y) = |y-x|^2\]
Parameters:
  • data (DataPoints)

  • scaling (str, optional) –

    Defaults to None. If specified, can be one of the following:

    • "level_set" : The cost is equal to C at distance R

    • "volume" : The integral of the cost on a ball of radius R is equal to the volume of the ball times C

    • "constant: : Multiply the cost by C

  • R (float or Tensor, optional) – Defaults to 1.0.

  • C (float or Tensor, optional) – Defaults to 1.0.

Returns:

cost matrix and its gradient

Return type:

((N,M)-LazyTensor, (N,M,d)-LazyTensor)

iceshot.costs.power_cost(data, p=2.0, scaling=None, R=1.0, C=1.0, **kwargs)

Power cost.

\[c(x,y) = \lambda_p |y-x|^p\]
Parameters:
  • data (DataPoints)

  • p (float or Tensor, optional) – Exponent. Defaults to 2.0.

  • scaling (str, optional) –

    Defaults to None. If specified, can be one of the following:

    • "level_set" : The cost is equal to C at distance R

    • "volume" : The integral of the cost on a ball of radius R is equal to the volume of the ball times C

    • "constant: : Multiply the cost by C

  • R (float or Tensor, optional) – Defaults to 1.0.

  • C (float or Tensor, optional) – Defaults to 1.0.

Returns:

cost matrix and its gradient

Return type:

((N,M)-LazyTensor, (N,M,d)-LazyTensor)

iceshot.costs.anisotropic_power_cost(data, p=2.0, scaling=None, b=1.0, ar=None, C=1.0, **kwargs)

Anisotropic power cost with anisotropy matrix data.orientation.

\[c(x,y) = \lambda_p (y-x)^T A (y-x)\]
Parameters:
  • data (DataPoints)

  • p (float or Tensor, optional) – Exponent. Defaults to 2.0.

  • scaling (str, optional) –

    Defaults to None. If specified, can be one of the following:

    • "level_set" : \(c(x,y) = C\) is the equation of an ellipse with aspect ratio ar and short axis b

    • "volume" : The integral of the cost on an ellipse of aspect ratio ar and short axis b is equal to the volume of the ellipse times C

    • "constant: : Multiply the cost by C

  • b (float or Tensor, optional) – short-axis. Defaults to 1.0.

  • ar (Tensor, optional) – aspect ratio. Defaults to None.

  • C (float or Tensor, optional) – Defaults to 1.0.

Returns:

cost matrix and its gradient

Return type:

((N,M)-LazyTensor, (N,M,d)-LazyTensor)

iceshot.costs.spherocylinders_2_cost(data, p=2.0, b=1.0, scaling=None, C=1.0, **kwargs)

Spherocylinder cost.

The level-sets are spherocylinders with aspect ratio data.ar.

Parameters:
  • data (DataPoints)

  • p (float or Tensor, optional) – Exponent. Defaults to 2.0.

  • b (float or Tensor, optional) – short_axis. Defaults to 1.0.

  • scaling (str, optional) –

    Defaults to None. If specified, can be one of the following:

    • "level_set" : Short-axis level-set

    • "volume" : The integral of the cost on the spherocylinder with short-axis b is the volume of this spherocylinder.

    • "constant: : Multiply the cost by C

  • C (float or Tensor, optional) – Defaults to 1.0.

Raises:

NotImplementedError – Only in 2D

Returns:

cost matrix and its gradient

Return type:

((N,M)-LazyTensor, (N,M,d)-LazyTensor)