citrine.informatics.constraints.ingredient_ratio_constraint module

class citrine.informatics.constraints.ingredient_ratio_constraint.IngredientRatioConstraint(*, formulation_descriptor: FormulationDescriptor, min: float, max: float, ingredient: Tuple[str, float] | None = None, label: Tuple[str, float] | None = None, basis_ingredients: Set[str] = {}, basis_labels: Set[str] = {})

Bases: Serializable[IngredientRatioConstraint], Constraint

A formulation constraint operating on the ratio of quantities of ingredients and a basis.

Example: “6 to 7 parts ingredient A per 100 parts ingredient B” becomes

IngredientRatioConstraint(min=6, max=7, ingredient=("A", 100), basis_ingredients=["B"])
Parameters:
  • formulation_descriptor (FormulationDescriptor) – descriptor to constrain

  • min (float) – minimum value for the ratio

  • max (float) – maximum value for the ratio

  • ingredient (Optional[tuple[str, float]]) – multiplier for an ingredient in the numerator of the ratio

  • label (Optional[tuple[str, float]]) – multiplier for a label in the numerator of the ratio

  • basis_ingredients (Optional[Union[list[str], dict[str, float]]]) – the ingredients which should appear in the denominator of the ratio

  • basis_labels (Optional[Union[list[str], dict[str, float]]]) – the labels which should appear in the denominator of the ratio

classmethod build(data: dict) Self

Build an instance of this object from given data.

dump() dict

Dump this instance.

classmethod get_type(data)

Return the subtype.

property basis_ingredient_names: Set[str]

Retrieve the names of all ingredients in the denominator of the ratio.

property basis_ingredients: Set[str]

Retrieve the ingredients in the denominator of the ratio.

property basis_label_names: Set[str]

Retrieve the names of all labels in the denominator of the ratio.

property basis_labels: Set[str]

Retrieve the labels in the denominator of the ratio.

formulation_descriptor = None
property ingredient

Retrieve the ingredient and its multiplier from the numerator, if it’s been set.

property label

Retrieve the label and its multiplier from the numerator, if it’s been set.

max = None
min = None
typ = 'IngredientRatio'