pubo_builder
class BinaryModel
BinaryModel(coeff: 'dict[tuple[int, ...], float]', constant: 'float')
normalize (self, factor) -> -
class Constraint
Constraint(name: 'str', condition: 'subs_expr.ConstraintCondition', forall: 'list[tuple[subs_expr.Element, subs_expr.SubstitutableCondition]]')
class PuboBuilder
A class to build a PUBO from a problem and an instance.
Attributes
- objective(BinaryModel) : a binary model of the objective function
- linear_penalty(dict[str, dict[tuple[int, ...], BinaryModel]]) : a binary model of linear penalties
- penalty(dict[str, dict[tuple[int, ...], BinaryModel]]) : a binary model of penalties
- custom_penalty(dict[str, dict[tuple[int, ...], BinaryModel]]) : a binary model of custom penalties
- binary_encoder(dict[str, IntegerEncoder]) : a binary encoder for each variable
- constraint_expr(dict[str, jm.Constraint]) : a constraint expression
- obj_norm(float) : a normalization factor of the objective function
- const_norm(dict[str, dict[tuple[int, ...], float]]) : a normalization factor of constraints
- pena_norm(dict[str, dict[tuple[int, ...], float]]) : a normalization factor of penalties
get_hubo_dict (self, multipliers, detail_parameters) -> tuple[dict[tuple[int, ...], float], float]
Get a HUBO from the built PUBO.
A constraint with label=const
is converted to a penalty term by the following equation:
where and are detail parameters for each constraint and is uniformal weight for each penalties.
is parameters provided to set the weights for each penalty,
independently of the index of the constraint and penalty.
You can set using multipliers
.
By default .
The weight of parameters and are set by detail_parameters
.
By default, and for the penalty is converted from equality constraint,
and and for the penalty is converted from inequality constraint.
For example, the following constraint
is converted to the following penalty term with multipliers={"onehot": 1}
and detail_parameters={"onehot": {(1,): (1/2, 1)}}
that means and :
Parameters
- multipliers(dict[str, float]) : a multiplier for each penalty. Defaults to None.
- detail_parameters(dict[str, dict[tuple[int, ...], tuple[float, float]]]) : detail parameters for each penalty. Defaults to None.
Returns
- tuple[dict[tuple[int, ...], float], float] : a HUBO dictionary and a constant term
get_qubo_dict (self, multipliers, detail_parameters) -> dict[tuple[int, int], float]
Get a QUBO COO format dictionary.
Please see the document of get_hubo_dict
for the detail.
Parameters
- multipliers(dict[str, float]) : a multiplier for each penalty. Defaults to None.
- detail_parameters(dict[str, dict[tuple[int, ...], tuple[float, float]]]) : detail parameters for each penalty. Defaults to None.
Returns
- dict[tuple[int, int], float] : a QUBO dictionary