Annotation Interface PlanningVariable
The property must be an object type. Primitive types (such as int, double, long) are not allowed.
It is specified on a getter of a java bean property (or directly on a field) of a PlanningEntity class.
It is sometimes referred to as the "basic" planning variable,
to distinguish it from a list variable.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic interfaceDeprecated, for removal: This API element is subject to removal in a future version.static interfaceDeprecated, for removal: This API element is subject to removal in a future version.Deprecated in favor ofPlanningVariable.NullComparatorFactory. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanA variable will automatically add the planning value null to theValueRangeProvider's range.Class<? extends Comparator>Allows sorting a collection of planning values for this variable.Class<? extends ComparatorFactory>TheComparatorFactoryalternative forcomparatorClass().Deprecated, for removal: This API element is subject to removal in a future version.Chained variable is deprecated.booleanDeprecated, for removal: This API element is subject to removal in a future version.UseallowsUnassigned()instead.Class<? extends Comparator>Deprecated, for removal: This API element is subject to removal in a future version.Deprecated in favor ofcomparatorClass().Class<? extends SelectionSorterWeightFactory>Deprecated, for removal: This API element is subject to removal in a future version.Deprecated in favor ofcomparatorFactoryClass().String[]AnyValueRangeProviderannotation on aPlanningSolutionorPlanningEntitywill automatically be registered with itsValueRangeProvider.id().
-
Element Details
-
valueRangeProviderRefs
String[] valueRangeProviderRefsAnyValueRangeProviderannotation on aPlanningSolutionorPlanningEntitywill automatically be registered with itsValueRangeProvider.id().If no refs are provided, all
ValueRangeProviders without an id will be registered, provided their return types match the type of this variable.- Returns:
- 0 or more registered
ValueRangeProvider.id()
- Default:
- {}
-
allowsUnassigned
boolean allowsUnassignedA variable will automatically add the planning value null to theValueRangeProvider's range.Allowing unassigned is not compatible with
PlanningVariableGraphType.CHAINEDtrue. Allowing unassigned is not compatible with a primitive property type.- Returns:
- true if null is a valid value for this planning variable
- See Also:
- Default:
- false
-
graphType
Deprecated, for removal: This API element is subject to removal in a future version.Chained variable is deprecated. Uselist variableinstead.In some use cases, such as Vehicle Routing, planning entities form a specific graph type, as specified byPlanningVariableGraphType.- Returns:
- never null, defaults to
PlanningVariableGraphType.NONE
- Default:
- NONE
-
comparatorClass
Class<? extends Comparator> comparatorClassAllows sorting a collection of planning values for this variable. Some algorithms perform better when the values are sorted based on specific metrics.The
Comparatorshould sort the data in ascending order. For example, prioritize three visits by sorting them based on their importance: Visit C (SMALL_PRIORITY), Visit A (MEDIUM_PRIORITY), Visit B (HIGH_PRIORITY)Do not use together with
comparatorFactoryClass().- Returns:
PlanningVariable.NullComparatorwhen it is null (workaround for annotation limitation)- See Also:
- Default:
- ai.timefold.solver.core.api.domain.variable.PlanningVariable.NullComparator.class
-
comparatorFactoryClass
Class<? extends ComparatorFactory> comparatorFactoryClassTheComparatorFactoryalternative forcomparatorClass().Differs from
comparatorClass()because it allows accessing the current solution when creating the comparator.Do not use together with
comparatorClass().- Returns:
PlanningVariable.NullComparatorFactorywhen it is null (workaround for annotation limitation)- See Also:
- Default:
- ai.timefold.solver.core.api.domain.variable.PlanningVariable.NullComparatorFactory.class
-
nullable
Deprecated, for removal: This API element is subject to removal in a future version.UseallowsUnassigned()instead.As defined byallowsUnassigned().- Returns:
- true if null is a valid value for this planning variable
- Default:
- false
-
strengthComparatorClass
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated in favor ofcomparatorClass().Allows a collection of planning values for this variable to be sorted by strength. A strengthWeight estimates how strong a planning value is. Some algorithms benefit from planning on weaker planning values first or from focusing on them.The
Comparatorshould sort in ascending strength. For example: sorting 3 computers on strength based on their RAM capacity: Computer B (1GB RAM), Computer A (2GB RAM), Computer C (7GB RAM),Do not use together with
strengthWeightFactoryClass().- Returns:
PlanningVariable.NullStrengthComparatorwhen it is null (workaround for annotation limitation)- See Also:
- Default:
- ai.timefold.solver.core.api.domain.variable.PlanningVariable.NullStrengthComparator.class
-
strengthWeightFactoryClass
@Deprecated(forRemoval=true, since="1.28.0") Class<? extends SelectionSorterWeightFactory> strengthWeightFactoryClassDeprecated, for removal: This API element is subject to removal in a future version.Deprecated in favor ofcomparatorFactoryClass().TheSelectionSorterWeightFactoryalternative forstrengthComparatorClass().Do not use together with
strengthComparatorClass().- Returns:
PlanningVariable.NullStrengthWeightFactorywhen it is null (workaround for annotation limitation)- See Also:
- Default:
- ai.timefold.solver.core.api.domain.variable.PlanningVariable.NullStrengthWeightFactory.class
-
PlanningVariable.NullComparator.