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.
- প্যারামিটার:
name (str) -- The name of the quadratic program.
Attributes
Returns the list of linear constraints of the quadratic program.
Returns the dictionary that maps the name of a linear constraint to its index.
Returns the name of the quadratic program.
Returns the quadratic objective.
Returns the list of quadratic constraints of the quadratic program.
Returns the dictionary that maps the name of a quadratic constraint to its index.
Status of the quadratic program.
Returns the list of variables of the quadratic program.
Returns the dictionary that maps the name of a variable to its index.
Methods
binary_var
([name])Adds a binary variable to the quadratic program.
binary_var_dict
(keys[, name, key_format])Uses 'var_dict' to construct a dictionary of binary variables
binary_var_list
(keys[, name, key_format])Uses 'var_list' to construct a list of binary variables
clear
()Clears the quadratic program, i.e., deletes all variables, constraints, the objective function as well as the name.
continuous_var
([lowerbound, upperbound, name])Adds a continuous variable to the quadratic program.
continuous_var_dict
(keys[, lowerbound, ...])Uses 'var_dict' to construct a dictionary of continuous variables
continuous_var_list
(keys[, lowerbound, ...])Uses 'var_list' to construct a list of continuous variables
Returns the quadratic program as a string of LP format.
from_ising
(qubit_op[, offset, linear])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.
get_num_vars
([vartype])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.
get_variable
(i)Returns a variable for a given name or index.
integer_var
([lowerbound, upperbound, name])Adds an integer variable to the quadratic program.
integer_var_dict
(keys[, lowerbound, ...])Uses 'var_dict' to construct a dictionary of integer variables
integer_var_list
(keys[, lowerbound, ...])Uses 'var_list' to construct a list of integer variables
is_feasible
(x)Returns whether a solution is feasible or not.
linear_constraint
([linear, sense, rhs, name])Adds a linear equality constraint to the quadratic program of the form:
maximize
([constant, linear, quadratic])Sets a quadratic objective to be maximized.
minimize
([constant, linear, quadratic])Sets a quadratic objective to be minimized.
prettyprint
([wrap])Returns a pretty printed string of this problem.
quadratic_constraint
([linear, quadratic, ...])Adds a quadratic equality constraint to the quadratic program of the form:
read_from_lp_file
(filename)Loads the quadratic program from a LP file.
Remove a linear constraint
Remove a quadratic constraint
substitute_variables
([constants, variables])Substitutes variables with constants or other variables.
to_ising
()Return the Ising Hamiltonian of this problem.
write_to_lp_file
(filename)Writes the quadratic program to an LP file.