QuadraticProgram.substitute_variables

QuadraticProgram.substitute_variables(constants=None, variables=None)[fuente]

Substitutes variables with constants or other variables.

Parámetros:
  • constants (Dict[int | str, float] | None) – replace variable by constant e.g., {'x': 2} means x is substituted with 2

  • variables (Dict[str | int, Tuple[str | int, float]] | None) – replace variables by weighted other variable need to copy everything using name reference to make sure that indices are matched correctly. The lower and upper bounds are updated accordingly. e.g., {'x': ('y', 2)} means x is substituted with y * 2

Devuelve:

An optimization problem by substituting variables with constants or other variables. If the substitution is valid, QuadraticProgram.status is still QuadraticProgram.Status.VALID. Otherwise, it gets QuadraticProgram.Status.INFEASIBLE.

Muestra:

QiskitOptimizationError – if the substitution is invalid as follows. - Same variable is substituted multiple times. - Coefficient of variable substitution is zero.

Tipo del valor devuelto:

QuadraticProgram