QuadraticProgram¶
-
class
QuadraticProgram
(name='')[source]¶ Bases:
object
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.
Methods
Adds a binary variable to the quadratic program.
Uses ‘var_dict’ to construct a dictionary of binary variables
Uses ‘var_list’ to construct a list of binary variables
Clears the quadratic program, i.e., deletes all variables, constraints, the objective function as well as the name.
Adds a continuous variable to the quadratic program.
Uses ‘var_dict’ to construct a dictionary of continuous variables
Uses ‘var_list’ to construct a list of continuous variables
Returns the quadratic program as a string of LP format.
Loads this quadratic program from a docplex model.
Create a quadratic program from a qubit operator and a shift value.
Returns whether a solution is feasible or not along with the violations.
Returns a linear constraint for a given name or index.
Returns the total number of binary variables.
Returns the total number of continuous variables.
Returns the total number of integer variables.
Returns the number of linear constraints.
Returns the number of quadratic constraints.
Returns the total number of variables or the number of variables of the specified type.
Returns a quadratic constraint for a given name or index.
Returns a variable for a given name or index.
Adds an integer variable to the quadratic program.
Uses ‘var_dict’ to construct a dictionary of integer variables
Uses ‘var_list’ to construct a dictionary of integer variables
Returns whether a solution is feasible or not.
Adds a linear equality constraint to the quadratic program of the form:
Sets a quadratic objective to be maximized.
Sets a quadratic objective to be minimized.
DEPRECATED Returns the quadratic program as a string in Docplex’s pretty print format.
DEPRECATED Pretty prints the quadratic program to a given output stream (None = default).
Adds a quadratic equality constraint to the quadratic program of the form:
Loads the quadratic program from a LP file.
Remove a linear constraint
Remove a quadratic constraint
Substitutes variables with constants or other variables.
Returns a docplex model corresponding to this quadratic program.
Return the Ising Hamiltonian of this problem.
Writes the quadratic program to an LP file.
Attributes
-
linear_constraints
¶ Returns the list of linear constraints of the quadratic program.
- Return type
List
[LinearConstraint
]- Returns
List of linear constraints.
-
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.
-
name
¶ Returns the name of the quadratic program.
- Return type
str
- Returns
The name of the quadratic program.
-
objective
¶ Returns the quadratic objective.
- Return type
QuadraticObjective
- Returns
The quadratic objective.
-
quadratic_constraints
¶ Returns the list of quadratic constraints of the quadratic program.
- Return type
List
[QuadraticConstraint
]- Returns
List of quadratic constraints.
-
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.
-
status
¶ Status of the quadratic program. It can be infeasible due to variable substitution.
- Return type
QuadraticProgramStatus
- Returns
The status of the quadratic program
-
variables
¶ Returns the list of variables of the quadratic program.
- Return type
List
[Variable
]- Returns
List of variables.
-
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.