dwave.optimization.mathematical.maximum#

maximum(x1: ArraySymbol, x2: ArraySymbol, *xi: ArraySymbol) Maximum | NaryMaximum[source]#

Return an element-wise maximum of the given symbols.

In the underlying directed acyclic expression graph, produces a Maximum node if two array nodes are provided and a NaryMaximum node otherwise.

Parameters:
  • x1 – Input array symbol.

  • x2 – Input array symbol.

  • *xi – Additional input array symbols.

Returns:

A symbol that is the element-wise maximum of the given symbols. Taking the element-wise maximum of two symbols returns a Maximum. Taking the element-wise maximum of three or more symbols returns a NaryMaximum.

Examples

This example maximizes two integer symbols of size \(1 \times 2\).

>>> from dwave.optimization import Model
>>> from dwave.optimization.mathematical import maximum
...
>>> model = Model()
>>> i = model.integer(2)
>>> j = model.integer(2)
>>> m = maximum(i, j)
>>> with model.lock():
...     model.states.resize(1)
...     i.set_state(0, [3, 5])
...     j.set_state(0, [7, 2])
...     print(m.state(0))
[7. 5.]