Class COptQuestAssignmentVariable
m items to one of
n bins. Use an assignment variable when the decision is an assignment of items to
bins, such as jobs to machines or tasks to workers.
The engine adds the assignment rules to the model as constraints, so a solution that does not meet a rule is infeasible. An item that must be in a bin is in exactly one bin, and any other item is in at most one bin. Each bin holds from its smallest to its largest number of items.
Variable names: <name>@1 to <name>@m, one for each item. The value of
each name is the number of the bin that the item is in, counted from 1, or 0 when the item is in
no bin.
In a suggested solution, the engine rounds each value to the nearest bin index, and it
puts an item whose value is outside 1 to n in no bin. The engine can then change the
assignment so that it meets the rules.
In most programs, you add this variable with one of the
OptQuestModel.AddAssignmentVariable
methods and read its values with OptQuestSolution.GetValue(String) and the generated
names. Construct this class only when you add the variable with
COptQuestOptimization.AddVariable(COptQuestVariable).
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCOptQuestAssignmentVariable(String name, int m, int n) Creates an assignment variable in which every item is in exactly one bin, and a bin can hold any number of items.COptQuestAssignmentVariable(String name, int m, int n, boolean[] mustAssign, int[] binCapacitiesMin, int[] binCapacitiesMax) Creates an assignment variable with separate rules for each item and each bin.COptQuestAssignmentVariable(String name, int m, int n, boolean mustAssign, int binCapacityMin, int binCapacityMax) Creates an assignment variable with the same rules for every item and every bin. -
Method Summary
Modifier and TypeMethodDescriptionReturns the constraints that this manifold variable adds to the model.Returns an empty list, because an assignment variable has no ordinary input variables.Returns an empty list, because an assignment variable has no output variables.Returns the decision values of this manifold variable that are not ordinary decision variables.Methods inherited from class com.opttek.optquest.COptQuestUserControlledVariable
GetReplicationStatistic, GetReplicationStatisticValue, SetExclusiveRange, SetLowerBound, SetReplicationStatistic, SetUpperBoundMethods inherited from class com.opttek.optquest.COptQuestVariable
equals, GetDOELowerBound, GetDOEUpperBound, GetExclusiveLowerBoundAt, GetExclusiveUpperBoundAt, getID, GetLowerBound, GetName, GetNumberOfExclusiveRanges, GetStepSize, GetSuggestedValue, GetUpperBound, getVarRange, hashCode, isZeroOne, SetName
-
Constructor Details
-
COptQuestAssignmentVariable
public COptQuestAssignmentVariable(String name, int m, int n, boolean[] mustAssign, int[] binCapacitiesMin, int[] binCapacitiesMax) throws COptQuestException Creates an assignment variable with separate rules for each item and each bin. Item i is in exactly one bin whenmustAssign[i]is true, and in at most one bin when it is false. Bin j holds frombinCapacitiesMin[j]tobinCapacitiesMax[j]items.- Parameters:
name- base name of the variablem- number of items; must be at least 1n- number of bins; must be at least 1mustAssign- one entry for each item: true if the item must be in a bin, false if it can be in no binbinCapacitiesMin- one entry for each bin: the smallest number of items in the binbinCapacitiesMax- one entry for each bin: the largest number of items in the bin- Throws:
COptQuestException- ifmornis less than 1, if an array is null or does not have one entry for each item or bin, if a bin maximum is negative or less than its minimum, if the bin minimums add up to more thanmitems, or if the bins cannot hold every item that must be assigned
-
COptQuestAssignmentVariable
public COptQuestAssignmentVariable(String name, int m, int n, boolean mustAssign, int binCapacityMin, int binCapacityMax) throws COptQuestException Creates an assignment variable with the same rules for every item and every bin. WhenmustAssignis true, every item is in exactly one bin. When it is false, every item is in at most one bin. Every bin holds frombinCapacityMintobinCapacityMaxitems.- Parameters:
name- base name of the variablem- number of items; must be at least 1n- number of bins; must be at least 1mustAssign- true if every item must be in a bin, false if an item can be in no binbinCapacityMin- smallest number of items in each binbinCapacityMax- largest number of items in each bin- Throws:
COptQuestException- ifmornis less than 1, ifbinCapacityMaxis negative or less thanbinCapacityMin, if the bin minimums add up to more thanmitems, or ifmustAssignis true and the bins cannot hold every item
-
COptQuestAssignmentVariable
Creates an assignment variable in which every item is in exactly one bin, and a bin can hold any number of items.- Parameters:
name- base name of the variablem- number of items; must be at least 1n- number of bins; must be at least 1- Throws:
COptQuestException- ifmornis less than 1
-
-
Method Details
-
getInputVariables
Returns an empty list, because an assignment variable has no ordinary input variables.The values of an assignment variable are in the list that
getProjectedInputVariables()returns. That list has the variables<name>@1to<name>@m, one for each item.- Returns:
- an empty list
-
getOutputVariables
Returns an empty list, because an assignment variable has no output variables.The values of an assignment variable are in the list that
getProjectedInputVariables()returns. That list has the variables<name>@1to<name>@m, one for each item.- Returns:
- an empty list
-
getProjectedInputVariables
Description copied from class:COptQuestManifoldVariableReturns the decision values of this manifold variable that are not ordinary decision variables.For example, an angle variable returns
angle@theta, and a mixture variable returns onemix@<component>name for each component. In every solution that the engine generates, and in every suggested solution, these values are inside the set of the variable. Your evaluator reads them as inputs:OptQuestSolution.GetInputNames()returns them.A constraint that uses one of these names is checked after the evaluation, like a constraint on an output. Your evaluator can receive values that break the constraint, and the solution is then infeasible.
- Specified by:
getProjectedInputVariablesin classCOptQuestManifoldVariable- Returns:
- fixed-size or immutable list of these variables; never
null
-
getConstraints
Description copied from class:COptQuestManifoldVariableReturns the constraints that this manifold variable adds to the model.The engine adds these constraints to the model when the variable is added. Most manifold variable types add no constraints and return an empty list.
- Overrides:
getConstraintsin classCOptQuestManifoldVariable- Returns:
- list of constraints; never
null
-