java.lang.Object
org.maxicp.cp.engine.core.AbstractCPConstraint
org.maxicp.cp.engine.constraints.LightBinaryKnapsack
- All Implemented Interfaces:
CPConstraint,ConcreteConstraint<ConcreteCPModel>
Lightweight Binary Knapsack constraint enforcing
load = sum_i items[i] * weights[i]
using bound reasoning on the required and possible loads.-
Constructor Summary
ConstructorsConstructorDescriptionLightBinaryKnapsack(CPBoolVar[] items, int[] weights, CPIntVar load) Creates a lightweight binary knapsack constraintload = sum_i items[i] * weights[i]. -
Method Summary
Methods inherited from class org.maxicp.cp.engine.core.AbstractCPConstraint
getSolver, isActive, isScheduled, priority, registerDelta, setActive, setScheduled, updateDeltas
-
Constructor Details
-
LightBinaryKnapsack
Creates a lightweight binary knapsack constraintload = sum_i items[i] * weights[i].- Parameters:
items- the binary selection variables for each itemweights- the weight of each itemload- the total weight variable of the selected items
-
-
Method Details
-
post
public void post()Description copied from interface:CPConstraintInitializes the constraint when it is posted to the solver.- Specified by:
postin interfaceCPConstraint- Overrides:
postin classAbstractCPConstraint
-
propagate
public void propagate()Description copied from interface:CPConstraintPropagates the constraint.- Specified by:
propagatein interfaceCPConstraint- Overrides:
propagatein classAbstractCPConstraint
-