DataType - underlying data type, should implement the interface IntegerIdentifiedDatapublic class SubsetProblem<DataType extends IntegerIdentifiedData> extends GenericProblem<SubsetSolution,DataType>
GenericProblem).
All items in the data set are identified using a unique integer ID so that any subset selection problem comes down to
selection of a subset of these IDs. The solution type is fixed to SubsetSolution and the data type can be set
to any implementation of the IntegerIdentifiedData interface. When creating the problem, the minimum and maximum
allowed subset size are specified. A default random solution generator is used, which generates random subsets within
the imposed size limits, based on the IDs of the items as retrieved from the underlying data. An additional method is
provided to generate subset solutions with an empty selection.| Constructor and Description |
|---|
SubsetProblem(DataType data,
Objective<? super SubsetSolution,? super DataType> objective)
Creates a subset problem without subset size limits.
|
SubsetProblem(DataType data,
Objective<? super SubsetSolution,? super DataType> objective,
int fixedSubsetSize)
Creates a subset problem with fixed subset size.
|
SubsetProblem(DataType data,
Objective<? super SubsetSolution,? super DataType> objective,
int minSubsetSize,
int maxSubsetSize)
Creates a new subset problem with given data, objective and minimum/maximum subset size.
|
SubsetProblem(DataType data,
Objective<? super SubsetSolution,? super DataType> objective,
int minSubsetSize,
int maxSubsetSize,
boolean orderIDs)
Creates a new subset problem with given data, objective and minimum/maximum subset size.
|
SubsetProblem(DataType data,
Objective<? super SubsetSolution,? super DataType> objective,
int minSubsetSize,
int maxSubsetSize,
Comparator<Integer> orderOfIDs)
Creates a new subset problem with given data, objective and minimum/maximum subset size.
|
| Modifier and Type | Method and Description |
|---|---|
SubsetSolution |
createEmptySubsetSolution()
Creates an empty subset solution in which no IDs are selected.
|
int |
getMaxSubsetSize()
Get the maximum subset size.
|
int |
getMinSubsetSize()
Get the minimum subset size.
|
void |
setData(DataType data)
Set new data.
|
void |
setMaxSubsetSize(int maxSubsetSize)
Set the maximum subset size.
|
void |
setMinSubsetSize(int minSubsetSize)
Set the minimum subset size.
|
SubsetValidation |
validate(Move<? super SubsetSolution> move,
SubsetSolution curSolution,
Validation curValidation)
Validate a move to be applied to the current subset solution of a local search (delta validation).
|
SubsetValidation |
validate(SubsetSolution solution)
Validate a subset solution.
|
addMandatoryConstraint, addPenalizingConstraint, createRandomSolution, evaluate, evaluate, getData, getMandatoryConstraints, getObjective, getPenalizingConstraints, getRandomSolutionGenerator, getViolatedConstraints, isMinimizing, removeMandatoryConstraint, removePenalizingConstraint, setObjective, setRandomSolutionGeneratorclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateRandomSolutionpublic SubsetProblem(DataType data, Objective<? super SubsetSolution,? super DataType> objective, int minSubsetSize, int maxSubsetSize, Comparator<Integer> orderOfIDs)
Creates a new subset problem with given data, objective and minimum/maximum subset size. Both objective
and data are not allowed to be null, an exception will be thrown if they are. Any objective
designed to evaluate subset solutions (or more general solutions) using the specified data type (or more general data)
is accepted. The minimum and maximum subset size should be contained in [0,n] where n
is the number of items in the given data from which a subset is to be selected. Also, the minimum size
should be smaller than or equal to the maximum size.
The given comparator orderOfIDs is used to impose an ordering on the IDs in generated subset solutions.
This argument may be null in which case no ordering is imposed.
data - underlying data, can not be nullobjective - objective function, can not be nullminSubsetSize - minimum subset size (should be ≥ 0 and ≤ maximum subset size)maxSubsetSize - maximum subset size (should be ≥ minimum subset size and ≤ number of items in underlying data)orderOfIDs - the order that is imposed on the IDs in any generated subset solution, may be null
in case no order is to be imposedNullPointerException - if objective or data is nullIllegalArgumentException - if an invalid minimum or maximum subset size is specifiedpublic SubsetProblem(DataType data, Objective<? super SubsetSolution,? super DataType> objective, int minSubsetSize, int maxSubsetSize, boolean orderIDs)
Creates a new subset problem with given data, objective and minimum/maximum subset size. Both objective
and data are not allowed to be null, an exception will be thrown if they are. Any objective
designed to evaluate subset solutions (or more general solutions) using the specified data type (or more general data)
is accepted. The minimum and maximum subset size should be contained in [0,n] where n
is the number of items in the given data from which a subset is to be selected. Also, the minimum size
should be smaller than or equal to the maximum size.
If orderIDs is true, subset solutions generated by this problem will order IDs
in ascending order (according to the natural integer ordering).
data - underlying data, can not be nullobjective - objective function, can not be nullminSubsetSize - minimum subset size (should be ≥ 0 and ≤ maximum subset size)maxSubsetSize - maximum subset size (should be ≥ minimum subset size and ≤ number of items in underlying data)orderIDs - indicates whether IDs are ordered (ascending) in generated subset solutionsNullPointerException - if objective or data is nullIllegalArgumentException - if an invalid minimum or maximum subset size is specifiedpublic SubsetProblem(DataType data, Objective<? super SubsetSolution,? super DataType> objective, int minSubsetSize, int maxSubsetSize)
objective
and data are not allowed to be null, an exception will be thrown if they are. Any objective
designed to evaluate subset solutions (or more general solutions) using the specified data type (or more general data)
is accepted. The minimum and maximum subset size should be contained in [0,n] where n
is the number of items in the given data from which a subset is to be selected. Also, the minimum size
should be smaller than or equal to the maximum size. Generated subset solutions do not impose any
order on the IDs.data - underlying data, can not be nullobjective - objective function, can not be nullminSubsetSize - minimum subset size (should be ≥ 0 and ≤ maximum subset size)maxSubsetSize - maximum subset size (should be ≥ minimum subset size and ≤ number of items in underlying data)NullPointerException - if objective or data is nullIllegalArgumentException - if an invalid minimum or maximum subset size is specifiedpublic SubsetProblem(DataType data, Objective<? super SubsetSolution,? super DataType> objective, int fixedSubsetSize)
SubsetProblem p = new SubsetProblem(data, objective, fixedSubsetSize, fixedSubsetSize);The fixed subset size should be contained in
[0,n] where n
is the number of items in the given data from which a subset is to be selected.
Generated subset solutions do not impose any order on the IDs.data - underlying data, can not be nullobjective - objective function, can not be nullfixedSubsetSize - fixed subset sizeNullPointerException - if objective or data is nullIllegalArgumentException - if an invalid fixed subset size is specifiedpublic SubsetProblem(DataType data, Objective<? super SubsetSolution,? super DataType> objective)
SubsetProblem p = new SubsetProblem(data, objective, 0, data.getIDs().size());Generated subset solutions do not impose any order on the IDs.
data - underlying data, can not be nullobjective - objective function, can not be nullNullPointerException - if objective or data is nullIllegalArgumentException - if an invalid fixed subset size is specifiedpublic void setData(DataType data)
setData in class GenericProblem<SubsetSolution,DataType extends IntegerIdentifiedData>data - new data (can not be null)NullPointerException - if data is nullpublic SubsetSolution createEmptySubsetSolution()
public SubsetValidation validate(SubsetSolution solution)
validate in interface Problem<SubsetSolution>validate in class GenericProblem<SubsetSolution,DataType extends IntegerIdentifiedData>solution - solution to validatepublic SubsetValidation validate(Move<? super SubsetSolution> move, SubsetSolution curSolution, Validation curValidation)
SubsetMove. If the
received move has a different type an IncompatibleDeltaValidationException is thrown.validate in interface Problem<SubsetSolution>validate in class GenericProblem<SubsetSolution,DataType extends IntegerIdentifiedData>move - subset move to be validatedcurSolution - current solutioncurValidation - current validationIncompatibleDeltaValidationException - if the received move is not of type SubsetMove
or if the delta validation of any mandatory constraint
is not compatible with the received move typepublic int getMinSubsetSize()
public void setMinSubsetSize(int minSubsetSize)
minSubsetSize - new minimum subset sizeIllegalArgumentException - if an invalid minimum size is givenpublic int getMaxSubsetSize()
public void setMaxSubsetSize(int maxSubsetSize)
maxSubsetSize - new maximum subset sizeIllegalArgumentException - if an invalid maximum size is givenCopyright © 2016. All rights reserved.