KnapsackConstraint#

class tagarnina.optimization.KnapsackConstraint(*, features: list[str], weights: list[float], budget: float)[source]#

Limit the weighted sum of the selected features.

The total weight of the selected features cannot exceed budget.

Parameters:
featureslist of str

Names of the features. Must be unique.

weightslist of float

Non-negative, finite weight of each feature, in the same order as features.

budgetfloat

Positive, finite budget for the total weight.

Methods

__init__(*, features, weights, budget)

Attributes

features

weights

budget