963 lines
47 KiB
Plaintext
963 lines
47 KiB
Plaintext
---
|
||
title: QuadraticProgram (v0.26)
|
||
description: API reference for qiskit.optimization.problems.QuadraticProgram in qiskit v0.26
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.optimization.problems.QuadraticProgram
|
||
---
|
||
|
||
<span id="qiskit-optimization-problems-quadraticprogram" />
|
||
|
||
# qiskit.optimization.problems.QuadraticProgram
|
||
|
||
<Class id="qiskit.optimization.problems.QuadraticProgram" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.9/qiskit/optimization/problems/quadratic_program.py" signature="QuadraticProgram(name='')" modifiers="class">
|
||
Quadratically Constrained Quadratic Program representation.
|
||
|
||
This representation supports inequality and equality constraints, as well as continuous, binary, and integer variables.
|
||
|
||
**Parameters**
|
||
|
||
**name** (`str`) – The name of the quadratic program.
|
||
|
||
### \_\_init\_\_
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.__init__" signature="__init__(name='')">
|
||
**Parameters**
|
||
|
||
**name** (`str`) – The name of the quadratic program.
|
||
</Function>
|
||
|
||
## Methods
|
||
|
||
| | |
|
||
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
||
| [`__init__`](#qiskit.optimization.problems.QuadraticProgram.__init__ "qiskit.optimization.problems.QuadraticProgram.__init__")(\[name]) | **type name**`str` |
|
||
| [`binary_var`](#qiskit.optimization.problems.QuadraticProgram.binary_var "qiskit.optimization.problems.QuadraticProgram.binary_var")(\[name]) | Adds a binary variable to the quadratic program. |
|
||
| [`binary_var_dict`](#qiskit.optimization.problems.QuadraticProgram.binary_var_dict "qiskit.optimization.problems.QuadraticProgram.binary_var_dict")(keys\[, name, key\_format]) | Uses ‘var\_dict’ to construct a dictionary of binary variables |
|
||
| [`binary_var_list`](#qiskit.optimization.problems.QuadraticProgram.binary_var_list "qiskit.optimization.problems.QuadraticProgram.binary_var_list")(keys\[, name, key\_format]) | Uses ‘var\_list’ to construct a list of binary variables |
|
||
| [`clear`](#qiskit.optimization.problems.QuadraticProgram.clear "qiskit.optimization.problems.QuadraticProgram.clear")() | Clears the quadratic program, i.e., deletes all variables, constraints, the objective function as well as the name. |
|
||
| [`continuous_var`](#qiskit.optimization.problems.QuadraticProgram.continuous_var "qiskit.optimization.problems.QuadraticProgram.continuous_var")(\[lowerbound, upperbound, name]) | Adds a continuous variable to the quadratic program. |
|
||
| [`continuous_var_dict`](#qiskit.optimization.problems.QuadraticProgram.continuous_var_dict "qiskit.optimization.problems.QuadraticProgram.continuous_var_dict")(keys\[, lowerbound, …]) | Uses ‘var\_dict’ to construct a dictionary of continuous variables |
|
||
| [`continuous_var_list`](#qiskit.optimization.problems.QuadraticProgram.continuous_var_list "qiskit.optimization.problems.QuadraticProgram.continuous_var_list")(keys\[, lowerbound, …]) | Uses ‘var\_list’ to construct a list of continuous variables |
|
||
| [`export_as_lp_string`](#qiskit.optimization.problems.QuadraticProgram.export_as_lp_string "qiskit.optimization.problems.QuadraticProgram.export_as_lp_string")() | Returns the quadratic program as a string of LP format. |
|
||
| [`from_docplex`](#qiskit.optimization.problems.QuadraticProgram.from_docplex "qiskit.optimization.problems.QuadraticProgram.from_docplex")(model) | Loads this quadratic program from a docplex model. |
|
||
| [`from_ising`](#qiskit.optimization.problems.QuadraticProgram.from_ising "qiskit.optimization.problems.QuadraticProgram.from_ising")(qubit\_op\[, offset, linear]) | Create a quadratic program from a qubit operator and a shift value. |
|
||
| [`get_feasibility_info`](#qiskit.optimization.problems.QuadraticProgram.get_feasibility_info "qiskit.optimization.problems.QuadraticProgram.get_feasibility_info")(x) | Returns whether a solution is feasible or not along with the violations. |
|
||
| [`get_linear_constraint`](#qiskit.optimization.problems.QuadraticProgram.get_linear_constraint "qiskit.optimization.problems.QuadraticProgram.get_linear_constraint")(i) | Returns a linear constraint for a given name or index. |
|
||
| [`get_num_binary_vars`](#qiskit.optimization.problems.QuadraticProgram.get_num_binary_vars "qiskit.optimization.problems.QuadraticProgram.get_num_binary_vars")() | Returns the total number of binary variables. |
|
||
| [`get_num_continuous_vars`](#qiskit.optimization.problems.QuadraticProgram.get_num_continuous_vars "qiskit.optimization.problems.QuadraticProgram.get_num_continuous_vars")() | Returns the total number of continuous variables. |
|
||
| [`get_num_integer_vars`](#qiskit.optimization.problems.QuadraticProgram.get_num_integer_vars "qiskit.optimization.problems.QuadraticProgram.get_num_integer_vars")() | Returns the total number of integer variables. |
|
||
| [`get_num_linear_constraints`](#qiskit.optimization.problems.QuadraticProgram.get_num_linear_constraints "qiskit.optimization.problems.QuadraticProgram.get_num_linear_constraints")() | Returns the number of linear constraints. |
|
||
| [`get_num_quadratic_constraints`](#qiskit.optimization.problems.QuadraticProgram.get_num_quadratic_constraints "qiskit.optimization.problems.QuadraticProgram.get_num_quadratic_constraints")() | Returns the number of quadratic constraints. |
|
||
| [`get_num_vars`](#qiskit.optimization.problems.QuadraticProgram.get_num_vars "qiskit.optimization.problems.QuadraticProgram.get_num_vars")(\[vartype]) | Returns the total number of variables or the number of variables of the specified type. |
|
||
| [`get_quadratic_constraint`](#qiskit.optimization.problems.QuadraticProgram.get_quadratic_constraint "qiskit.optimization.problems.QuadraticProgram.get_quadratic_constraint")(i) | Returns a quadratic constraint for a given name or index. |
|
||
| [`get_variable`](#qiskit.optimization.problems.QuadraticProgram.get_variable "qiskit.optimization.problems.QuadraticProgram.get_variable")(i) | Returns a variable for a given name or index. |
|
||
| [`integer_var`](#qiskit.optimization.problems.QuadraticProgram.integer_var "qiskit.optimization.problems.QuadraticProgram.integer_var")(\[lowerbound, upperbound, name]) | Adds an integer variable to the quadratic program. |
|
||
| [`integer_var_dict`](#qiskit.optimization.problems.QuadraticProgram.integer_var_dict "qiskit.optimization.problems.QuadraticProgram.integer_var_dict")(keys\[, lowerbound, …]) | Uses ‘var\_dict’ to construct a dictionary of integer variables |
|
||
| [`integer_var_list`](#qiskit.optimization.problems.QuadraticProgram.integer_var_list "qiskit.optimization.problems.QuadraticProgram.integer_var_list")(keys\[, lowerbound, …]) | Uses ‘var\_list’ to construct a dictionary of integer variables |
|
||
| [`is_feasible`](#qiskit.optimization.problems.QuadraticProgram.is_feasible "qiskit.optimization.problems.QuadraticProgram.is_feasible")(x) | Returns whether a solution is feasible or not. |
|
||
| [`linear_constraint`](#qiskit.optimization.problems.QuadraticProgram.linear_constraint "qiskit.optimization.problems.QuadraticProgram.linear_constraint")(\[linear, sense, rhs, name]) | Adds a linear equality constraint to the quadratic program of the form: |
|
||
| [`maximize`](#qiskit.optimization.problems.QuadraticProgram.maximize "qiskit.optimization.problems.QuadraticProgram.maximize")(\[constant, linear, quadratic]) | Sets a quadratic objective to be maximized. |
|
||
| [`minimize`](#qiskit.optimization.problems.QuadraticProgram.minimize "qiskit.optimization.problems.QuadraticProgram.minimize")(\[constant, linear, quadratic]) | Sets a quadratic objective to be minimized. |
|
||
| [`pprint_as_string`](#qiskit.optimization.problems.QuadraticProgram.pprint_as_string "qiskit.optimization.problems.QuadraticProgram.pprint_as_string")() | DEPRECATED Returns the quadratic program as a string in Docplex’s pretty print format. |
|
||
| [`prettyprint`](#qiskit.optimization.problems.QuadraticProgram.prettyprint "qiskit.optimization.problems.QuadraticProgram.prettyprint")(\[out]) | DEPRECATED Pretty prints the quadratic program to a given output stream (None = default). |
|
||
| [`quadratic_constraint`](#qiskit.optimization.problems.QuadraticProgram.quadratic_constraint "qiskit.optimization.problems.QuadraticProgram.quadratic_constraint")(\[linear, quadratic, …]) | Adds a quadratic equality constraint to the quadratic program of the form: |
|
||
| [`read_from_lp_file`](#qiskit.optimization.problems.QuadraticProgram.read_from_lp_file "qiskit.optimization.problems.QuadraticProgram.read_from_lp_file")(filename) | Loads the quadratic program from a LP file. |
|
||
| [`remove_linear_constraint`](#qiskit.optimization.problems.QuadraticProgram.remove_linear_constraint "qiskit.optimization.problems.QuadraticProgram.remove_linear_constraint")(i) | Remove a linear constraint |
|
||
| [`remove_quadratic_constraint`](#qiskit.optimization.problems.QuadraticProgram.remove_quadratic_constraint "qiskit.optimization.problems.QuadraticProgram.remove_quadratic_constraint")(i) | Remove a quadratic constraint |
|
||
| [`substitute_variables`](#qiskit.optimization.problems.QuadraticProgram.substitute_variables "qiskit.optimization.problems.QuadraticProgram.substitute_variables")(\[constants, variables]) | Substitutes variables with constants or other variables. |
|
||
| [`to_docplex`](#qiskit.optimization.problems.QuadraticProgram.to_docplex "qiskit.optimization.problems.QuadraticProgram.to_docplex")() | Returns a docplex model corresponding to this quadratic program. |
|
||
| [`to_ising`](#qiskit.optimization.problems.QuadraticProgram.to_ising "qiskit.optimization.problems.QuadraticProgram.to_ising")() | Return the Ising Hamiltonian of this problem. |
|
||
| [`write_to_lp_file`](#qiskit.optimization.problems.QuadraticProgram.write_to_lp_file "qiskit.optimization.problems.QuadraticProgram.write_to_lp_file")(filename) | Writes the quadratic program to an LP file. |
|
||
|
||
## Attributes
|
||
|
||
| | |
|
||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
||
| [`linear_constraints`](#qiskit.optimization.problems.QuadraticProgram.linear_constraints "qiskit.optimization.problems.QuadraticProgram.linear_constraints") | Returns the list of linear constraints of the quadratic program. |
|
||
| [`linear_constraints_index`](#qiskit.optimization.problems.QuadraticProgram.linear_constraints_index "qiskit.optimization.problems.QuadraticProgram.linear_constraints_index") | Returns the dictionary that maps the name of a linear constraint to its index. |
|
||
| [`name`](#qiskit.optimization.problems.QuadraticProgram.name "qiskit.optimization.problems.QuadraticProgram.name") | Returns the name of the quadratic program. |
|
||
| [`objective`](#qiskit.optimization.problems.QuadraticProgram.objective "qiskit.optimization.problems.QuadraticProgram.objective") | Returns the quadratic objective. |
|
||
| [`quadratic_constraints`](#qiskit.optimization.problems.QuadraticProgram.quadratic_constraints "qiskit.optimization.problems.QuadraticProgram.quadratic_constraints") | Returns the list of quadratic constraints of the quadratic program. |
|
||
| [`quadratic_constraints_index`](#qiskit.optimization.problems.QuadraticProgram.quadratic_constraints_index "qiskit.optimization.problems.QuadraticProgram.quadratic_constraints_index") | Returns the dictionary that maps the name of a quadratic constraint to its index. |
|
||
| [`status`](#qiskit.optimization.problems.QuadraticProgram.status "qiskit.optimization.problems.QuadraticProgram.status") | Status of the quadratic program. |
|
||
| [`variables`](#qiskit.optimization.problems.QuadraticProgram.variables "qiskit.optimization.problems.QuadraticProgram.variables") | Returns the list of variables of the quadratic program. |
|
||
| [`variables_index`](#qiskit.optimization.problems.QuadraticProgram.variables_index "qiskit.optimization.problems.QuadraticProgram.variables_index") | Returns the dictionary that maps the name of a variable to its index. |
|
||
|
||
### Status
|
||
|
||
<Attribute id="qiskit.optimization.problems.QuadraticProgram.Status">
|
||
alias of `QuadraticProgramStatus`
|
||
</Attribute>
|
||
|
||
### binary\_var
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.binary_var" signature="binary_var(name=None)">
|
||
Adds a binary variable to the quadratic program.
|
||
|
||
**Parameters**
|
||
|
||
**name** (`Optional`\[`str`]) – The name of the variable.
|
||
|
||
**Return type**
|
||
|
||
`Variable`
|
||
|
||
**Returns**
|
||
|
||
The added variable.
|
||
|
||
**Raises**
|
||
|
||
[**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if the variable name is already occupied.
|
||
</Function>
|
||
|
||
### binary\_var\_dict
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.binary_var_dict" signature="binary_var_dict(keys, name=None, key_format='{}')">
|
||
Uses ‘var\_dict’ to construct a dictionary of binary variables
|
||
|
||
**Parameters**
|
||
|
||
* **name** (`Optional`\[`str`]) – The name(s) of the variable(s).
|
||
* **key\_format** (`str`) – The format used to name/index the variable(s).
|
||
* **keys** (`Union`\[`int`, `Sequence`]) – If keys: int, it is interpreted as the number of variables to construct. Otherwise, the elements of the sequence are converted to strings via ‘str’ and substituted into key\_format.
|
||
|
||
**Return type**
|
||
|
||
`Dict`\[`str`, `Variable`]
|
||
|
||
**Returns**
|
||
|
||
A dictionary mapping the variable names to variable instances.
|
||
|
||
**Raises**
|
||
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if the variable name is already taken.
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if less than one variable instantiation is attempted.
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if key\_format has more than one substitution or a nested substitution.
|
||
</Function>
|
||
|
||
### binary\_var\_list
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.binary_var_list" signature="binary_var_list(keys, name=None, key_format='{}')">
|
||
Uses ‘var\_list’ to construct a list of binary variables
|
||
|
||
**Parameters**
|
||
|
||
* **name** (`Optional`\[`str`]) – The name(s) of the variable(s).
|
||
* **key\_format** (`str`) – The format used to name/index the variable(s).
|
||
* **keys** (`Union`\[`int`, `Sequence`]) – If keys: int, it is interpreted as the number of variables to construct. Otherwise, the elements of the sequence are converted to strings via ‘str’ and substituted into key\_format.
|
||
|
||
**Return type**
|
||
|
||
`List`\[`Variable`]
|
||
|
||
**Returns**
|
||
|
||
A list of variable instances.
|
||
|
||
**Raises**
|
||
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if the variable name is already taken.
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if less than one variable instantiation is attempted.
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if key\_format has more than one substitution or a nested substitution.
|
||
</Function>
|
||
|
||
### clear
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.clear" signature="clear()">
|
||
Clears the quadratic program, i.e., deletes all variables, constraints, the objective function as well as the name.
|
||
|
||
**Return type**
|
||
|
||
`None`
|
||
</Function>
|
||
|
||
### continuous\_var
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.continuous_var" signature="continuous_var(lowerbound=0, upperbound=1e+20, name=None)">
|
||
Adds a continuous variable to the quadratic program.
|
||
|
||
**Parameters**
|
||
|
||
* **lowerbound** (`Union`\[`float`, `int`]) – The lowerbound of the variable.
|
||
* **upperbound** (`Union`\[`float`, `int`]) – The upperbound of the variable.
|
||
* **name** (`Optional`\[`str`]) – The name of the variable.
|
||
|
||
**Return type**
|
||
|
||
`Variable`
|
||
|
||
**Returns**
|
||
|
||
The added variable.
|
||
|
||
**Raises**
|
||
|
||
[**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if the variable name is already occupied.
|
||
</Function>
|
||
|
||
### continuous\_var\_dict
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.continuous_var_dict" signature="continuous_var_dict(keys, lowerbound=0, upperbound=1e+20, name=None, key_format='{}')">
|
||
Uses ‘var\_dict’ to construct a dictionary of continuous variables
|
||
|
||
**Parameters**
|
||
|
||
* **lowerbound** (`Union`\[`float`, `int`]) – The lower bound of the variable(s).
|
||
* **upperbound** (`Union`\[`float`, `int`]) – The upper bound of the variable(s).
|
||
* **name** (`Optional`\[`str`]) – The name(s) of the variable(s).
|
||
* **key\_format** (`str`) – The format used to name/index the variable(s).
|
||
* **keys** (`Union`\[`int`, `Sequence`]) – If keys: int, it is interpreted as the number of variables to construct. Otherwise, the elements of the sequence are converted to strings via ‘str’ and substituted into key\_format.
|
||
|
||
**Return type**
|
||
|
||
`Dict`\[`str`, `Variable`]
|
||
|
||
**Returns**
|
||
|
||
A dictionary mapping the variable names to variable instances.
|
||
|
||
**Raises**
|
||
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if the variable name is already taken.
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if less than one variable instantiation is attempted.
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if key\_format has more than one substitution or a nested substitution.
|
||
</Function>
|
||
|
||
### continuous\_var\_list
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.continuous_var_list" signature="continuous_var_list(keys, lowerbound=0, upperbound=1e+20, name=None, key_format='{}')">
|
||
Uses ‘var\_list’ to construct a list of continuous variables
|
||
|
||
**Parameters**
|
||
|
||
* **lowerbound** (`Union`\[`float`, `int`]) – The lower bound of the variable(s).
|
||
* **upperbound** (`Union`\[`float`, `int`]) – The upper bound of the variable(s).
|
||
* **name** (`Optional`\[`str`]) – The name(s) of the variable(s).
|
||
* **key\_format** (`str`) – The format used to name/index the variable(s).
|
||
* **keys** (`Union`\[`int`, `Sequence`]) – If keys: int, it is interpreted as the number of variables to construct. Otherwise, the elements of the sequence are converted to strings via ‘str’ and substituted into key\_format.
|
||
|
||
**Return type**
|
||
|
||
`List`\[`Variable`]
|
||
|
||
**Returns**
|
||
|
||
A list of variable instances.
|
||
|
||
**Raises**
|
||
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if the variable name is already taken.
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if less than one variable instantiation is attempted.
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if key\_format has more than one substitution or a nested substitution.
|
||
</Function>
|
||
|
||
### export\_as\_lp\_string
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.export_as_lp_string" signature="export_as_lp_string()">
|
||
Returns the quadratic program as a string of LP format.
|
||
|
||
**Return type**
|
||
|
||
`str`
|
||
|
||
**Returns**
|
||
|
||
A string representing the quadratic program.
|
||
</Function>
|
||
|
||
### from\_docplex
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.from_docplex" signature="from_docplex(model)">
|
||
Loads this quadratic program from a docplex model.
|
||
|
||
Note that this supports only basic functions of docplex as follows: - quadratic objective function - linear / quadratic constraints - binary / integer / continuous variables
|
||
|
||
**Parameters**
|
||
|
||
**model** (`Model`) – The docplex model to be loaded.
|
||
|
||
**Raises**
|
||
|
||
[**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if the model contains unsupported elements.
|
||
|
||
**Return type**
|
||
|
||
`None`
|
||
</Function>
|
||
|
||
### from\_ising
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.from_ising" signature="from_ising(qubit_op, offset=0.0, linear=False)">
|
||
Create a quadratic program from a qubit operator and a shift value.
|
||
|
||
**Parameters**
|
||
|
||
* **qubit\_op** (`Union`\[`OperatorBase`, `WeightedPauliOperator`]) – The qubit operator of the problem.
|
||
* **offset** (`float`) – The constant value in the Ising Hamiltonian.
|
||
* **linear** (`bool`) – If linear is True, $x^2$ is treated as a linear term since $x^2 = x$ for $x \in \{0,1\}$. Else, $x^2$ is treat as a quadratic term. The default value is False.
|
||
|
||
**Raises**
|
||
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – If there are Pauli Xs in any Pauli term
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – If there are more than 2 Pauli Zs in any Pauli term
|
||
* **NotImplementedError** – If the input operator is a ListOp
|
||
|
||
**Return type**
|
||
|
||
`None`
|
||
</Function>
|
||
|
||
### get\_feasibility\_info
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.get_feasibility_info" signature="get_feasibility_info(x)">
|
||
Returns whether a solution is feasible or not along with the violations. :type x: `Union`\[`List`\[`float`], `ndarray`] :param x: a solution value, such as returned in an optimizer result.
|
||
|
||
**Returns**
|
||
|
||
Whether the solution provided is feasible or not. List\[Variable]: List of variables which are violated. List\[Constraint]: List of constraints which are violated.
|
||
|
||
**Return type**
|
||
|
||
feasible
|
||
|
||
**Raises**
|
||
|
||
[**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – If the input x is not same len as total vars
|
||
</Function>
|
||
|
||
### get\_linear\_constraint
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.get_linear_constraint" signature="get_linear_constraint(i)">
|
||
Returns a linear constraint for a given name or index.
|
||
|
||
**Parameters**
|
||
|
||
**i** (`Union`\[`int`, `str`]) – the index or name of the constraint.
|
||
|
||
**Return type**
|
||
|
||
`LinearConstraint`
|
||
|
||
**Returns**
|
||
|
||
The corresponding constraint.
|
||
|
||
**Raises**
|
||
|
||
* **IndexError** – if the index is out of the list size
|
||
* **KeyError** – if the name does not exist
|
||
</Function>
|
||
|
||
### get\_num\_binary\_vars
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.get_num_binary_vars" signature="get_num_binary_vars()">
|
||
Returns the total number of binary variables.
|
||
|
||
**Return type**
|
||
|
||
`int`
|
||
|
||
**Returns**
|
||
|
||
The total number of binary variables.
|
||
</Function>
|
||
|
||
### get\_num\_continuous\_vars
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.get_num_continuous_vars" signature="get_num_continuous_vars()">
|
||
Returns the total number of continuous variables.
|
||
|
||
**Return type**
|
||
|
||
`int`
|
||
|
||
**Returns**
|
||
|
||
The total number of continuous variables.
|
||
</Function>
|
||
|
||
### get\_num\_integer\_vars
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.get_num_integer_vars" signature="get_num_integer_vars()">
|
||
Returns the total number of integer variables.
|
||
|
||
**Return type**
|
||
|
||
`int`
|
||
|
||
**Returns**
|
||
|
||
The total number of integer variables.
|
||
</Function>
|
||
|
||
### get\_num\_linear\_constraints
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.get_num_linear_constraints" signature="get_num_linear_constraints()">
|
||
Returns the number of linear constraints.
|
||
|
||
**Return type**
|
||
|
||
`int`
|
||
|
||
**Returns**
|
||
|
||
The number of linear constraints.
|
||
</Function>
|
||
|
||
### get\_num\_quadratic\_constraints
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.get_num_quadratic_constraints" signature="get_num_quadratic_constraints()">
|
||
Returns the number of quadratic constraints.
|
||
|
||
**Return type**
|
||
|
||
`int`
|
||
|
||
**Returns**
|
||
|
||
The number of quadratic constraints.
|
||
</Function>
|
||
|
||
### get\_num\_vars
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.get_num_vars" signature="get_num_vars(vartype=None)">
|
||
Returns the total number of variables or the number of variables of the specified type.
|
||
|
||
**Parameters**
|
||
|
||
**vartype** (`Optional`\[`VarType`]) – The type to be filtered on. All variables are counted if None.
|
||
|
||
**Return type**
|
||
|
||
`int`
|
||
|
||
**Returns**
|
||
|
||
The total number of variables.
|
||
</Function>
|
||
|
||
### get\_quadratic\_constraint
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.get_quadratic_constraint" signature="get_quadratic_constraint(i)">
|
||
Returns a quadratic constraint for a given name or index.
|
||
|
||
**Parameters**
|
||
|
||
**i** (`Union`\[`int`, `str`]) – the index or name of the constraint.
|
||
|
||
**Return type**
|
||
|
||
`QuadraticConstraint`
|
||
|
||
**Returns**
|
||
|
||
The corresponding constraint.
|
||
|
||
**Raises**
|
||
|
||
* **IndexError** – if the index is out of the list size
|
||
* **KeyError** – if the name does not exist
|
||
</Function>
|
||
|
||
### get\_variable
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.get_variable" signature="get_variable(i)">
|
||
Returns a variable for a given name or index.
|
||
|
||
**Parameters**
|
||
|
||
**i** (`Union`\[`int`, `str`]) – the index or name of the variable.
|
||
|
||
**Return type**
|
||
|
||
`Variable`
|
||
|
||
**Returns**
|
||
|
||
The corresponding variable.
|
||
</Function>
|
||
|
||
### integer\_var
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.integer_var" signature="integer_var(lowerbound=0, upperbound=1e+20, name=None)">
|
||
Adds an integer variable to the quadratic program.
|
||
|
||
**Parameters**
|
||
|
||
* **lowerbound** (`Union`\[`float`, `int`]) – The lowerbound of the variable.
|
||
* **upperbound** (`Union`\[`float`, `int`]) – The upperbound of the variable.
|
||
* **name** (`Optional`\[`str`]) – The name of the variable.
|
||
|
||
**Return type**
|
||
|
||
`Variable`
|
||
|
||
**Returns**
|
||
|
||
The added variable.
|
||
|
||
**Raises**
|
||
|
||
[**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if the variable name is already occupied.
|
||
</Function>
|
||
|
||
### integer\_var\_dict
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.integer_var_dict" signature="integer_var_dict(keys, lowerbound=0, upperbound=1e+20, name=None, key_format='{}')">
|
||
Uses ‘var\_dict’ to construct a dictionary of integer variables
|
||
|
||
**Parameters**
|
||
|
||
* **lowerbound** (`Union`\[`float`, `int`]) – The lower bound of the variable(s).
|
||
* **upperbound** (`Union`\[`float`, `int`]) – The upper bound of the variable(s).
|
||
* **name** (`Optional`\[`str`]) – The name(s) of the variable(s).
|
||
* **key\_format** (`str`) – The format used to name/index the variable(s).
|
||
* **keys** (`Union`\[`int`, `Sequence`]) – If keys: int, it is interpreted as the number of variables to construct. Otherwise, the elements of the sequence are converted to strings via ‘str’ and substituted into key\_format.
|
||
|
||
**Return type**
|
||
|
||
`Dict`\[`str`, `Variable`]
|
||
|
||
**Returns**
|
||
|
||
A dictionary mapping the variable names to variable instances.
|
||
|
||
**Raises**
|
||
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if the variable name is already taken.
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if less than one variable instantiation is attempted.
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if key\_format has more than one substitution or a nested substitution.
|
||
</Function>
|
||
|
||
### integer\_var\_list
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.integer_var_list" signature="integer_var_list(keys, lowerbound=0, upperbound=1e+20, name=None, key_format='{}')">
|
||
Uses ‘var\_list’ to construct a dictionary of integer variables
|
||
|
||
**Parameters**
|
||
|
||
* **lowerbound** (`Union`\[`float`, `int`]) – The lower bound of the variable(s).
|
||
* **upperbound** (`Union`\[`float`, `int`]) – The upper bound of the variable(s).
|
||
* **name** (`Optional`\[`str`]) – The name(s) of the variable(s).
|
||
* **key\_format** (`str`) – The format used to name/index the variable(s).
|
||
* **keys** (`Union`\[`int`, `Sequence`]) – If keys: int, it is interpreted as the number of variables to construct. Otherwise, the elements of the sequence are converted to strings via ‘str’ and substituted into key\_format.
|
||
|
||
**Return type**
|
||
|
||
`List`\[`Variable`]
|
||
|
||
**Returns**
|
||
|
||
A list of variable instances.
|
||
|
||
**Raises**
|
||
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if the variable name is already taken.
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if less than one variable instantiation is attempted.
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if key\_format has more than one substitution or a nested substitution.
|
||
</Function>
|
||
|
||
### is\_feasible
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.is_feasible" signature="is_feasible(x)">
|
||
Returns whether a solution is feasible or not.
|
||
|
||
**Parameters**
|
||
|
||
**x** (`Union`\[`List`\[`float`], `ndarray`]) – a solution value, such as returned in an optimizer result.
|
||
|
||
**Return type**
|
||
|
||
`bool`
|
||
|
||
**Returns**
|
||
|
||
`True` if the solution provided is feasible otherwise `False`.
|
||
</Function>
|
||
|
||
### linear\_constraint
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.linear_constraint" signature="linear_constraint(linear=None, sense='<=', rhs=0.0, name=None)">
|
||
**Adds a linear equality constraint to the quadratic program of the form:**
|
||
|
||
linear \* x sense rhs.
|
||
|
||
**Parameters**
|
||
|
||
* **linear** (`Union`\[`ndarray`, `spmatrix`, `List`\[`float`], `Dict`\[`Union`\[`int`, `str`], `float`], `None`]) – The linear coefficients of the left-hand-side of the constraint.
|
||
* **sense** (`Union`\[`str`, `ConstraintSense`]) – The sense of the constraint, - ‘==’, ‘=’, ‘E’, and ‘EQ’ denote ‘equal to’. - ‘>=’, ‘>’, ‘G’, and ‘GE’ denote ‘greater-than-or-equal-to’. - ‘\<=’, ‘\<’, ‘L’, and ‘LE’ denote ‘less-than-or-equal-to’.
|
||
* **rhs** (`float`) – The right hand side of the constraint.
|
||
* **name** (`Optional`\[`str`]) – The name of the constraint.
|
||
|
||
**Return type**
|
||
|
||
`LinearConstraint`
|
||
|
||
**Returns**
|
||
|
||
The added constraint.
|
||
|
||
**Raises**
|
||
|
||
[**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if the constraint name already exists or the sense is not valid.
|
||
</Function>
|
||
|
||
### linear\_constraints
|
||
|
||
<Attribute id="qiskit.optimization.problems.QuadraticProgram.linear_constraints">
|
||
Returns the list of linear constraints of the quadratic program.
|
||
|
||
**Return type**
|
||
|
||
`List`\[`LinearConstraint`]
|
||
|
||
**Returns**
|
||
|
||
List of linear constraints.
|
||
</Attribute>
|
||
|
||
### linear\_constraints\_index
|
||
|
||
<Attribute id="qiskit.optimization.problems.QuadraticProgram.linear_constraints_index">
|
||
Returns the dictionary that maps the name of a linear constraint to its index.
|
||
|
||
**Return type**
|
||
|
||
`Dict`\[`str`, `int`]
|
||
|
||
**Returns**
|
||
|
||
The linear constraint index dictionary.
|
||
</Attribute>
|
||
|
||
### maximize
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.maximize" signature="maximize(constant=0.0, linear=None, quadratic=None)">
|
||
Sets a quadratic objective to be maximized.
|
||
|
||
**Parameters**
|
||
|
||
* **constant** (`float`) – the constant offset of the objective.
|
||
* **linear** (`Union`\[`ndarray`, `spmatrix`, `List`\[`float`], `Dict`\[`Union`\[`int`, `str`], `float`], `None`]) – the coefficients of the linear part of the objective.
|
||
* **quadratic** (`Union`\[`ndarray`, `spmatrix`, `List`\[`List`\[`float`]], `Dict`\[`Tuple`\[`Union`\[`int`, `str`], `Union`\[`int`, `str`]], `float`], `None`]) – the coefficients of the quadratic part of the objective.
|
||
|
||
**Return type**
|
||
|
||
`None`
|
||
|
||
**Returns**
|
||
|
||
The created quadratic objective.
|
||
</Function>
|
||
|
||
### minimize
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.minimize" signature="minimize(constant=0.0, linear=None, quadratic=None)">
|
||
Sets a quadratic objective to be minimized.
|
||
|
||
**Parameters**
|
||
|
||
* **constant** (`float`) – the constant offset of the objective.
|
||
* **linear** (`Union`\[`ndarray`, `spmatrix`, `List`\[`float`], `Dict`\[`Union`\[`int`, `str`], `float`], `None`]) – the coefficients of the linear part of the objective.
|
||
* **quadratic** (`Union`\[`ndarray`, `spmatrix`, `List`\[`List`\[`float`]], `Dict`\[`Tuple`\[`Union`\[`int`, `str`], `Union`\[`int`, `str`]], `float`], `None`]) – the coefficients of the quadratic part of the objective.
|
||
|
||
**Return type**
|
||
|
||
`None`
|
||
|
||
**Returns**
|
||
|
||
The created quadratic objective.
|
||
</Function>
|
||
|
||
### name
|
||
|
||
<Attribute id="qiskit.optimization.problems.QuadraticProgram.name">
|
||
Returns the name of the quadratic program.
|
||
|
||
**Return type**
|
||
|
||
`str`
|
||
|
||
**Returns**
|
||
|
||
The name of the quadratic program.
|
||
</Attribute>
|
||
|
||
### objective
|
||
|
||
<Attribute id="qiskit.optimization.problems.QuadraticProgram.objective">
|
||
Returns the quadratic objective.
|
||
|
||
**Return type**
|
||
|
||
`QuadraticObjective`
|
||
|
||
**Returns**
|
||
|
||
The quadratic objective.
|
||
</Attribute>
|
||
|
||
### pprint\_as\_string
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.pprint_as_string" signature="pprint_as_string()">
|
||
DEPRECATED Returns the quadratic program as a string in Docplex’s pretty print format. :rtype: `str` :returns: A string representing the quadratic program.
|
||
</Function>
|
||
|
||
### prettyprint
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.prettyprint" signature="prettyprint(out=None)">
|
||
DEPRECATED Pretty prints the quadratic program to a given output stream (None = default).
|
||
|
||
**Parameters**
|
||
|
||
**out** (`Optional`\[`str`]) – The output stream or file name to print to. if you specify a file name, the output file name is has ‘.mod’ as suffix.
|
||
|
||
**Return type**
|
||
|
||
`None`
|
||
</Function>
|
||
|
||
### quadratic\_constraint
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.quadratic_constraint" signature="quadratic_constraint(linear=None, quadratic=None, sense='<=', rhs=0.0, name=None)">
|
||
**Adds a quadratic equality constraint to the quadratic program of the form:**
|
||
|
||
x \* Q \* x \<= rhs.
|
||
|
||
**Parameters**
|
||
|
||
* **linear** (`Union`\[`ndarray`, `spmatrix`, `List`\[`float`], `Dict`\[`Union`\[`int`, `str`], `float`], `None`]) – The linear coefficients of the constraint.
|
||
* **quadratic** (`Union`\[`ndarray`, `spmatrix`, `List`\[`List`\[`float`]], `Dict`\[`Tuple`\[`Union`\[`int`, `str`], `Union`\[`int`, `str`]], `float`], `None`]) – The quadratic coefficients of the constraint.
|
||
* **sense** (`Union`\[`str`, `ConstraintSense`]) – The sense of the constraint, - ‘==’, ‘=’, ‘E’, and ‘EQ’ denote ‘equal to’. - ‘>=’, ‘>’, ‘G’, and ‘GE’ denote ‘greater-than-or-equal-to’. - ‘\<=’, ‘\<’, ‘L’, and ‘LE’ denote ‘less-than-or-equal-to’.
|
||
* **rhs** (`float`) – The right hand side of the constraint.
|
||
* **name** (`Optional`\[`str`]) – The name of the constraint.
|
||
|
||
**Return type**
|
||
|
||
`QuadraticConstraint`
|
||
|
||
**Returns**
|
||
|
||
The added constraint.
|
||
|
||
**Raises**
|
||
|
||
[**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if the constraint name already exists.
|
||
</Function>
|
||
|
||
### quadratic\_constraints
|
||
|
||
<Attribute id="qiskit.optimization.problems.QuadraticProgram.quadratic_constraints">
|
||
Returns the list of quadratic constraints of the quadratic program.
|
||
|
||
**Return type**
|
||
|
||
`List`\[`QuadraticConstraint`]
|
||
|
||
**Returns**
|
||
|
||
List of quadratic constraints.
|
||
</Attribute>
|
||
|
||
### quadratic\_constraints\_index
|
||
|
||
<Attribute id="qiskit.optimization.problems.QuadraticProgram.quadratic_constraints_index">
|
||
Returns the dictionary that maps the name of a quadratic constraint to its index.
|
||
|
||
**Return type**
|
||
|
||
`Dict`\[`str`, `int`]
|
||
|
||
**Returns**
|
||
|
||
The quadratic constraint index dictionary.
|
||
</Attribute>
|
||
|
||
### read\_from\_lp\_file
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.read_from_lp_file" signature="read_from_lp_file(filename)">
|
||
Loads the quadratic program from a LP file.
|
||
|
||
**Parameters**
|
||
|
||
**filename** (`str`) – The filename of the file to be loaded.
|
||
|
||
**Raises**
|
||
|
||
* **FileNotFoundError** – If the file does not exist.
|
||
* [**MissingOptionalLibraryError**](qiskit.aqua.MissingOptionalLibraryError "qiskit.aqua.MissingOptionalLibraryError") – If CPLEX is not installed.
|
||
|
||
<Admonition title="Note" type="note">
|
||
This method requires CPLEX to be installed and present in `PYTHONPATH`.
|
||
</Admonition>
|
||
|
||
**Return type**
|
||
|
||
`None`
|
||
</Function>
|
||
|
||
### remove\_linear\_constraint
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.remove_linear_constraint" signature="remove_linear_constraint(i)">
|
||
Remove a linear constraint
|
||
|
||
**Parameters**
|
||
|
||
**i** (`Union`\[`str`, `int`]) – an index or a name of a linear constraint
|
||
|
||
**Raises**
|
||
|
||
* **KeyError** – if name does not exist
|
||
* **IndexError** – if index is out of range
|
||
|
||
**Return type**
|
||
|
||
`None`
|
||
</Function>
|
||
|
||
### remove\_quadratic\_constraint
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.remove_quadratic_constraint" signature="remove_quadratic_constraint(i)">
|
||
Remove a quadratic constraint
|
||
|
||
**Parameters**
|
||
|
||
**i** (`Union`\[`str`, `int`]) – an index or a name of a quadratic constraint
|
||
|
||
**Raises**
|
||
|
||
* **KeyError** – if name does not exist
|
||
* **IndexError** – if index is out of range
|
||
|
||
**Return type**
|
||
|
||
`None`
|
||
</Function>
|
||
|
||
### status
|
||
|
||
<Attribute id="qiskit.optimization.problems.QuadraticProgram.status">
|
||
Status of the quadratic program. It can be infeasible due to variable substitution.
|
||
|
||
**Return type**
|
||
|
||
`QuadraticProgramStatus`
|
||
|
||
**Returns**
|
||
|
||
The status of the quadratic program
|
||
</Attribute>
|
||
|
||
### substitute\_variables
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.substitute_variables" signature="substitute_variables(constants=None, variables=None)">
|
||
Substitutes variables with constants or other variables.
|
||
|
||
**Parameters**
|
||
|
||
* **constants** (`Optional`\[`Dict`\[`Union`\[`int`, `str`], `float`]]) – replace variable by constant e.g., \{‘x’: 2} means ‘x’ is substituted with 2
|
||
* **variables** (`Optional`\[`Dict`\[`Union`\[`str`, `int`], `Tuple`\[`Union`\[`str`, `int`], `float`]]]) – 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
|
||
|
||
**Return type**
|
||
|
||
`QuadraticProgram`
|
||
|
||
**Returns**
|
||
|
||
An optimization problem by substituting variables with constants or other variables. If the substitution is valid, QuadraticProgram.status is still QuadraticProgram.Status.VALIAD. Otherwise, it gets QuadraticProgram.Status.INFEASIBLE.
|
||
|
||
**Raises**
|
||
|
||
[**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if the substitution is invalid as follows. - Same variable is substituted multiple times. - Coefficient of variable substitution is zero.
|
||
</Function>
|
||
|
||
### to\_docplex
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.to_docplex" signature="to_docplex()">
|
||
Returns a docplex model corresponding to this quadratic program.
|
||
|
||
**Return type**
|
||
|
||
`Model`
|
||
|
||
**Returns**
|
||
|
||
The docplex model corresponding to this quadratic program.
|
||
|
||
**Raises**
|
||
|
||
[**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – if non-supported elements (should never happen).
|
||
</Function>
|
||
|
||
### to\_ising
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.to_ising" signature="to_ising()">
|
||
Return the Ising Hamiltonian of this problem.
|
||
|
||
**Returns**
|
||
|
||
The qubit operator for the problem offset: The constant value in the Ising Hamiltonian.
|
||
|
||
**Return type**
|
||
|
||
qubit\_op
|
||
|
||
**Raises**
|
||
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – If a variable type is not binary.
|
||
* [**QiskitOptimizationError**](qiskit.optimization.QiskitOptimizationError "qiskit.optimization.QiskitOptimizationError") – If constraints exist in the problem.
|
||
</Function>
|
||
|
||
### variables
|
||
|
||
<Attribute id="qiskit.optimization.problems.QuadraticProgram.variables">
|
||
Returns the list of variables of the quadratic program.
|
||
|
||
**Return type**
|
||
|
||
`List`\[`Variable`]
|
||
|
||
**Returns**
|
||
|
||
List of variables.
|
||
</Attribute>
|
||
|
||
### variables\_index
|
||
|
||
<Attribute id="qiskit.optimization.problems.QuadraticProgram.variables_index">
|
||
Returns the dictionary that maps the name of a variable to its index.
|
||
|
||
**Return type**
|
||
|
||
`Dict`\[`str`, `int`]
|
||
|
||
**Returns**
|
||
|
||
The variable index dictionary.
|
||
</Attribute>
|
||
|
||
### write\_to\_lp\_file
|
||
|
||
<Function id="qiskit.optimization.problems.QuadraticProgram.write_to_lp_file" signature="write_to_lp_file(filename)">
|
||
Writes the quadratic program to an LP file.
|
||
|
||
**Parameters**
|
||
|
||
**filename** (`str`) – The filename of the file the model is written to. If filename is a directory, file name ‘my\_problem.lp’ is appended. If filename does not end with ‘.lp’, suffix ‘.lp’ is appended.
|
||
|
||
**Raises**
|
||
|
||
* **OSError** – If this cannot open a file.
|
||
* **DOcplexException** – If filename is an empty string
|
||
|
||
**Return type**
|
||
|
||
`None`
|
||
</Function>
|
||
</Class>
|
||
|