<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/quantum/blob/v0.7.6/tensorflow_quantum/python/optimizers/rotosolve_minimizer.py#L109-L274) |

Applies the rotosolve algorithm.

    tfq.optimizers.rotosolve_minimize(
        expectation_value_function,
        initial_position,
        tolerance=1e-05,
        max_iterations=50,
        name=None
    )

The rotosolve algorithm can be used to minimize a linear combination

of quantum measurement expectation values. See the following paper:

[arXiv:1903.12166](https://arxiv.org/abs/1903.12166), Ken M. Nakanishi.
[arXiv:1905.09692](https://arxiv.org/abs/1905.09692), Mateusz Ostaszewski.

#### Usage:

Here is an example of optimize a function which consists summation of
a few sinusoids.

    n = 10  # Number of sinusoids
    coefficient = tf.random.uniform(shape=[n])
    min_value = -tf.math.reduce_sum(tf.abs(coefficient))
    func = lambda x:tf.math.reduce_sum(tf.sin(x) * coefficient)
    # Optimize the function with rotosolve, start with random parameters
    result = tfq.optimizers.rotosolve_minimize(func, np.random.random(n))
    result.converged
    tf.Tensor(True, shape=(), dtype=bool)
    result.objective_value
    tf.Tensor(-4.7045116, shape=(), dtype=float32)

<br />

<br />

<br />

| ## Args ||
|---|---|
| `expectation_value_function` | A Python callable that accepts a point as a real [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) and returns a [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor)s of real dtype containing the value of the function. The function to be minimized. The input is of shape `[n]`, where `n` is the size of the trainable parameters. The return value is a real [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) Scalar (matching shape `[1]`). This must be a linear combination of quantum measurement expectation value, otherwise this algorithm cannot work. |
| `initial_position` | Real [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) of shape `[n]`. The starting point, or points when using batching dimensions, of the search procedure. At these points the function value and the gradient norm should be finite. |
| `tolerance` | Scalar [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) of real dtype. Specifies the tolerance for the procedure. If the supremum norm between two iteration vector is below this number, the algorithm is stopped. |
| `name` | (Optional) Python `str`. The name prefixed to the ops created by this function. If not supplied, the default name 'minimize' is used. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `optimizer_results` | A RotosolveOptimizerResults object contains the result of the optimization process. |

<br />