index int64 | repo_id string | file_path string | content string |
|---|---|---|---|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/PillarChangeMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.value.ValueSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"valueSelectorConfig"
})
public class PillarChangeMoveSelectorConfig extends AbstractPillarMoveSelectorConfig<PillarChangeMoveSelectorConfig> {
public static final String XML_ELEMENT_NAME = "pillarChangeMoveSelector";
@XmlElement(name = "valueSelector")
private ValueSelectorConfig valueSelectorConfig = null;
public @Nullable ValueSelectorConfig getValueSelectorConfig() {
return valueSelectorConfig;
}
public void setValueSelectorConfig(@Nullable ValueSelectorConfig valueSelectorConfig) {
this.valueSelectorConfig = valueSelectorConfig;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull PillarChangeMoveSelectorConfig withValueSelectorConfig(@NonNull ValueSelectorConfig valueSelectorConfig) {
this.setValueSelectorConfig(valueSelectorConfig);
return this;
}
@Override
public @NonNull PillarChangeMoveSelectorConfig inherit(@NonNull PillarChangeMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig());
return this;
}
@Override
public @NonNull PillarChangeMoveSelectorConfig copyConfig() {
return new PillarChangeMoveSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
visitCommonReferencedClasses(classVisitor);
if (valueSelectorConfig != null) {
valueSelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public boolean hasNearbySelectionConfig() {
return (pillarSelectorConfig != null && pillarSelectorConfig.hasNearbySelectionConfig())
|| (valueSelectorConfig != null && valueSelectorConfig.hasNearbySelectionConfig());
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + pillarSelectorConfig + ", " + valueSelectorConfig + ")";
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/PillarSwapMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic;
import java.util.List;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.entity.pillar.PillarSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"secondaryPillarSelectorConfig",
"variableNameIncludeList"
})
public class PillarSwapMoveSelectorConfig extends AbstractPillarMoveSelectorConfig<PillarSwapMoveSelectorConfig> {
public static final String XML_ELEMENT_NAME = "pillarSwapMoveSelector";
@XmlElement(name = "secondaryPillarSelector")
private PillarSelectorConfig secondaryPillarSelectorConfig = null;
@XmlElementWrapper(name = "variableNameIncludes")
@XmlElement(name = "variableNameInclude")
private List<String> variableNameIncludeList = null;
public @Nullable PillarSelectorConfig getSecondaryPillarSelectorConfig() {
return secondaryPillarSelectorConfig;
}
public void setSecondaryPillarSelectorConfig(@Nullable PillarSelectorConfig secondaryPillarSelectorConfig) {
this.secondaryPillarSelectorConfig = secondaryPillarSelectorConfig;
}
public @Nullable List<@NonNull String> getVariableNameIncludeList() {
return variableNameIncludeList;
}
public void setVariableNameIncludeList(@Nullable List<@NonNull String> variableNameIncludeList) {
this.variableNameIncludeList = variableNameIncludeList;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull PillarSwapMoveSelectorConfig
withSecondaryPillarSelectorConfig(@NonNull PillarSelectorConfig pillarSelectorConfig) {
this.setSecondaryPillarSelectorConfig(pillarSelectorConfig);
return this;
}
public @NonNull PillarSwapMoveSelectorConfig
withVariableNameIncludeList(@NonNull List<@NonNull String> variableNameIncludeList) {
this.setVariableNameIncludeList(variableNameIncludeList);
return this;
}
public @NonNull PillarSwapMoveSelectorConfig withVariableNameIncludes(@NonNull String @NonNull... variableNameIncludes) {
this.setVariableNameIncludeList(List.of(variableNameIncludes));
return this;
}
@Override
public @NonNull PillarSwapMoveSelectorConfig inherit(@NonNull PillarSwapMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
secondaryPillarSelectorConfig = ConfigUtils.inheritConfig(secondaryPillarSelectorConfig,
inheritedConfig.getSecondaryPillarSelectorConfig());
variableNameIncludeList = ConfigUtils.inheritMergeableListProperty(
variableNameIncludeList, inheritedConfig.getVariableNameIncludeList());
return this;
}
@Override
public @NonNull PillarSwapMoveSelectorConfig copyConfig() {
return new PillarSwapMoveSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
visitCommonReferencedClasses(classVisitor);
if (secondaryPillarSelectorConfig != null) {
secondaryPillarSelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public boolean hasNearbySelectionConfig() {
return (pillarSelectorConfig != null && pillarSelectorConfig.hasNearbySelectionConfig())
|| (secondaryPillarSelectorConfig != null && secondaryPillarSelectorConfig.hasNearbySelectionConfig());
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + pillarSelectorConfig
+ (secondaryPillarSelectorConfig == null ? "" : ", " + secondaryPillarSelectorConfig) + ")";
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/RuinRecreateMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.entity.EntitySelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"minimumRuinedCount",
"maximumRuinedCount",
"minimumRuinedPercentage",
"maximumRuinedPercentage",
"entitySelectorConfig",
"variableName"
})
public class RuinRecreateMoveSelectorConfig extends MoveSelectorConfig<RuinRecreateMoveSelectorConfig> {
// Determined by benchmarking on multiple datasets.
private static final int DEFAULT_MINIMUM_RUINED_COUNT = 5;
private static final int DEFAULT_MAXIMUM_RUINED_COUNT = 20;
public static final String XML_ELEMENT_NAME = "ruinRecreateMoveSelector";
protected Integer minimumRuinedCount = null;
protected Integer maximumRuinedCount = null;
protected Double minimumRuinedPercentage = null;
protected Double maximumRuinedPercentage = null;
@XmlElement(name = "entitySelector")
protected EntitySelectorConfig entitySelectorConfig = null;
protected String variableName = null;
// **************************
// Getters/Setters
// **************************
public @Nullable Integer getMinimumRuinedCount() {
return minimumRuinedCount;
}
public void setMinimumRuinedCount(@Nullable Integer minimumRuinedCount) {
this.minimumRuinedCount = minimumRuinedCount;
}
public @NonNull RuinRecreateMoveSelectorConfig withMinimumRuinedCount(@NonNull Integer minimumRuinedCount) {
this.minimumRuinedCount = minimumRuinedCount;
return this;
}
public @Nullable Integer getMaximumRuinedCount() {
return maximumRuinedCount;
}
public void setMaximumRuinedCount(@Nullable Integer maximumRuinedCount) {
this.maximumRuinedCount = maximumRuinedCount;
}
public @NonNull RuinRecreateMoveSelectorConfig withMaximumRuinedCount(@NonNull Integer maximumRuinedCount) {
this.maximumRuinedCount = maximumRuinedCount;
return this;
}
public @Nullable Double getMinimumRuinedPercentage() {
return minimumRuinedPercentage;
}
public void setMinimumRuinedPercentage(@Nullable Double minimumRuinedPercentage) {
this.minimumRuinedPercentage = minimumRuinedPercentage;
}
public @NonNull RuinRecreateMoveSelectorConfig withMinimumRuinedPercentage(@NonNull Double minimumRuinedPercentage) {
this.minimumRuinedPercentage = minimumRuinedPercentage;
return this;
}
public @Nullable Double getMaximumRuinedPercentage() {
return maximumRuinedPercentage;
}
public void setMaximumRuinedPercentage(@Nullable Double maximumRuinedPercentage) {
this.maximumRuinedPercentage = maximumRuinedPercentage;
}
public EntitySelectorConfig getEntitySelectorConfig() {
return entitySelectorConfig;
}
public void setEntitySelectorConfig(EntitySelectorConfig entitySelectorConfig) {
this.entitySelectorConfig = entitySelectorConfig;
}
public String getVariableName() {
return variableName;
}
public void setVariableName(String variableName) {
this.variableName = variableName;
}
public @NonNull RuinRecreateMoveSelectorConfig withMaximumRuinedPercentage(@NonNull Double maximumRuinedPercentage) {
this.maximumRuinedPercentage = maximumRuinedPercentage;
return this;
}
public @NonNull RuinRecreateMoveSelectorConfig
withEntitySelectorConfig(@NonNull EntitySelectorConfig entitySelectorConfig) {
this.setEntitySelectorConfig(entitySelectorConfig);
return this;
}
public @NonNull RuinRecreateMoveSelectorConfig withVariableName(@NonNull String variableName) {
this.setVariableName(variableName);
return this;
}
// **************************
// Interface methods
// **************************
@Override
public boolean hasNearbySelectionConfig() {
return false;
}
@Override
public @NonNull RuinRecreateMoveSelectorConfig copyConfig() {
return new RuinRecreateMoveSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
if (entitySelectorConfig != null) {
entitySelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public @NonNull RuinRecreateMoveSelectorConfig inherit(@NonNull RuinRecreateMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
minimumRuinedCount =
ConfigUtils.inheritOverwritableProperty(minimumRuinedCount, inheritedConfig.getMinimumRuinedCount());
maximumRuinedCount =
ConfigUtils.inheritOverwritableProperty(maximumRuinedCount, inheritedConfig.getMaximumRuinedCount());
minimumRuinedPercentage =
ConfigUtils.inheritOverwritableProperty(minimumRuinedPercentage, inheritedConfig.getMinimumRuinedPercentage());
maximumRuinedPercentage =
ConfigUtils.inheritOverwritableProperty(maximumRuinedPercentage, inheritedConfig.getMaximumRuinedPercentage());
entitySelectorConfig = ConfigUtils.inheritConfig(entitySelectorConfig, inheritedConfig.getEntitySelectorConfig());
variableName =
ConfigUtils.inheritOverwritableProperty(variableName, inheritedConfig.getVariableName());
return this;
}
public int determineMinimumRuinedCount(long entityCount) {
if (minimumRuinedCount != null) {
return minimumRuinedCount;
}
if (minimumRuinedPercentage != null) {
return (int) Math.floor(minimumRuinedPercentage * entityCount);
}
return (int) Math.min(DEFAULT_MINIMUM_RUINED_COUNT, entityCount);
}
public int determineMaximumRuinedCount(long entityCount) {
if (maximumRuinedCount != null) {
return maximumRuinedCount;
}
if (maximumRuinedPercentage != null) {
return (int) Math.floor(maximumRuinedPercentage * entityCount);
}
return (int) Math.min(DEFAULT_MAXIMUM_RUINED_COUNT, entityCount);
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/SubPillarType.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic;
import java.util.Comparator;
import jakarta.xml.bind.annotation.XmlEnum;
@XmlEnum
public enum SubPillarType {
/**
* Pillars will only be affected in their entirety.
*/
NONE,
/**
* Pillars may also be affected partially, and the resulting subpillar returned in an order according to a given
* {@link Comparator}.
*/
SEQUENCE,
/**
* Pillars may also be affected partially, the resulting subpillar returned in random order.
*/
ALL;
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/SwapMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.entity.EntitySelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.NearbyAutoConfigurationEnabled;
import ai.timefold.solver.core.config.heuristic.selector.move.NearbyUtil;
import ai.timefold.solver.core.config.util.ConfigUtils;
import ai.timefold.solver.core.impl.heuristic.selector.common.nearby.NearbyDistanceMeter;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"entitySelectorConfig",
"secondaryEntitySelectorConfig",
"variableNameIncludeList"
})
public class SwapMoveSelectorConfig
extends MoveSelectorConfig<SwapMoveSelectorConfig>
implements NearbyAutoConfigurationEnabled<SwapMoveSelectorConfig> {
public static final String XML_ELEMENT_NAME = "swapMoveSelector";
@XmlElement(name = "entitySelector")
private EntitySelectorConfig entitySelectorConfig = null;
@XmlElement(name = "secondaryEntitySelector")
private EntitySelectorConfig secondaryEntitySelectorConfig = null;
@XmlElementWrapper(name = "variableNameIncludes")
@XmlElement(name = "variableNameInclude")
private List<String> variableNameIncludeList = null;
public @Nullable EntitySelectorConfig getEntitySelectorConfig() {
return entitySelectorConfig;
}
public void setEntitySelectorConfig(@Nullable EntitySelectorConfig entitySelectorConfig) {
this.entitySelectorConfig = entitySelectorConfig;
}
public @Nullable EntitySelectorConfig getSecondaryEntitySelectorConfig() {
return secondaryEntitySelectorConfig;
}
public void setSecondaryEntitySelectorConfig(@Nullable EntitySelectorConfig secondaryEntitySelectorConfig) {
this.secondaryEntitySelectorConfig = secondaryEntitySelectorConfig;
}
public @Nullable List<@NonNull String> getVariableNameIncludeList() {
return variableNameIncludeList;
}
public void setVariableNameIncludeList(@Nullable List<@NonNull String> variableNameIncludeList) {
this.variableNameIncludeList = variableNameIncludeList;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull SwapMoveSelectorConfig withEntitySelectorConfig(@NonNull EntitySelectorConfig entitySelectorConfig) {
this.setEntitySelectorConfig(entitySelectorConfig);
return this;
}
public @NonNull SwapMoveSelectorConfig
withSecondaryEntitySelectorConfig(@NonNull EntitySelectorConfig secondaryEntitySelectorConfig) {
this.setSecondaryEntitySelectorConfig(secondaryEntitySelectorConfig);
return this;
}
public @NonNull SwapMoveSelectorConfig withVariableNameIncludes(@NonNull String @NonNull... variableNameIncludes) {
this.setVariableNameIncludeList(Arrays.asList(variableNameIncludes));
return this;
}
// ************************************************************************
// Builder methods
// ************************************************************************
@Override
public @NonNull SwapMoveSelectorConfig inherit(@NonNull SwapMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
entitySelectorConfig = ConfigUtils.inheritConfig(entitySelectorConfig, inheritedConfig.getEntitySelectorConfig());
secondaryEntitySelectorConfig = ConfigUtils.inheritConfig(secondaryEntitySelectorConfig,
inheritedConfig.getSecondaryEntitySelectorConfig());
variableNameIncludeList = ConfigUtils.inheritMergeableListProperty(
variableNameIncludeList, inheritedConfig.getVariableNameIncludeList());
return this;
}
@Override
public @NonNull SwapMoveSelectorConfig copyConfig() {
return new SwapMoveSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
visitCommonReferencedClasses(classVisitor);
if (entitySelectorConfig != null) {
entitySelectorConfig.visitReferencedClasses(classVisitor);
}
if (secondaryEntitySelectorConfig != null) {
secondaryEntitySelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public @NonNull SwapMoveSelectorConfig enableNearbySelection(
@NonNull Class<? extends NearbyDistanceMeter<?, ?>> distanceMeter,
@NonNull Random random) {
return NearbyUtil.enable(this, distanceMeter, random);
}
@Override
public boolean hasNearbySelectionConfig() {
return (entitySelectorConfig != null && entitySelectorConfig.hasNearbySelectionConfig())
|| (secondaryEntitySelectorConfig != null && secondaryEntitySelectorConfig.hasNearbySelectionConfig());
}
@Override
public boolean canEnableNearbyInMixedModels() {
return false;
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + entitySelectorConfig
+ (secondaryEntitySelectorConfig == null ? "" : ", " + secondaryEntitySelectorConfig) + ")";
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.heuristic.selector.move.generic;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/chained/KOptMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic.chained;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.entity.EntitySelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.value.ValueSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
/**
* THIS CLASS IS EXPERIMENTAL AND UNSUPPORTED.
* Backward compatibility is not guaranteed.
* It's NOT DOCUMENTED because we'll only document it when it actually works in more than 1 use case.
*
* Do not use.
*
* @see TailChainSwapMoveSelectorConfig
*/
@XmlType(propOrder = {
"entitySelectorConfig",
"valueSelectorConfig"
})
public class KOptMoveSelectorConfig extends MoveSelectorConfig<KOptMoveSelectorConfig> {
public static final String XML_ELEMENT_NAME = "kOptMoveSelector";
@XmlElement(name = "entitySelector")
private EntitySelectorConfig entitySelectorConfig = null;
/**
* Like {@link TailChainSwapMoveSelectorConfig#valueSelectorConfig} but used multiple times to create 1 move.
*/
@XmlElement(name = "valueSelector")
private ValueSelectorConfig valueSelectorConfig = null;
public @Nullable EntitySelectorConfig getEntitySelectorConfig() {
return entitySelectorConfig;
}
public void setEntitySelectorConfig(@Nullable EntitySelectorConfig entitySelectorConfig) {
this.entitySelectorConfig = entitySelectorConfig;
}
public @Nullable ValueSelectorConfig getValueSelectorConfig() {
return valueSelectorConfig;
}
public void setValueSelectorConfig(@Nullable ValueSelectorConfig valueSelectorConfig) {
this.valueSelectorConfig = valueSelectorConfig;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull KOptMoveSelectorConfig withEntitySelectorConfig(@NonNull EntitySelectorConfig entitySelectorConfig) {
this.setEntitySelectorConfig(entitySelectorConfig);
return this;
}
public @NonNull KOptMoveSelectorConfig withValueSelectorConfig(@NonNull ValueSelectorConfig valueSelectorConfig) {
this.setValueSelectorConfig(valueSelectorConfig);
return this;
}
@Override
public @NonNull KOptMoveSelectorConfig inherit(@NonNull KOptMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
entitySelectorConfig = ConfigUtils.inheritConfig(entitySelectorConfig, inheritedConfig.getEntitySelectorConfig());
valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig());
return this;
}
@Override
public @NonNull KOptMoveSelectorConfig copyConfig() {
return new KOptMoveSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
visitCommonReferencedClasses(classVisitor);
if (entitySelectorConfig != null) {
entitySelectorConfig.visitReferencedClasses(classVisitor);
}
if (valueSelectorConfig != null) {
valueSelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public boolean hasNearbySelectionConfig() {
return (entitySelectorConfig != null && entitySelectorConfig.hasNearbySelectionConfig())
|| (valueSelectorConfig != null && valueSelectorConfig.hasNearbySelectionConfig());
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + entitySelectorConfig + ", " + valueSelectorConfig + ")";
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/chained/SubChainChangeMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic.chained;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.value.ValueSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.value.chained.SubChainSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"entityClass",
"subChainSelectorConfig",
"valueSelectorConfig",
"selectReversingMoveToo"
})
public class SubChainChangeMoveSelectorConfig extends MoveSelectorConfig<SubChainChangeMoveSelectorConfig> {
public static final String XML_ELEMENT_NAME = "subChainChangeMoveSelector";
private Class<?> entityClass = null;
@XmlElement(name = "subChainSelector")
private SubChainSelectorConfig subChainSelectorConfig = null;
@XmlElement(name = "valueSelector")
private ValueSelectorConfig valueSelectorConfig = null;
private Boolean selectReversingMoveToo = null;
public @Nullable Class<?> getEntityClass() {
return entityClass;
}
public void setEntityClass(@Nullable Class<?> entityClass) {
this.entityClass = entityClass;
}
public @Nullable SubChainSelectorConfig getSubChainSelectorConfig() {
return subChainSelectorConfig;
}
public void setSubChainSelectorConfig(@Nullable SubChainSelectorConfig subChainSelectorConfig) {
this.subChainSelectorConfig = subChainSelectorConfig;
}
public @Nullable ValueSelectorConfig getValueSelectorConfig() {
return valueSelectorConfig;
}
public void setValueSelectorConfig(@Nullable ValueSelectorConfig valueSelectorConfig) {
this.valueSelectorConfig = valueSelectorConfig;
}
public @Nullable Boolean getSelectReversingMoveToo() {
return selectReversingMoveToo;
}
public void setSelectReversingMoveToo(@Nullable Boolean selectReversingMoveToo) {
this.selectReversingMoveToo = selectReversingMoveToo;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull SubChainChangeMoveSelectorConfig withEntityClass(@NonNull Class<?> entityClass) {
this.setEntityClass(entityClass);
return this;
}
public @NonNull SubChainChangeMoveSelectorConfig
withSubChainSelectorConfig(@NonNull SubChainSelectorConfig subChainSelectorConfig) {
this.setSubChainSelectorConfig(subChainSelectorConfig);
return this;
}
public @NonNull SubChainChangeMoveSelectorConfig withValueSelectorConfig(@NonNull ValueSelectorConfig valueSelectorConfig) {
this.setValueSelectorConfig(valueSelectorConfig);
return this;
}
public @NonNull SubChainChangeMoveSelectorConfig withSelectReversingMoveToo(@NonNull Boolean selectReversingMoveToo) {
this.setSelectReversingMoveToo(selectReversingMoveToo);
return this;
}
@Override
public @NonNull SubChainChangeMoveSelectorConfig inherit(@NonNull SubChainChangeMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
entityClass = ConfigUtils.inheritOverwritableProperty(entityClass, inheritedConfig.getEntityClass());
subChainSelectorConfig = ConfigUtils.inheritConfig(subChainSelectorConfig, inheritedConfig.getSubChainSelectorConfig());
valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig());
selectReversingMoveToo = ConfigUtils.inheritOverwritableProperty(selectReversingMoveToo,
inheritedConfig.getSelectReversingMoveToo());
return this;
}
@Override
public @NonNull SubChainChangeMoveSelectorConfig copyConfig() {
return new SubChainChangeMoveSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
visitCommonReferencedClasses(classVisitor);
classVisitor.accept(entityClass);
if (subChainSelectorConfig != null) {
subChainSelectorConfig.visitReferencedClasses(classVisitor);
}
if (valueSelectorConfig != null) {
valueSelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public boolean hasNearbySelectionConfig() {
return (subChainSelectorConfig != null && subChainSelectorConfig.hasNearbySelectionConfig())
|| (valueSelectorConfig != null && valueSelectorConfig.hasNearbySelectionConfig());
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + subChainSelectorConfig + ", " + valueSelectorConfig + ")";
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/chained/SubChainSwapMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic.chained;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.value.chained.SubChainSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"entityClass",
"subChainSelectorConfig",
"secondarySubChainSelectorConfig",
"selectReversingMoveToo"
})
public class SubChainSwapMoveSelectorConfig extends MoveSelectorConfig<SubChainSwapMoveSelectorConfig> {
public static final String XML_ELEMENT_NAME = "subChainSwapMoveSelector";
private Class<?> entityClass = null;
@XmlElement(name = "subChainSelector")
private SubChainSelectorConfig subChainSelectorConfig = null;
@XmlElement(name = "secondarySubChainSelector")
private SubChainSelectorConfig secondarySubChainSelectorConfig = null;
private Boolean selectReversingMoveToo = null;
public @Nullable Class<?> getEntityClass() {
return entityClass;
}
public void setEntityClass(@Nullable Class<?> entityClass) {
this.entityClass = entityClass;
}
public @Nullable SubChainSelectorConfig getSubChainSelectorConfig() {
return subChainSelectorConfig;
}
public void setSubChainSelectorConfig(@Nullable SubChainSelectorConfig subChainSelectorConfig) {
this.subChainSelectorConfig = subChainSelectorConfig;
}
public @Nullable SubChainSelectorConfig getSecondarySubChainSelectorConfig() {
return secondarySubChainSelectorConfig;
}
public void setSecondarySubChainSelectorConfig(@Nullable SubChainSelectorConfig secondarySubChainSelectorConfig) {
this.secondarySubChainSelectorConfig = secondarySubChainSelectorConfig;
}
public @Nullable Boolean getSelectReversingMoveToo() {
return selectReversingMoveToo;
}
public void setSelectReversingMoveToo(@Nullable Boolean selectReversingMoveToo) {
this.selectReversingMoveToo = selectReversingMoveToo;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull SubChainSwapMoveSelectorConfig withEntityClass(@NonNull Class<?> entityClass) {
this.setEntityClass(entityClass);
return this;
}
public @NonNull SubChainSwapMoveSelectorConfig
withSubChainSelectorConfig(@NonNull SubChainSelectorConfig subChainSelectorConfig) {
this.setSubChainSelectorConfig(subChainSelectorConfig);
return this;
}
public @NonNull SubChainSwapMoveSelectorConfig
withSecondarySubChainSelectorConfig(@NonNull SubChainSelectorConfig secondarySubChainSelectorConfig) {
this.setSecondarySubChainSelectorConfig(secondarySubChainSelectorConfig);
return this;
}
public @NonNull SubChainSwapMoveSelectorConfig withSelectReversingMoveToo(@NonNull Boolean selectReversingMoveToo) {
this.setSelectReversingMoveToo(selectReversingMoveToo);
return this;
}
@Override
public @NonNull SubChainSwapMoveSelectorConfig inherit(@NonNull SubChainSwapMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
entityClass = ConfigUtils.inheritOverwritableProperty(entityClass, inheritedConfig.getEntityClass());
subChainSelectorConfig = ConfigUtils.inheritConfig(subChainSelectorConfig, inheritedConfig.getSubChainSelectorConfig());
secondarySubChainSelectorConfig = ConfigUtils.inheritConfig(secondarySubChainSelectorConfig,
inheritedConfig.getSecondarySubChainSelectorConfig());
selectReversingMoveToo = ConfigUtils.inheritOverwritableProperty(selectReversingMoveToo,
inheritedConfig.getSelectReversingMoveToo());
return this;
}
@Override
public @NonNull SubChainSwapMoveSelectorConfig copyConfig() {
return new SubChainSwapMoveSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
visitCommonReferencedClasses(classVisitor);
classVisitor.accept(entityClass);
if (subChainSelectorConfig != null) {
subChainSelectorConfig.visitReferencedClasses(classVisitor);
}
if (secondarySubChainSelectorConfig != null) {
secondarySubChainSelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public boolean hasNearbySelectionConfig() {
return (subChainSelectorConfig != null && subChainSelectorConfig.hasNearbySelectionConfig())
|| (secondarySubChainSelectorConfig != null && secondarySubChainSelectorConfig.hasNearbySelectionConfig());
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + subChainSelectorConfig
+ (secondarySubChainSelectorConfig == null ? "" : ", " + secondarySubChainSelectorConfig) + ")";
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/chained/TailChainSwapMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic.chained;
import java.util.Random;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.entity.EntitySelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.NearbyAutoConfigurationEnabled;
import ai.timefold.solver.core.config.heuristic.selector.move.NearbyUtil;
import ai.timefold.solver.core.config.heuristic.selector.value.ValueSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import ai.timefold.solver.core.impl.heuristic.selector.common.nearby.NearbyDistanceMeter;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
/**
* Also known as a 2-opt move selector config.
*/
@XmlType(propOrder = {
"entitySelectorConfig",
"valueSelectorConfig"
})
public class TailChainSwapMoveSelectorConfig
extends MoveSelectorConfig<TailChainSwapMoveSelectorConfig>
implements NearbyAutoConfigurationEnabled<TailChainSwapMoveSelectorConfig> {
public static final String XML_ELEMENT_NAME = "tailChainSwapMoveSelector";
@XmlElement(name = "entitySelector")
private EntitySelectorConfig entitySelectorConfig = null;
/**
* Uses a valueSelector instead of a secondaryEntitySelector because
* the secondary entity might not exist if the value is a buoy (= the last entity in a chain)
* and also because with nearby selection, it's more important that the value is near (instead of the secondary entity).
*/
@XmlElement(name = "valueSelector")
private ValueSelectorConfig valueSelectorConfig = null;
public @Nullable EntitySelectorConfig getEntitySelectorConfig() {
return entitySelectorConfig;
}
public void setEntitySelectorConfig(@Nullable EntitySelectorConfig entitySelectorConfig) {
this.entitySelectorConfig = entitySelectorConfig;
}
public @Nullable ValueSelectorConfig getValueSelectorConfig() {
return valueSelectorConfig;
}
public void setValueSelectorConfig(@Nullable ValueSelectorConfig valueSelectorConfig) {
this.valueSelectorConfig = valueSelectorConfig;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull TailChainSwapMoveSelectorConfig
withEntitySelectorConfig(@NonNull EntitySelectorConfig entitySelectorConfig) {
this.entitySelectorConfig = entitySelectorConfig;
return this;
}
public @NonNull TailChainSwapMoveSelectorConfig withValueSelectorConfig(@NonNull ValueSelectorConfig valueSelectorConfig) {
this.valueSelectorConfig = valueSelectorConfig;
return this;
}
@Override
public @NonNull TailChainSwapMoveSelectorConfig inherit(@NonNull TailChainSwapMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
entitySelectorConfig = ConfigUtils.inheritConfig(entitySelectorConfig, inheritedConfig.getEntitySelectorConfig());
valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig());
return this;
}
@Override
public @NonNull TailChainSwapMoveSelectorConfig copyConfig() {
return new TailChainSwapMoveSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
visitCommonReferencedClasses(classVisitor);
if (entitySelectorConfig != null) {
entitySelectorConfig.visitReferencedClasses(classVisitor);
}
if (valueSelectorConfig != null) {
valueSelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public @NonNull TailChainSwapMoveSelectorConfig enableNearbySelection(
@NonNull Class<? extends NearbyDistanceMeter<?, ?>> distanceMeter,
@NonNull Random random) {
return NearbyUtil.enable(this, distanceMeter, random);
}
@Override
public boolean hasNearbySelectionConfig() {
return (entitySelectorConfig != null && entitySelectorConfig.hasNearbySelectionConfig())
|| (valueSelectorConfig != null && valueSelectorConfig.hasNearbySelectionConfig());
}
@Override
public boolean canEnableNearbyInMixedModels() {
return false;
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + entitySelectorConfig + ", " + valueSelectorConfig + ")";
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/chained/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.heuristic.selector.move.generic.chained;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/list/ListChangeMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic.list;
import java.util.Random;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.list.DestinationSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.NearbyAutoConfigurationEnabled;
import ai.timefold.solver.core.config.heuristic.selector.move.NearbyUtil;
import ai.timefold.solver.core.config.heuristic.selector.value.ValueSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import ai.timefold.solver.core.impl.heuristic.selector.common.nearby.NearbyDistanceMeter;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"valueSelectorConfig",
"destinationSelectorConfig"
})
public class ListChangeMoveSelectorConfig
extends MoveSelectorConfig<ListChangeMoveSelectorConfig>
implements NearbyAutoConfigurationEnabled<ListChangeMoveSelectorConfig> {
public static final String XML_ELEMENT_NAME = "listChangeMoveSelector";
@XmlElement(name = "valueSelector")
private ValueSelectorConfig valueSelectorConfig = null;
@XmlElement(name = "destinationSelector")
private DestinationSelectorConfig destinationSelectorConfig = null;
public @Nullable ValueSelectorConfig getValueSelectorConfig() {
return valueSelectorConfig;
}
public void setValueSelectorConfig(@Nullable ValueSelectorConfig valueSelectorConfig) {
this.valueSelectorConfig = valueSelectorConfig;
}
public @Nullable DestinationSelectorConfig getDestinationSelectorConfig() {
return destinationSelectorConfig;
}
public void setDestinationSelectorConfig(@Nullable DestinationSelectorConfig destinationSelectorConfig) {
this.destinationSelectorConfig = destinationSelectorConfig;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull ListChangeMoveSelectorConfig withValueSelectorConfig(@NonNull ValueSelectorConfig valueSelectorConfig) {
this.setValueSelectorConfig(valueSelectorConfig);
return this;
}
public @NonNull ListChangeMoveSelectorConfig
withDestinationSelectorConfig(@NonNull DestinationSelectorConfig destinationSelectorConfig) {
this.setDestinationSelectorConfig(destinationSelectorConfig);
return this;
}
// ************************************************************************
// Builder methods
// ************************************************************************
@Override
public @NonNull ListChangeMoveSelectorConfig inherit(@NonNull ListChangeMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig());
destinationSelectorConfig =
ConfigUtils.inheritConfig(destinationSelectorConfig, inheritedConfig.getDestinationSelectorConfig());
return this;
}
@Override
public @NonNull ListChangeMoveSelectorConfig copyConfig() {
return new ListChangeMoveSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
visitCommonReferencedClasses(classVisitor);
if (valueSelectorConfig != null) {
valueSelectorConfig.visitReferencedClasses(classVisitor);
}
if (destinationSelectorConfig != null) {
destinationSelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public @NonNull ListChangeMoveSelectorConfig enableNearbySelection(
@NonNull Class<? extends NearbyDistanceMeter<?, ?>> distanceMeter,
@NonNull Random random) {
return NearbyUtil.enable(this, distanceMeter, random);
}
@Override
public boolean hasNearbySelectionConfig() {
return (valueSelectorConfig != null && valueSelectorConfig.hasNearbySelectionConfig())
|| (destinationSelectorConfig != null && destinationSelectorConfig.hasNearbySelectionConfig());
}
@Override
public boolean canEnableNearbyInMixedModels() {
return true;
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + valueSelectorConfig + ", " + destinationSelectorConfig + ")";
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/list/ListRuinRecreateMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic.list;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"minimumRuinedCount",
"maximumRuinedCount",
"minimumRuinedPercentage",
"maximumRuinedPercentage"
})
public class ListRuinRecreateMoveSelectorConfig extends MoveSelectorConfig<ListRuinRecreateMoveSelectorConfig> {
// Determined by benchmarking on multiple datasets.
private static final int DEFAULT_MINIMUM_RUINED_COUNT = 5;
private static final int DEFAULT_MAXIMUM_RUINED_COUNT = 40;
public static final String XML_ELEMENT_NAME = "listRuinRecreateMoveSelector";
protected Integer minimumRuinedCount = null;
protected Integer maximumRuinedCount = null;
protected Double minimumRuinedPercentage = null;
protected Double maximumRuinedPercentage = null;
// **************************
// Getters/Setters
// **************************
public @Nullable Integer getMinimumRuinedCount() {
return minimumRuinedCount;
}
public void setMinimumRuinedCount(@Nullable Integer minimumRuinedCount) {
this.minimumRuinedCount = minimumRuinedCount;
}
public @NonNull ListRuinRecreateMoveSelectorConfig withMinimumRuinedCount(@NonNull Integer minimumRuinedCount) {
this.minimumRuinedCount = minimumRuinedCount;
return this;
}
public @Nullable Integer getMaximumRuinedCount() {
return maximumRuinedCount;
}
public void setMaximumRuinedCount(@Nullable Integer maximumRuinedCount) {
this.maximumRuinedCount = maximumRuinedCount;
}
public @NonNull ListRuinRecreateMoveSelectorConfig withMaximumRuinedCount(@NonNull Integer maximumRuinedCount) {
this.maximumRuinedCount = maximumRuinedCount;
return this;
}
public @Nullable Double getMinimumRuinedPercentage() {
return minimumRuinedPercentage;
}
public void setMinimumRuinedPercentage(@Nullable Double minimumRuinedPercentage) {
this.minimumRuinedPercentage = minimumRuinedPercentage;
}
public @NonNull ListRuinRecreateMoveSelectorConfig withMinimumRuinedPercentage(@NonNull Double minimumRuinedPercentage) {
this.minimumRuinedPercentage = minimumRuinedPercentage;
return this;
}
public @Nullable Double getMaximumRuinedPercentage() {
return maximumRuinedPercentage;
}
public void setMaximumRuinedPercentage(@Nullable Double maximumRuinedPercentage) {
this.maximumRuinedPercentage = maximumRuinedPercentage;
}
public @NonNull ListRuinRecreateMoveSelectorConfig withMaximumRuinedPercentage(@NonNull Double maximumRuinedPercentage) {
this.maximumRuinedPercentage = maximumRuinedPercentage;
return this;
}
// **************************
// Interface methods
// **************************
@Override
public boolean hasNearbySelectionConfig() {
return false;
}
@Override
public @NonNull ListRuinRecreateMoveSelectorConfig copyConfig() {
return new ListRuinRecreateMoveSelectorConfig().inherit(this);
}
@Override
public @NonNull ListRuinRecreateMoveSelectorConfig inherit(@NonNull ListRuinRecreateMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
minimumRuinedCount =
ConfigUtils.inheritOverwritableProperty(minimumRuinedCount, inheritedConfig.getMinimumRuinedCount());
maximumRuinedCount =
ConfigUtils.inheritOverwritableProperty(maximumRuinedCount, inheritedConfig.getMaximumRuinedCount());
minimumRuinedPercentage =
ConfigUtils.inheritOverwritableProperty(minimumRuinedPercentage, inheritedConfig.getMinimumRuinedPercentage());
maximumRuinedPercentage =
ConfigUtils.inheritOverwritableProperty(maximumRuinedPercentage, inheritedConfig.getMaximumRuinedPercentage());
return this;
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
// No referenced classes.
}
public int determineMinimumRuinedCount(long valueCount) {
if (minimumRuinedCount != null) {
return minimumRuinedCount;
}
if (minimumRuinedPercentage != null) {
return (int) Math.floor(minimumRuinedPercentage * valueCount);
}
return (int) Math.min(DEFAULT_MINIMUM_RUINED_COUNT, valueCount);
}
public int determineMaximumRuinedCount(long valueCount) {
if (maximumRuinedCount != null) {
return maximumRuinedCount;
}
if (maximumRuinedPercentage != null) {
return (int) Math.floor(maximumRuinedPercentage * valueCount);
}
return (int) Math.min(DEFAULT_MAXIMUM_RUINED_COUNT, valueCount);
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/list/ListSwapMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic.list;
import java.util.Random;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.NearbyAutoConfigurationEnabled;
import ai.timefold.solver.core.config.heuristic.selector.move.NearbyUtil;
import ai.timefold.solver.core.config.heuristic.selector.value.ValueSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import ai.timefold.solver.core.impl.heuristic.selector.common.nearby.NearbyDistanceMeter;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"valueSelectorConfig",
"secondaryValueSelectorConfig"
})
public class ListSwapMoveSelectorConfig
extends MoveSelectorConfig<ListSwapMoveSelectorConfig>
implements NearbyAutoConfigurationEnabled<ListSwapMoveSelectorConfig> {
public static final String XML_ELEMENT_NAME = "listSwapMoveSelector";
@XmlElement(name = "valueSelector")
private ValueSelectorConfig valueSelectorConfig = null;
@XmlElement(name = "secondaryValueSelector")
private ValueSelectorConfig secondaryValueSelectorConfig = null;
public @Nullable ValueSelectorConfig getValueSelectorConfig() {
return valueSelectorConfig;
}
public void setValueSelectorConfig(@Nullable ValueSelectorConfig valueSelectorConfig) {
this.valueSelectorConfig = valueSelectorConfig;
}
public @Nullable ValueSelectorConfig getSecondaryValueSelectorConfig() {
return secondaryValueSelectorConfig;
}
public void setSecondaryValueSelectorConfig(@Nullable ValueSelectorConfig secondaryValueSelectorConfig) {
this.secondaryValueSelectorConfig = secondaryValueSelectorConfig;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull ListSwapMoveSelectorConfig withValueSelectorConfig(@NonNull ValueSelectorConfig valueSelectorConfig) {
this.setValueSelectorConfig(valueSelectorConfig);
return this;
}
public @NonNull ListSwapMoveSelectorConfig
withSecondaryValueSelectorConfig(@NonNull ValueSelectorConfig secondaryValueSelectorConfig) {
this.setSecondaryValueSelectorConfig(secondaryValueSelectorConfig);
return this;
}
// ************************************************************************
// Builder methods
// ************************************************************************
@Override
public @NonNull ListSwapMoveSelectorConfig inherit(@NonNull ListSwapMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig());
secondaryValueSelectorConfig = ConfigUtils.inheritConfig(secondaryValueSelectorConfig,
inheritedConfig.getSecondaryValueSelectorConfig());
return this;
}
@Override
public @NonNull ListSwapMoveSelectorConfig copyConfig() {
return new ListSwapMoveSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
visitCommonReferencedClasses(classVisitor);
if (valueSelectorConfig != null) {
valueSelectorConfig.visitReferencedClasses(classVisitor);
}
if (secondaryValueSelectorConfig != null) {
secondaryValueSelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public @NonNull ListSwapMoveSelectorConfig enableNearbySelection(
@NonNull Class<? extends NearbyDistanceMeter<?, ?>> distanceMeter,
@NonNull Random random) {
return NearbyUtil.enable(this, distanceMeter, random);
}
@Override
public boolean hasNearbySelectionConfig() {
return (valueSelectorConfig != null && valueSelectorConfig.hasNearbySelectionConfig())
|| (secondaryValueSelectorConfig != null && secondaryValueSelectorConfig.hasNearbySelectionConfig());
}
@Override
public boolean canEnableNearbyInMixedModels() {
return true;
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + valueSelectorConfig
+ (secondaryValueSelectorConfig == null ? "" : ", " + secondaryValueSelectorConfig) + ")";
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/list/SubListChangeMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic.list;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.list.DestinationSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.list.SubListSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"minimumSubListSize",
"maximumSubListSize",
"selectReversingMoveToo",
"subListSelectorConfig",
"destinationSelectorConfig"
})
public class SubListChangeMoveSelectorConfig extends MoveSelectorConfig<SubListChangeMoveSelectorConfig> {
public static final String XML_ELEMENT_NAME = "subListChangeMoveSelector";
/**
* @deprecated The minimumSubListSize on the SubListChangeMoveSelectorConfig is deprecated and will be removed in a future
* major version of Timefold. Use {@link SubListSelectorConfig#getMinimumSubListSize()} instead.
*/
@Deprecated(forRemoval = true)
protected Integer minimumSubListSize = null;
/**
* @deprecated The maximumSubListSize on the SubListChangeMoveSelectorConfig is deprecated and will be removed in a future
* major version of Timefold. Use {@link SubListSelectorConfig#getMaximumSubListSize()} instead.
*/
@Deprecated(forRemoval = true)
protected Integer maximumSubListSize = null;
private Boolean selectReversingMoveToo = null;
@XmlElement(name = "subListSelector")
private SubListSelectorConfig subListSelectorConfig = null;
@XmlElement(name = "destinationSelector")
private DestinationSelectorConfig destinationSelectorConfig = null;
/**
* @deprecated The minimumSubListSize on the SubListChangeMoveSelectorConfig is deprecated and will be removed in a future
* major version of Timefold. Use {@link SubListSelectorConfig#getMinimumSubListSize()} instead.
*/
@Deprecated(forRemoval = true)
public Integer getMinimumSubListSize() {
return minimumSubListSize;
}
/**
* @deprecated The minimumSubListSize on the SubListChangeMoveSelectorConfig is deprecated and will be removed in a future
* major version of Timefold. Use {@link SubListSelectorConfig#setMinimumSubListSize(Integer)} instead.
*/
@Deprecated(forRemoval = true)
public void setMinimumSubListSize(Integer minimumSubListSize) {
this.minimumSubListSize = minimumSubListSize;
}
/**
* @deprecated The maximumSubListSize on the SubListChangeMoveSelectorConfig is deprecated and will be removed in a future
* major version of Timefold. Use {@link SubListSelectorConfig#getMaximumSubListSize()} instead.
*/
@Deprecated(forRemoval = true)
public Integer getMaximumSubListSize() {
return maximumSubListSize;
}
/**
* @deprecated The maximumSubListSize on the SubListChangeMoveSelectorConfig is deprecated and will be removed in a future
* major version of Timefold. Use {@link SubListSelectorConfig#setMaximumSubListSize(Integer)} instead.
*/
@Deprecated(forRemoval = true)
public void setMaximumSubListSize(Integer maximumSubListSize) {
this.maximumSubListSize = maximumSubListSize;
}
public @Nullable Boolean getSelectReversingMoveToo() {
return selectReversingMoveToo;
}
public void setSelectReversingMoveToo(@Nullable Boolean selectReversingMoveToo) {
this.selectReversingMoveToo = selectReversingMoveToo;
}
public @Nullable SubListSelectorConfig getSubListSelectorConfig() {
return subListSelectorConfig;
}
public void setSubListSelectorConfig(@Nullable SubListSelectorConfig subListSelectorConfig) {
this.subListSelectorConfig = subListSelectorConfig;
}
public @Nullable DestinationSelectorConfig getDestinationSelectorConfig() {
return destinationSelectorConfig;
}
public void setDestinationSelectorConfig(@Nullable DestinationSelectorConfig destinationSelectorConfig) {
this.destinationSelectorConfig = destinationSelectorConfig;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull SubListChangeMoveSelectorConfig withSelectReversingMoveToo(@NonNull Boolean selectReversingMoveToo) {
this.setSelectReversingMoveToo(selectReversingMoveToo);
return this;
}
public @NonNull SubListChangeMoveSelectorConfig
withSubListSelectorConfig(@NonNull SubListSelectorConfig subListSelectorConfig) {
this.setSubListSelectorConfig(subListSelectorConfig);
return this;
}
public @NonNull SubListChangeMoveSelectorConfig
withDestinationSelectorConfig(@NonNull DestinationSelectorConfig destinationSelectorConfig) {
this.setDestinationSelectorConfig(destinationSelectorConfig);
return this;
}
// ************************************************************************
// Builder methods
// ************************************************************************
@Override
public @NonNull SubListChangeMoveSelectorConfig inherit(@NonNull SubListChangeMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
this.minimumSubListSize =
ConfigUtils.inheritOverwritableProperty(minimumSubListSize, inheritedConfig.minimumSubListSize);
this.maximumSubListSize =
ConfigUtils.inheritOverwritableProperty(maximumSubListSize, inheritedConfig.maximumSubListSize);
this.selectReversingMoveToo =
ConfigUtils.inheritOverwritableProperty(selectReversingMoveToo, inheritedConfig.selectReversingMoveToo);
this.subListSelectorConfig =
ConfigUtils.inheritOverwritableProperty(subListSelectorConfig, inheritedConfig.subListSelectorConfig);
this.destinationSelectorConfig =
ConfigUtils.inheritOverwritableProperty(destinationSelectorConfig, inheritedConfig.destinationSelectorConfig);
return this;
}
@Override
public @NonNull SubListChangeMoveSelectorConfig copyConfig() {
return new SubListChangeMoveSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
visitCommonReferencedClasses(classVisitor);
if (subListSelectorConfig != null) {
subListSelectorConfig.visitReferencedClasses(classVisitor);
}
if (destinationSelectorConfig != null) {
destinationSelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public boolean hasNearbySelectionConfig() {
return (subListSelectorConfig != null && subListSelectorConfig.hasNearbySelectionConfig())
|| (destinationSelectorConfig != null && destinationSelectorConfig.hasNearbySelectionConfig());
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + subListSelectorConfig + ", " + destinationSelectorConfig + ")";
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/list/SubListSwapMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic.list;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.list.SubListSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"minimumSubListSize",
"maximumSubListSize",
"selectReversingMoveToo",
"subListSelectorConfig",
"secondarySubListSelectorConfig"
})
public class SubListSwapMoveSelectorConfig extends MoveSelectorConfig<SubListSwapMoveSelectorConfig> {
public static final String XML_ELEMENT_NAME = "subListSwapMoveSelector";
/**
* @deprecated The minimumSubListSize on the SubListSwapMoveSelectorConfig is deprecated and will be removed in a future
* major version of Timefold. Use {@link SubListSelectorConfig#getMinimumSubListSize()} instead.
*/
@Deprecated(forRemoval = true)
protected Integer minimumSubListSize = null;
/**
* @deprecated The maximumSubListSize on the SubListSwapMoveSelectorConfig is deprecated and will be removed in a future
* major version of Timefold. Use {@link SubListSelectorConfig#getMaximumSubListSize()} instead.
*/
@Deprecated(forRemoval = true)
protected Integer maximumSubListSize = null;
private Boolean selectReversingMoveToo = null;
@XmlElement(name = "subListSelector")
private SubListSelectorConfig subListSelectorConfig = null;
@XmlElement(name = "secondarySubListSelector")
private SubListSelectorConfig secondarySubListSelectorConfig = null;
/**
* @deprecated The minimumSubListSize on the SubListSwapMoveSelectorConfig is deprecated and will be removed in a future
* major version of Timefold. Use {@link SubListSelectorConfig#getMinimumSubListSize()} instead.
*/
@Deprecated(forRemoval = true)
public Integer getMinimumSubListSize() {
return minimumSubListSize;
}
/**
* @deprecated The minimumSubListSize on the SubListSwapMoveSelectorConfig is deprecated and will be removed in a future
* major version of Timefold. Use {@link SubListSelectorConfig#setMinimumSubListSize(Integer)} instead.
*/
@Deprecated(forRemoval = true)
public void setMinimumSubListSize(Integer minimumSubListSize) {
this.minimumSubListSize = minimumSubListSize;
}
/**
* @deprecated The maximumSubListSize on the SubListSwapMoveSelectorConfig is deprecated and will be removed in a future
* major version of Timefold. Use {@link SubListSelectorConfig#getMaximumSubListSize()} instead.
*/
@Deprecated(forRemoval = true)
public Integer getMaximumSubListSize() {
return maximumSubListSize;
}
/**
* @deprecated The maximumSubListSize on the SubListSwapMoveSelectorConfig is deprecated and will be removed in a future
* major version of Timefold. Use {@link SubListSelectorConfig#setMaximumSubListSize(Integer)} instead.
*/
@Deprecated(forRemoval = true)
public void setMaximumSubListSize(Integer maximumSubListSize) {
this.maximumSubListSize = maximumSubListSize;
}
public @Nullable Boolean getSelectReversingMoveToo() {
return selectReversingMoveToo;
}
public void setSelectReversingMoveToo(@Nullable Boolean selectReversingMoveToo) {
this.selectReversingMoveToo = selectReversingMoveToo;
}
public @Nullable SubListSelectorConfig getSubListSelectorConfig() {
return subListSelectorConfig;
}
public void setSubListSelectorConfig(@Nullable SubListSelectorConfig subListSelectorConfig) {
this.subListSelectorConfig = subListSelectorConfig;
}
public @Nullable SubListSelectorConfig getSecondarySubListSelectorConfig() {
return secondarySubListSelectorConfig;
}
public void setSecondarySubListSelectorConfig(@Nullable SubListSelectorConfig secondarySubListSelectorConfig) {
this.secondarySubListSelectorConfig = secondarySubListSelectorConfig;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull SubListSwapMoveSelectorConfig withSelectReversingMoveToo(@NonNull Boolean selectReversingMoveToo) {
this.setSelectReversingMoveToo(selectReversingMoveToo);
return this;
}
public @NonNull SubListSwapMoveSelectorConfig
withSubListSelectorConfig(@NonNull SubListSelectorConfig subListSelectorConfig) {
this.setSubListSelectorConfig(subListSelectorConfig);
return this;
}
public @NonNull SubListSwapMoveSelectorConfig
withSecondarySubListSelectorConfig(@NonNull SubListSelectorConfig secondarySubListSelectorConfig) {
this.setSecondarySubListSelectorConfig(secondarySubListSelectorConfig);
return this;
}
@Override
public @NonNull SubListSwapMoveSelectorConfig inherit(@NonNull SubListSwapMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
this.minimumSubListSize =
ConfigUtils.inheritOverwritableProperty(minimumSubListSize, inheritedConfig.minimumSubListSize);
this.maximumSubListSize =
ConfigUtils.inheritOverwritableProperty(maximumSubListSize, inheritedConfig.maximumSubListSize);
this.selectReversingMoveToo =
ConfigUtils.inheritOverwritableProperty(selectReversingMoveToo, inheritedConfig.selectReversingMoveToo);
this.subListSelectorConfig =
ConfigUtils.inheritOverwritableProperty(subListSelectorConfig, inheritedConfig.subListSelectorConfig);
this.secondarySubListSelectorConfig =
ConfigUtils.inheritOverwritableProperty(secondarySubListSelectorConfig,
inheritedConfig.secondarySubListSelectorConfig);
return this;
}
@Override
public @NonNull SubListSwapMoveSelectorConfig copyConfig() {
return new SubListSwapMoveSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
visitCommonReferencedClasses(classVisitor);
if (subListSelectorConfig != null) {
subListSelectorConfig.visitReferencedClasses(classVisitor);
}
if (secondarySubListSelectorConfig != null) {
secondarySubListSelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public boolean hasNearbySelectionConfig() {
return (subListSelectorConfig != null && subListSelectorConfig.hasNearbySelectionConfig())
|| (secondarySubListSelectorConfig != null && secondarySubListSelectorConfig.hasNearbySelectionConfig());
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + subListSelectorConfig
+ (secondarySubListSelectorConfig == null ? "" : ", " + secondarySubListSelectorConfig) + ")";
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/list/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.heuristic.selector.move.generic.list;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/list | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/list/kopt/KOptListMoveSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.move.generic.list.kopt;
import java.util.Random;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.NearbyAutoConfigurationEnabled;
import ai.timefold.solver.core.config.heuristic.selector.move.NearbyUtil;
import ai.timefold.solver.core.config.heuristic.selector.value.ValueSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import ai.timefold.solver.core.impl.heuristic.selector.common.nearby.NearbyDistanceMeter;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"minimumK",
"maximumK",
"originSelectorConfig",
"valueSelectorConfig"
})
public class KOptListMoveSelectorConfig
extends MoveSelectorConfig<KOptListMoveSelectorConfig>
implements NearbyAutoConfigurationEnabled<KOptListMoveSelectorConfig> {
public static final String XML_ELEMENT_NAME = "kOptListMoveSelector";
protected Integer minimumK = null;
protected Integer maximumK = null;
@XmlElement(name = "originSelector")
private ValueSelectorConfig originSelectorConfig = null;
@XmlElement(name = "valueSelector")
private ValueSelectorConfig valueSelectorConfig = null;
public @Nullable Integer getMinimumK() {
return minimumK;
}
public void setMinimumK(@Nullable Integer minimumK) {
this.minimumK = minimumK;
}
public @Nullable Integer getMaximumK() {
return maximumK;
}
public void setMaximumK(@Nullable Integer maximumK) {
this.maximumK = maximumK;
}
public @Nullable ValueSelectorConfig getOriginSelectorConfig() {
return originSelectorConfig;
}
public void setOriginSelectorConfig(@Nullable ValueSelectorConfig originSelectorConfig) {
this.originSelectorConfig = originSelectorConfig;
}
public @Nullable ValueSelectorConfig getValueSelectorConfig() {
return valueSelectorConfig;
}
public void setValueSelectorConfig(@Nullable ValueSelectorConfig valueSelectorConfig) {
this.valueSelectorConfig = valueSelectorConfig;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull KOptListMoveSelectorConfig withMinimumK(@NonNull Integer minimumK) {
this.minimumK = minimumK;
return this;
}
public @NonNull KOptListMoveSelectorConfig withMaximumK(@NonNull Integer maximumK) {
this.maximumK = maximumK;
return this;
}
public @NonNull KOptListMoveSelectorConfig withOriginSelectorConfig(@NonNull ValueSelectorConfig originSelectorConfig) {
this.originSelectorConfig = originSelectorConfig;
return this;
}
public @NonNull KOptListMoveSelectorConfig withValueSelectorConfig(@NonNull ValueSelectorConfig valueSelectorConfig) {
this.valueSelectorConfig = valueSelectorConfig;
return this;
}
// ************************************************************************
// Builder methods
// ************************************************************************
@Override
public @NonNull KOptListMoveSelectorConfig inherit(@NonNull KOptListMoveSelectorConfig inheritedConfig) {
super.inherit(inheritedConfig);
this.minimumK = ConfigUtils.inheritOverwritableProperty(minimumK, inheritedConfig.minimumK);
this.maximumK = ConfigUtils.inheritOverwritableProperty(maximumK, inheritedConfig.maximumK);
this.originSelectorConfig = ConfigUtils.inheritConfig(originSelectorConfig, inheritedConfig.originSelectorConfig);
this.valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.valueSelectorConfig);
return this;
}
@Override
public @NonNull KOptListMoveSelectorConfig copyConfig() {
return new KOptListMoveSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
visitCommonReferencedClasses(classVisitor);
if (originSelectorConfig != null) {
originSelectorConfig.visitReferencedClasses(classVisitor);
}
if (valueSelectorConfig != null) {
valueSelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public @NonNull KOptListMoveSelectorConfig enableNearbySelection(
@NonNull Class<? extends NearbyDistanceMeter<?, ?>> distanceMeter,
@NonNull Random random) {
return NearbyUtil.enable(this, distanceMeter, random);
}
@Override
public boolean hasNearbySelectionConfig() {
return (originSelectorConfig != null && originSelectorConfig.hasNearbySelectionConfig())
|| (valueSelectorConfig != null && valueSelectorConfig.hasNearbySelectionConfig());
}
@Override
public boolean canEnableNearbyInMixedModels() {
return true;
}
@Override
public String toString() {
return getClass().getSimpleName() + "()";
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/list | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/move/generic/list/kopt/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.heuristic.selector.move.generic.list.kopt;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/value/ValueSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.value;
import java.util.Comparator;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.api.domain.variable.PlanningVariable;
import ai.timefold.solver.core.config.heuristic.selector.SelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.common.SelectionCacheType;
import ai.timefold.solver.core.config.heuristic.selector.common.SelectionOrder;
import ai.timefold.solver.core.config.heuristic.selector.common.decorator.SelectionSorterOrder;
import ai.timefold.solver.core.config.heuristic.selector.common.nearby.NearbySelectionConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import ai.timefold.solver.core.impl.domain.variable.descriptor.GenuineVariableDescriptor;
import ai.timefold.solver.core.impl.heuristic.selector.common.decorator.SelectionFilter;
import ai.timefold.solver.core.impl.heuristic.selector.common.decorator.SelectionProbabilityWeightFactory;
import ai.timefold.solver.core.impl.heuristic.selector.common.decorator.SelectionSorter;
import ai.timefold.solver.core.impl.heuristic.selector.common.decorator.SelectionSorterWeightFactory;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"id",
"mimicSelectorRef",
"downcastEntityClass",
"variableName",
"cacheType",
"selectionOrder",
"nearbySelectionConfig",
"filterClass",
"sorterManner",
"sorterComparatorClass",
"sorterWeightFactoryClass",
"sorterOrder",
"sorterClass",
"probabilityWeightFactoryClass",
"selectedCountLimit"
})
public class ValueSelectorConfig extends SelectorConfig<ValueSelectorConfig> {
@XmlAttribute
protected String id = null;
@XmlAttribute
protected String mimicSelectorRef = null;
protected Class<?> downcastEntityClass = null;
@XmlAttribute
protected String variableName = null;
protected SelectionCacheType cacheType = null;
protected SelectionOrder selectionOrder = null;
@XmlElement(name = "nearbySelection")
protected NearbySelectionConfig nearbySelectionConfig = null;
protected Class<? extends SelectionFilter> filterClass = null;
protected ValueSorterManner sorterManner = null;
protected Class<? extends Comparator> sorterComparatorClass = null;
protected Class<? extends SelectionSorterWeightFactory> sorterWeightFactoryClass = null;
protected SelectionSorterOrder sorterOrder = null;
protected Class<? extends SelectionSorter> sorterClass = null;
protected Class<? extends SelectionProbabilityWeightFactory> probabilityWeightFactoryClass = null;
protected Long selectedCountLimit = null;
public ValueSelectorConfig() {
}
public ValueSelectorConfig(@NonNull String variableName) {
this.variableName = variableName;
}
public ValueSelectorConfig(@Nullable ValueSelectorConfig inheritedConfig) {
if (inheritedConfig != null) {
inherit(inheritedConfig);
}
}
public @Nullable String getId() {
return id;
}
public void setId(@Nullable String id) {
this.id = id;
}
public @Nullable String getMimicSelectorRef() {
return mimicSelectorRef;
}
public void setMimicSelectorRef(@Nullable String mimicSelectorRef) {
this.mimicSelectorRef = mimicSelectorRef;
}
public @Nullable Class<?> getDowncastEntityClass() {
return downcastEntityClass;
}
public void setDowncastEntityClass(@Nullable Class<?> downcastEntityClass) {
this.downcastEntityClass = downcastEntityClass;
}
public @Nullable String getVariableName() {
return variableName;
}
public void setVariableName(@Nullable String variableName) {
this.variableName = variableName;
}
public @Nullable SelectionCacheType getCacheType() {
return cacheType;
}
public void setCacheType(@Nullable SelectionCacheType cacheType) {
this.cacheType = cacheType;
}
public @Nullable SelectionOrder getSelectionOrder() {
return selectionOrder;
}
public void setSelectionOrder(@Nullable SelectionOrder selectionOrder) {
this.selectionOrder = selectionOrder;
}
public @Nullable NearbySelectionConfig getNearbySelectionConfig() {
return nearbySelectionConfig;
}
public void setNearbySelectionConfig(@Nullable NearbySelectionConfig nearbySelectionConfig) {
this.nearbySelectionConfig = nearbySelectionConfig;
}
public @Nullable Class<? extends SelectionFilter> getFilterClass() {
return filterClass;
}
public void setFilterClass(@Nullable Class<? extends SelectionFilter> filterClass) {
this.filterClass = filterClass;
}
public @Nullable ValueSorterManner getSorterManner() {
return sorterManner;
}
public void setSorterManner(@Nullable ValueSorterManner sorterManner) {
this.sorterManner = sorterManner;
}
public @Nullable Class<? extends Comparator> getSorterComparatorClass() {
return sorterComparatorClass;
}
public void setSorterComparatorClass(@Nullable Class<? extends Comparator> sorterComparatorClass) {
this.sorterComparatorClass = sorterComparatorClass;
}
public @Nullable Class<? extends SelectionSorterWeightFactory> getSorterWeightFactoryClass() {
return sorterWeightFactoryClass;
}
public void setSorterWeightFactoryClass(@Nullable Class<? extends SelectionSorterWeightFactory> sorterWeightFactoryClass) {
this.sorterWeightFactoryClass = sorterWeightFactoryClass;
}
public @Nullable SelectionSorterOrder getSorterOrder() {
return sorterOrder;
}
public void setSorterOrder(@Nullable SelectionSorterOrder sorterOrder) {
this.sorterOrder = sorterOrder;
}
public @Nullable Class<? extends SelectionSorter> getSorterClass() {
return sorterClass;
}
public void setSorterClass(@Nullable Class<? extends SelectionSorter> sorterClass) {
this.sorterClass = sorterClass;
}
public @Nullable Class<? extends SelectionProbabilityWeightFactory> getProbabilityWeightFactoryClass() {
return probabilityWeightFactoryClass;
}
public void setProbabilityWeightFactoryClass(
@Nullable Class<? extends SelectionProbabilityWeightFactory> probabilityWeightFactoryClass) {
this.probabilityWeightFactoryClass = probabilityWeightFactoryClass;
}
public @Nullable Long getSelectedCountLimit() {
return selectedCountLimit;
}
public void setSelectedCountLimit(@Nullable Long selectedCountLimit) {
this.selectedCountLimit = selectedCountLimit;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull ValueSelectorConfig withId(@NonNull String id) {
this.setId(id);
return this;
}
public @NonNull ValueSelectorConfig withMimicSelectorRef(@NonNull String mimicSelectorRef) {
this.setMimicSelectorRef(mimicSelectorRef);
return this;
}
public @NonNull ValueSelectorConfig withDowncastEntityClass(@NonNull Class<?> entityClass) {
this.setDowncastEntityClass(entityClass);
return this;
}
public @NonNull ValueSelectorConfig withVariableName(@NonNull String variableName) {
this.setVariableName(variableName);
return this;
}
public @NonNull ValueSelectorConfig withCacheType(@NonNull SelectionCacheType cacheType) {
this.setCacheType(cacheType);
return this;
}
public @NonNull ValueSelectorConfig withSelectionOrder(@NonNull SelectionOrder selectionOrder) {
this.setSelectionOrder(selectionOrder);
return this;
}
public @NonNull ValueSelectorConfig withNearbySelectionConfig(@NonNull NearbySelectionConfig nearbySelectionConfig) {
this.setNearbySelectionConfig(nearbySelectionConfig);
return this;
}
public @NonNull ValueSelectorConfig withFilterClass(@NonNull Class<? extends SelectionFilter> filterClass) {
this.setFilterClass(filterClass);
return this;
}
public @NonNull ValueSelectorConfig withSorterManner(@NonNull ValueSorterManner sorterManner) {
this.setSorterManner(sorterManner);
return this;
}
public @NonNull ValueSelectorConfig withSorterComparatorClass(@NonNull Class<? extends Comparator> comparatorClass) {
this.setSorterComparatorClass(comparatorClass);
return this;
}
public @NonNull ValueSelectorConfig
withSorterWeightFactoryClass(@NonNull Class<? extends SelectionSorterWeightFactory> weightFactoryClass) {
this.setSorterWeightFactoryClass(weightFactoryClass);
return this;
}
public @NonNull ValueSelectorConfig withSorterOrder(@NonNull SelectionSorterOrder sorterOrder) {
this.setSorterOrder(sorterOrder);
return this;
}
public @NonNull ValueSelectorConfig withSorterClass(@NonNull Class<? extends SelectionSorter> sorterClass) {
this.setSorterClass(sorterClass);
return this;
}
public @NonNull ValueSelectorConfig
withProbabilityWeightFactoryClass(@NonNull Class<? extends SelectionProbabilityWeightFactory> factoryClass) {
this.setProbabilityWeightFactoryClass(factoryClass);
return this;
}
public @NonNull ValueSelectorConfig withSelectedCountLimit(long selectedCountLimit) {
this.setSelectedCountLimit(selectedCountLimit);
return this;
}
// ************************************************************************
// Builder methods
// ************************************************************************
@Override
public @NonNull ValueSelectorConfig inherit(@NonNull ValueSelectorConfig inheritedConfig) {
id = ConfigUtils.inheritOverwritableProperty(id, inheritedConfig.getId());
mimicSelectorRef = ConfigUtils.inheritOverwritableProperty(mimicSelectorRef,
inheritedConfig.getMimicSelectorRef());
downcastEntityClass = ConfigUtils.inheritOverwritableProperty(downcastEntityClass,
inheritedConfig.getDowncastEntityClass());
variableName = ConfigUtils.inheritOverwritableProperty(variableName, inheritedConfig.getVariableName());
nearbySelectionConfig = ConfigUtils.inheritConfig(nearbySelectionConfig, inheritedConfig.getNearbySelectionConfig());
filterClass = ConfigUtils.inheritOverwritableProperty(filterClass, inheritedConfig.getFilterClass());
cacheType = ConfigUtils.inheritOverwritableProperty(cacheType, inheritedConfig.getCacheType());
selectionOrder = ConfigUtils.inheritOverwritableProperty(selectionOrder, inheritedConfig.getSelectionOrder());
sorterManner = ConfigUtils.inheritOverwritableProperty(
sorterManner, inheritedConfig.getSorterManner());
sorterComparatorClass = ConfigUtils.inheritOverwritableProperty(
sorterComparatorClass, inheritedConfig.getSorterComparatorClass());
sorterWeightFactoryClass = ConfigUtils.inheritOverwritableProperty(
sorterWeightFactoryClass, inheritedConfig.getSorterWeightFactoryClass());
sorterOrder = ConfigUtils.inheritOverwritableProperty(
sorterOrder, inheritedConfig.getSorterOrder());
sorterClass = ConfigUtils.inheritOverwritableProperty(
sorterClass, inheritedConfig.getSorterClass());
probabilityWeightFactoryClass = ConfigUtils.inheritOverwritableProperty(
probabilityWeightFactoryClass, inheritedConfig.getProbabilityWeightFactoryClass());
selectedCountLimit = ConfigUtils.inheritOverwritableProperty(
selectedCountLimit, inheritedConfig.getSelectedCountLimit());
return this;
}
@Override
public @NonNull ValueSelectorConfig copyConfig() {
return new ValueSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
classVisitor.accept(downcastEntityClass);
if (nearbySelectionConfig != null) {
nearbySelectionConfig.visitReferencedClasses(classVisitor);
}
classVisitor.accept(filterClass);
classVisitor.accept(sorterComparatorClass);
classVisitor.accept(sorterWeightFactoryClass);
classVisitor.accept(sorterClass);
classVisitor.accept(probabilityWeightFactoryClass);
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + variableName + ")";
}
public static <Solution_> boolean hasSorter(@NonNull ValueSorterManner valueSorterManner,
@NonNull GenuineVariableDescriptor<Solution_> variableDescriptor) {
switch (valueSorterManner) {
case NONE:
return false;
case INCREASING_STRENGTH:
case DECREASING_STRENGTH:
return true;
case INCREASING_STRENGTH_IF_AVAILABLE:
return variableDescriptor.getIncreasingStrengthSorter() != null;
case DECREASING_STRENGTH_IF_AVAILABLE:
return variableDescriptor.getDecreasingStrengthSorter() != null;
default:
throw new IllegalStateException("The sorterManner ("
+ valueSorterManner + ") is not implemented.");
}
}
public static <Solution_> @NonNull SelectionSorter<Solution_, Object> determineSorter(
@NonNull ValueSorterManner valueSorterManner, @NonNull GenuineVariableDescriptor<Solution_> variableDescriptor) {
SelectionSorter<Solution_, Object> sorter;
switch (valueSorterManner) {
case NONE:
throw new IllegalStateException("Impossible state: hasSorter() should have returned null.");
case INCREASING_STRENGTH:
case INCREASING_STRENGTH_IF_AVAILABLE:
sorter = variableDescriptor.getIncreasingStrengthSorter();
break;
case DECREASING_STRENGTH:
case DECREASING_STRENGTH_IF_AVAILABLE:
sorter = variableDescriptor.getDecreasingStrengthSorter();
break;
default:
throw new IllegalStateException("The sorterManner ("
+ valueSorterManner + ") is not implemented.");
}
if (sorter == null) {
throw new IllegalArgumentException("The sorterManner (" + valueSorterManner
+ ") on entity class (" + variableDescriptor.getEntityDescriptor().getEntityClass()
+ ")'s variable (" + variableDescriptor.getVariableName()
+ ") fails because that variable getter's @" + PlanningVariable.class.getSimpleName()
+ " annotation does not declare any strength comparison.");
}
return sorter;
}
@Override
public boolean hasNearbySelectionConfig() {
return nearbySelectionConfig != null;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/value/ValueSorterManner.java | package ai.timefold.solver.core.config.heuristic.selector.value;
import jakarta.xml.bind.annotation.XmlEnum;
import ai.timefold.solver.core.api.domain.variable.PlanningVariable;
/**
* The manner of sorting values for a {@link PlanningVariable}.
*/
@XmlEnum
public enum ValueSorterManner {
NONE(true),
INCREASING_STRENGTH(false),
INCREASING_STRENGTH_IF_AVAILABLE(true),
DECREASING_STRENGTH(false),
DECREASING_STRENGTH_IF_AVAILABLE(true);
private final boolean nonePossible;
ValueSorterManner(boolean nonePossible) {
this.nonePossible = nonePossible;
}
/**
* @return true if {@link #NONE} is an option, such as when the other option is not available.
*/
public boolean isNonePossible() {
return nonePossible;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/value/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.heuristic.selector.value;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/value | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/value/chained/SubChainSelectorConfig.java | package ai.timefold.solver.core.config.heuristic.selector.value.chained;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.SelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.value.ValueSelectorConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"valueSelectorConfig",
"minimumSubChainSize",
"maximumSubChainSize"
})
public class SubChainSelectorConfig extends SelectorConfig<SubChainSelectorConfig> {
@XmlElement(name = "valueSelector")
protected ValueSelectorConfig valueSelectorConfig = null;
protected Integer minimumSubChainSize = null;
protected Integer maximumSubChainSize = null;
public @Nullable ValueSelectorConfig getValueSelectorConfig() {
return valueSelectorConfig;
}
public void setValueSelectorConfig(@Nullable ValueSelectorConfig valueSelectorConfig) {
this.valueSelectorConfig = valueSelectorConfig;
}
public @Nullable Integer getMinimumSubChainSize() {
return minimumSubChainSize;
}
public void setMinimumSubChainSize(@Nullable Integer minimumSubChainSize) {
this.minimumSubChainSize = minimumSubChainSize;
}
public @Nullable Integer getMaximumSubChainSize() {
return maximumSubChainSize;
}
public void setMaximumSubChainSize(@Nullable Integer maximumSubChainSize) {
this.maximumSubChainSize = maximumSubChainSize;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull SubChainSelectorConfig withValueSelectorConfig(@NonNull ValueSelectorConfig valueSelectorConfig) {
this.setValueSelectorConfig(valueSelectorConfig);
return this;
}
public @NonNull SubChainSelectorConfig withMinimumSubChainSize(@NonNull Integer minimumSubChainSize) {
this.setMinimumSubChainSize(minimumSubChainSize);
return this;
}
public @NonNull SubChainSelectorConfig withMaximumSubChainSize(@NonNull Integer maximumSubChainSize) {
this.setMaximumSubChainSize(maximumSubChainSize);
return this;
}
@Override
public @NonNull SubChainSelectorConfig inherit(@NonNull SubChainSelectorConfig inheritedConfig) {
valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig());
minimumSubChainSize = ConfigUtils.inheritOverwritableProperty(minimumSubChainSize,
inheritedConfig.getMinimumSubChainSize());
maximumSubChainSize = ConfigUtils.inheritOverwritableProperty(maximumSubChainSize,
inheritedConfig.getMaximumSubChainSize());
return this;
}
@Override
public @NonNull SubChainSelectorConfig copyConfig() {
return new SubChainSelectorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
if (valueSelectorConfig != null) {
valueSelectorConfig.visitReferencedClasses(classVisitor);
}
}
@Override
public boolean hasNearbySelectionConfig() {
return valueSelectorConfig != null && valueSelectorConfig.hasNearbySelectionConfig();
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + valueSelectorConfig + ")";
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/value | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/heuristic/selector/value/chained/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.heuristic.selector.value.chained;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/LocalSearchPhaseConfig.java | package ai.timefold.solver.core.config.localsearch;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElements;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.heuristic.selector.move.MoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.composite.CartesianProductMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.composite.UnionMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.factory.MoveListFactoryConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.generic.ChangeMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.generic.PillarChangeMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.generic.PillarSwapMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.generic.RuinRecreateMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.generic.SwapMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.generic.chained.SubChainChangeMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.generic.chained.SubChainSwapMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.generic.chained.TailChainSwapMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.generic.list.ListChangeMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.generic.list.ListRuinRecreateMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.generic.list.ListSwapMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.generic.list.SubListChangeMoveSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.move.generic.list.SubListSwapMoveSelectorConfig;
import ai.timefold.solver.core.config.localsearch.decider.acceptor.LocalSearchAcceptorConfig;
import ai.timefold.solver.core.config.localsearch.decider.forager.LocalSearchForagerConfig;
import ai.timefold.solver.core.config.phase.PhaseConfig;
import ai.timefold.solver.core.config.solver.PreviewFeature;
import ai.timefold.solver.core.config.util.ConfigUtils;
import ai.timefold.solver.core.impl.move.streams.maybeapi.stream.MoveProviders;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"localSearchType",
"moveSelectorConfig",
"moveProvidersClass",
"acceptorConfig",
"foragerConfig"
})
public class LocalSearchPhaseConfig extends PhaseConfig<LocalSearchPhaseConfig> {
public static final String XML_ELEMENT_NAME = "localSearch";
// Warning: all fields are null (and not defaulted) because they can be inherited
// and also because the input config file should match the output config file
protected LocalSearchType localSearchType = null;
@XmlElements({
@XmlElement(name = CartesianProductMoveSelectorConfig.XML_ELEMENT_NAME,
type = CartesianProductMoveSelectorConfig.class),
@XmlElement(name = ChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = ChangeMoveSelectorConfig.class),
@XmlElement(name = ListChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = ListChangeMoveSelectorConfig.class),
@XmlElement(name = ListSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = ListSwapMoveSelectorConfig.class),
@XmlElement(name = MoveIteratorFactoryConfig.XML_ELEMENT_NAME, type = MoveIteratorFactoryConfig.class),
@XmlElement(name = MoveListFactoryConfig.XML_ELEMENT_NAME, type = MoveListFactoryConfig.class),
@XmlElement(name = PillarChangeMoveSelectorConfig.XML_ELEMENT_NAME,
type = PillarChangeMoveSelectorConfig.class),
@XmlElement(name = PillarSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = PillarSwapMoveSelectorConfig.class),
@XmlElement(name = RuinRecreateMoveSelectorConfig.XML_ELEMENT_NAME,
type = RuinRecreateMoveSelectorConfig.class),
@XmlElement(name = ListRuinRecreateMoveSelectorConfig.XML_ELEMENT_NAME,
type = ListRuinRecreateMoveSelectorConfig.class),
@XmlElement(name = SubChainChangeMoveSelectorConfig.XML_ELEMENT_NAME,
type = SubChainChangeMoveSelectorConfig.class),
@XmlElement(name = SubChainSwapMoveSelectorConfig.XML_ELEMENT_NAME,
type = SubChainSwapMoveSelectorConfig.class),
@XmlElement(name = SubListChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = SubListChangeMoveSelectorConfig.class),
@XmlElement(name = SubListSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SubListSwapMoveSelectorConfig.class),
@XmlElement(name = SwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SwapMoveSelectorConfig.class),
@XmlElement(name = TailChainSwapMoveSelectorConfig.XML_ELEMENT_NAME,
type = TailChainSwapMoveSelectorConfig.class),
@XmlElement(name = UnionMoveSelectorConfig.XML_ELEMENT_NAME, type = UnionMoveSelectorConfig.class)
})
private MoveSelectorConfig moveSelectorConfig = null;
private Class<? extends MoveProviders> moveProvidersClass = null;
@XmlElement(name = "acceptor")
private LocalSearchAcceptorConfig acceptorConfig = null;
@XmlElement(name = "forager")
private LocalSearchForagerConfig foragerConfig = null;
// ************************************************************************
// Constructors and simple getters/setters
// ************************************************************************
public @Nullable LocalSearchType getLocalSearchType() {
return localSearchType;
}
public void setLocalSearchType(@Nullable LocalSearchType localSearchType) {
this.localSearchType = localSearchType;
}
public @Nullable MoveSelectorConfig getMoveSelectorConfig() {
return moveSelectorConfig;
}
public void setMoveSelectorConfig(@Nullable MoveSelectorConfig moveSelectorConfig) {
this.moveSelectorConfig = moveSelectorConfig;
}
/**
* Part of {@link PreviewFeature#MOVE_STREAMS}.
*/
@SuppressWarnings("unchecked")
public @Nullable <Solution_> Class<? extends MoveProviders<Solution_>> getMoveProvidersClass() {
return (Class<? extends MoveProviders<Solution_>>) moveProvidersClass;
}
/**
* Part of {@link PreviewFeature#MOVE_STREAMS}.
*/
@SuppressWarnings("rawtypes")
public void setMoveProvidersClass(@Nullable Class<? extends MoveProviders> moveProvidersClass) {
this.moveProvidersClass = moveProvidersClass;
}
public @Nullable LocalSearchAcceptorConfig getAcceptorConfig() {
return acceptorConfig;
}
public void setAcceptorConfig(@Nullable LocalSearchAcceptorConfig acceptorConfig) {
this.acceptorConfig = acceptorConfig;
}
public @Nullable LocalSearchForagerConfig getForagerConfig() {
return foragerConfig;
}
public void setForagerConfig(@Nullable LocalSearchForagerConfig foragerConfig) {
this.foragerConfig = foragerConfig;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull LocalSearchPhaseConfig withLocalSearchType(@NonNull LocalSearchType localSearchType) {
this.localSearchType = localSearchType;
return this;
}
public @NonNull LocalSearchPhaseConfig withMoveSelectorConfig(@NonNull MoveSelectorConfig moveSelectorConfig) {
this.moveSelectorConfig = moveSelectorConfig;
return this;
}
/**
* Part of {@link PreviewFeature#MOVE_STREAMS}.
*/
public @NonNull LocalSearchPhaseConfig
withMoveProvidersClass(@NonNull Class<? extends MoveProviders<?>> moveProviderClass) {
this.moveProvidersClass = moveProviderClass;
return this;
}
public @NonNull LocalSearchPhaseConfig withAcceptorConfig(@NonNull LocalSearchAcceptorConfig acceptorConfig) {
this.acceptorConfig = acceptorConfig;
return this;
}
public @NonNull LocalSearchPhaseConfig withForagerConfig(@NonNull LocalSearchForagerConfig foragerConfig) {
this.foragerConfig = foragerConfig;
return this;
}
@Override
public @NonNull LocalSearchPhaseConfig inherit(@NonNull LocalSearchPhaseConfig inheritedConfig) {
super.inherit(inheritedConfig);
localSearchType = ConfigUtils.inheritOverwritableProperty(localSearchType,
inheritedConfig.getLocalSearchType());
setMoveSelectorConfig(ConfigUtils.inheritOverwritableProperty(
getMoveSelectorConfig(), inheritedConfig.getMoveSelectorConfig()));
setMoveProvidersClass(ConfigUtils.inheritOverwritableProperty(getMoveProvidersClass(),
inheritedConfig.getMoveProvidersClass()));
acceptorConfig = ConfigUtils.inheritConfig(acceptorConfig, inheritedConfig.getAcceptorConfig());
foragerConfig = ConfigUtils.inheritConfig(foragerConfig, inheritedConfig.getForagerConfig());
return this;
}
@Override
public @NonNull LocalSearchPhaseConfig copyConfig() {
return new LocalSearchPhaseConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
if (terminationConfig != null) {
terminationConfig.visitReferencedClasses(classVisitor);
}
if (moveSelectorConfig != null) {
moveSelectorConfig.visitReferencedClasses(classVisitor);
}
if (moveProvidersClass != null) {
classVisitor.accept(moveProvidersClass);
}
if (acceptorConfig != null) {
acceptorConfig.visitReferencedClasses(classVisitor);
}
if (foragerConfig != null) {
foragerConfig.visitReferencedClasses(classVisitor);
}
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/LocalSearchType.java | package ai.timefold.solver.core.config.localsearch;
import java.util.Arrays;
import jakarta.xml.bind.annotation.XmlEnum;
import ai.timefold.solver.core.config.solver.PreviewFeature;
import org.jspecify.annotations.NonNull;
@XmlEnum
public enum LocalSearchType {
HILL_CLIMBING,
TABU_SEARCH,
SIMULATED_ANNEALING,
LATE_ACCEPTANCE,
/**
* See {@link PreviewFeature#DIVERSIFIED_LATE_ACCEPTANCE}.
*/
DIVERSIFIED_LATE_ACCEPTANCE,
GREAT_DELUGE,
VARIABLE_NEIGHBORHOOD_DESCENT;
/**
* @return {@link #values()} without duplicates (abstract types that end up behaving as one of the other types).
*/
public static @NonNull LocalSearchType @NonNull [] getBluePrintTypes() {
return Arrays.stream(values())
// Workaround for https://issues.redhat.com/browse/PLANNER-1294
.filter(localSearchType -> localSearchType != SIMULATED_ANNEALING)
.toArray(LocalSearchType[]::new);
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.localsearch;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider/acceptor/AcceptorType.java | package ai.timefold.solver.core.config.localsearch.decider.acceptor;
import jakarta.xml.bind.annotation.XmlEnum;
@XmlEnum
public enum AcceptorType {
HILL_CLIMBING,
ENTITY_TABU(true),
VALUE_TABU(true),
MOVE_TABU(true),
UNDO_MOVE_TABU(true),
SIMULATED_ANNEALING,
LATE_ACCEPTANCE,
DIVERSIFIED_LATE_ACCEPTANCE,
GREAT_DELUGE,
STEP_COUNTING_HILL_CLIMBING;
private final boolean isTabu;
AcceptorType() {
this(false);
}
AcceptorType(boolean isTabu) {
this.isTabu = isTabu;
}
public boolean isTabu() {
return isTabu;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider/acceptor/LocalSearchAcceptorConfig.java | package ai.timefold.solver.core.config.localsearch.decider.acceptor;
import java.util.List;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.AbstractConfig;
import ai.timefold.solver.core.config.localsearch.decider.acceptor.stepcountinghillclimbing.StepCountingHillClimbingType;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"acceptorTypeList",
"entityTabuSize",
"entityTabuRatio",
"fadingEntityTabuSize",
"fadingEntityTabuRatio",
"valueTabuSize",
"valueTabuRatio",
"fadingValueTabuSize",
"fadingValueTabuRatio",
"moveTabuSize",
"fadingMoveTabuSize",
"undoMoveTabuSize",
"fadingUndoMoveTabuSize",
"simulatedAnnealingStartingTemperature",
"lateAcceptanceSize",
"greatDelugeWaterLevelIncrementScore",
"greatDelugeWaterLevelIncrementRatio",
"stepCountingHillClimbingSize",
"stepCountingHillClimbingType"
})
public class LocalSearchAcceptorConfig extends AbstractConfig<LocalSearchAcceptorConfig> {
@XmlElement(name = "acceptorType")
private List<AcceptorType> acceptorTypeList = null;
protected Integer entityTabuSize = null;
protected Double entityTabuRatio = null;
protected Integer fadingEntityTabuSize = null;
protected Double fadingEntityTabuRatio = null;
protected Integer valueTabuSize = null;
protected Double valueTabuRatio = null;
protected Integer fadingValueTabuSize = null;
protected Double fadingValueTabuRatio = null;
protected Integer moveTabuSize = null;
protected Integer fadingMoveTabuSize = null;
/**
* @deprecated Deprecated, no longer has any effect.
*/
@Deprecated(forRemoval = true, since = "1.16.0")
protected Integer undoMoveTabuSize = null;
/**
* @deprecated Deprecated, no longer has any effect.
*/
@Deprecated(forRemoval = true, since = "1.16.0")
protected Integer fadingUndoMoveTabuSize = null;
protected String simulatedAnnealingStartingTemperature = null;
protected Integer lateAcceptanceSize = null;
protected String greatDelugeWaterLevelIncrementScore = null;
protected Double greatDelugeWaterLevelIncrementRatio = null;
protected Integer stepCountingHillClimbingSize = null;
protected StepCountingHillClimbingType stepCountingHillClimbingType = null;
public @Nullable List<AcceptorType> getAcceptorTypeList() {
return acceptorTypeList;
}
public void setAcceptorTypeList(@Nullable List<AcceptorType> acceptorTypeList) {
this.acceptorTypeList = acceptorTypeList;
}
public @Nullable Integer getEntityTabuSize() {
return entityTabuSize;
}
public void setEntityTabuSize(@Nullable Integer entityTabuSize) {
this.entityTabuSize = entityTabuSize;
}
public @Nullable Double getEntityTabuRatio() {
return entityTabuRatio;
}
public void setEntityTabuRatio(@Nullable Double entityTabuRatio) {
this.entityTabuRatio = entityTabuRatio;
}
public @Nullable Integer getFadingEntityTabuSize() {
return fadingEntityTabuSize;
}
public void setFadingEntityTabuSize(@Nullable Integer fadingEntityTabuSize) {
this.fadingEntityTabuSize = fadingEntityTabuSize;
}
public @Nullable Double getFadingEntityTabuRatio() {
return fadingEntityTabuRatio;
}
public void setFadingEntityTabuRatio(@Nullable Double fadingEntityTabuRatio) {
this.fadingEntityTabuRatio = fadingEntityTabuRatio;
}
public @Nullable Integer getValueTabuSize() {
return valueTabuSize;
}
public void setValueTabuSize(@Nullable Integer valueTabuSize) {
this.valueTabuSize = valueTabuSize;
}
/**
* @deprecated Deprecated on account of never having worked in the first place.
*/
@Deprecated(forRemoval = true, since = "1.5.0")
public Double getValueTabuRatio() {
return valueTabuRatio;
}
/**
* @deprecated Deprecated on account of never having worked in the first place.
*/
@Deprecated(forRemoval = true, since = "1.5.0")
public void setValueTabuRatio(Double valueTabuRatio) {
this.valueTabuRatio = valueTabuRatio;
}
public @Nullable Integer getFadingValueTabuSize() {
return fadingValueTabuSize;
}
public void setFadingValueTabuSize(@Nullable Integer fadingValueTabuSize) {
this.fadingValueTabuSize = fadingValueTabuSize;
}
/**
* @deprecated Deprecated on account of never having worked in the first place.
*/
@Deprecated(forRemoval = true, since = "1.5.0")
public Double getFadingValueTabuRatio() {
return fadingValueTabuRatio;
}
/**
* @deprecated Deprecated on account of never having worked in the first place.
*/
@Deprecated(forRemoval = true, since = "1.5.0")
public void setFadingValueTabuRatio(Double fadingValueTabuRatio) {
this.fadingValueTabuRatio = fadingValueTabuRatio;
}
public @Nullable Integer getMoveTabuSize() {
return moveTabuSize;
}
public void setMoveTabuSize(@Nullable Integer moveTabuSize) {
this.moveTabuSize = moveTabuSize;
}
public @Nullable Integer getFadingMoveTabuSize() {
return fadingMoveTabuSize;
}
public void setFadingMoveTabuSize(@Nullable Integer fadingMoveTabuSize) {
this.fadingMoveTabuSize = fadingMoveTabuSize;
}
/**
* @deprecated Deprecated, no longer has any effect.
*/
@Deprecated(forRemoval = true, since = "1.16.0")
public Integer getUndoMoveTabuSize() {
return undoMoveTabuSize;
}
/**
* @deprecated Deprecated, no longer has any effect.
*/
@Deprecated(forRemoval = true, since = "1.16.0")
public void setUndoMoveTabuSize(Integer undoMoveTabuSize) {
this.undoMoveTabuSize = undoMoveTabuSize;
}
/**
* @deprecated Deprecated, no longer has any effect.
*/
@Deprecated(forRemoval = true, since = "1.16.0")
public Integer getFadingUndoMoveTabuSize() {
return fadingUndoMoveTabuSize;
}
/**
* @deprecated Deprecated, no longer has any effect.
*/
@Deprecated(forRemoval = true, since = "1.16.0")
public void setFadingUndoMoveTabuSize(Integer fadingUndoMoveTabuSize) {
this.fadingUndoMoveTabuSize = fadingUndoMoveTabuSize;
}
public @Nullable String getSimulatedAnnealingStartingTemperature() {
return simulatedAnnealingStartingTemperature;
}
public void setSimulatedAnnealingStartingTemperature(@Nullable String simulatedAnnealingStartingTemperature) {
this.simulatedAnnealingStartingTemperature = simulatedAnnealingStartingTemperature;
}
public @Nullable Integer getLateAcceptanceSize() {
return lateAcceptanceSize;
}
public void setLateAcceptanceSize(@Nullable Integer lateAcceptanceSize) {
this.lateAcceptanceSize = lateAcceptanceSize;
}
public @Nullable String getGreatDelugeWaterLevelIncrementScore() {
return greatDelugeWaterLevelIncrementScore;
}
public void setGreatDelugeWaterLevelIncrementScore(@Nullable String greatDelugeWaterLevelIncrementScore) {
this.greatDelugeWaterLevelIncrementScore = greatDelugeWaterLevelIncrementScore;
}
public @Nullable Double getGreatDelugeWaterLevelIncrementRatio() {
return greatDelugeWaterLevelIncrementRatio;
}
public void setGreatDelugeWaterLevelIncrementRatio(@Nullable Double greatDelugeWaterLevelIncrementRatio) {
this.greatDelugeWaterLevelIncrementRatio = greatDelugeWaterLevelIncrementRatio;
}
public @Nullable Integer getStepCountingHillClimbingSize() {
return stepCountingHillClimbingSize;
}
public void setStepCountingHillClimbingSize(@Nullable Integer stepCountingHillClimbingSize) {
this.stepCountingHillClimbingSize = stepCountingHillClimbingSize;
}
public @Nullable StepCountingHillClimbingType getStepCountingHillClimbingType() {
return stepCountingHillClimbingType;
}
public void setStepCountingHillClimbingType(@Nullable StepCountingHillClimbingType stepCountingHillClimbingType) {
this.stepCountingHillClimbingType = stepCountingHillClimbingType;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull LocalSearchAcceptorConfig withAcceptorTypeList(@NonNull List<AcceptorType> acceptorTypeList) {
this.acceptorTypeList = acceptorTypeList;
return this;
}
public @NonNull LocalSearchAcceptorConfig withEntityTabuSize(@NonNull Integer entityTabuSize) {
this.entityTabuSize = entityTabuSize;
return this;
}
public @NonNull LocalSearchAcceptorConfig withEntityTabuRatio(@NonNull Double entityTabuRatio) {
this.entityTabuRatio = entityTabuRatio;
return this;
}
public @NonNull LocalSearchAcceptorConfig withFadingEntityTabuSize(@NonNull Integer fadingEntityTabuSize) {
this.fadingEntityTabuSize = fadingEntityTabuSize;
return this;
}
public @NonNull LocalSearchAcceptorConfig withFadingEntityTabuRatio(@NonNull Double fadingEntityTabuRatio) {
this.fadingEntityTabuRatio = fadingEntityTabuRatio;
return this;
}
public @NonNull LocalSearchAcceptorConfig withValueTabuSize(@NonNull Integer valueTabuSize) {
this.valueTabuSize = valueTabuSize;
return this;
}
public @NonNull LocalSearchAcceptorConfig withValueTabuRatio(@NonNull Double valueTabuRatio) {
this.valueTabuRatio = valueTabuRatio;
return this;
}
public @NonNull LocalSearchAcceptorConfig withFadingValueTabuSize(@NonNull Integer fadingValueTabuSize) {
this.fadingValueTabuSize = fadingValueTabuSize;
return this;
}
public @NonNull LocalSearchAcceptorConfig withFadingValueTabuRatio(@NonNull Double fadingValueTabuRatio) {
this.fadingValueTabuRatio = fadingValueTabuRatio;
return this;
}
public @NonNull LocalSearchAcceptorConfig withMoveTabuSize(@NonNull Integer moveTabuSize) {
this.moveTabuSize = moveTabuSize;
return this;
}
public @NonNull LocalSearchAcceptorConfig withFadingMoveTabuSize(@NonNull Integer fadingMoveTabuSize) {
this.fadingMoveTabuSize = fadingMoveTabuSize;
return this;
}
/**
* @deprecated Deprecated, no longer has any effect.
*/
@Deprecated(forRemoval = true, since = "1.16.0")
public LocalSearchAcceptorConfig withUndoMoveTabuSize(Integer undoMoveTabuSize) {
this.undoMoveTabuSize = undoMoveTabuSize;
return this;
}
/**
* @deprecated Deprecated, no longer has any effect.
*/
@Deprecated(forRemoval = true, since = "1.16.0")
public LocalSearchAcceptorConfig withFadingUndoMoveTabuSize(Integer fadingUndoMoveTabuSize) {
this.fadingUndoMoveTabuSize = fadingUndoMoveTabuSize;
return this;
}
public @NonNull LocalSearchAcceptorConfig
withSimulatedAnnealingStartingTemperature(@NonNull String simulatedAnnealingStartingTemperature) {
this.simulatedAnnealingStartingTemperature = simulatedAnnealingStartingTemperature;
return this;
}
public @NonNull LocalSearchAcceptorConfig withLateAcceptanceSize(@NonNull Integer lateAcceptanceSize) {
this.lateAcceptanceSize = lateAcceptanceSize;
return this;
}
public @NonNull LocalSearchAcceptorConfig withStepCountingHillClimbingSize(@NonNull Integer stepCountingHillClimbingSize) {
this.stepCountingHillClimbingSize = stepCountingHillClimbingSize;
return this;
}
public @NonNull LocalSearchAcceptorConfig
withStepCountingHillClimbingType(@NonNull StepCountingHillClimbingType stepCountingHillClimbingType) {
this.stepCountingHillClimbingType = stepCountingHillClimbingType;
return this;
}
@Override
public @NonNull LocalSearchAcceptorConfig inherit(@NonNull LocalSearchAcceptorConfig inheritedConfig) {
if (acceptorTypeList == null) {
acceptorTypeList = inheritedConfig.getAcceptorTypeList();
} else {
List<AcceptorType> inheritedAcceptorTypeList = inheritedConfig.getAcceptorTypeList();
if (inheritedAcceptorTypeList != null) {
for (AcceptorType acceptorType : inheritedAcceptorTypeList) {
if (!acceptorTypeList.contains(acceptorType)) {
acceptorTypeList.add(acceptorType);
}
}
}
}
entityTabuSize = ConfigUtils.inheritOverwritableProperty(entityTabuSize, inheritedConfig.getEntityTabuSize());
entityTabuRatio = ConfigUtils.inheritOverwritableProperty(entityTabuRatio, inheritedConfig.getEntityTabuRatio());
fadingEntityTabuSize = ConfigUtils.inheritOverwritableProperty(fadingEntityTabuSize,
inheritedConfig.getFadingEntityTabuSize());
fadingEntityTabuRatio = ConfigUtils.inheritOverwritableProperty(fadingEntityTabuRatio,
inheritedConfig.getFadingEntityTabuRatio());
valueTabuSize = ConfigUtils.inheritOverwritableProperty(valueTabuSize, inheritedConfig.getValueTabuSize());
valueTabuRatio = ConfigUtils.inheritOverwritableProperty(valueTabuRatio, inheritedConfig.getValueTabuRatio());
fadingValueTabuSize = ConfigUtils.inheritOverwritableProperty(fadingValueTabuSize,
inheritedConfig.getFadingValueTabuSize());
fadingValueTabuRatio = ConfigUtils.inheritOverwritableProperty(fadingValueTabuRatio,
inheritedConfig.getFadingValueTabuRatio());
moveTabuSize = ConfigUtils.inheritOverwritableProperty(moveTabuSize, inheritedConfig.getMoveTabuSize());
fadingMoveTabuSize = ConfigUtils.inheritOverwritableProperty(fadingMoveTabuSize,
inheritedConfig.getFadingMoveTabuSize());
undoMoveTabuSize = ConfigUtils.inheritOverwritableProperty(undoMoveTabuSize,
inheritedConfig.getUndoMoveTabuSize());
fadingUndoMoveTabuSize = ConfigUtils.inheritOverwritableProperty(fadingUndoMoveTabuSize,
inheritedConfig.getFadingUndoMoveTabuSize());
simulatedAnnealingStartingTemperature = ConfigUtils.inheritOverwritableProperty(
simulatedAnnealingStartingTemperature, inheritedConfig.getSimulatedAnnealingStartingTemperature());
lateAcceptanceSize = ConfigUtils.inheritOverwritableProperty(lateAcceptanceSize,
inheritedConfig.getLateAcceptanceSize());
greatDelugeWaterLevelIncrementScore = ConfigUtils.inheritOverwritableProperty(greatDelugeWaterLevelIncrementScore,
inheritedConfig.getGreatDelugeWaterLevelIncrementScore());
greatDelugeWaterLevelIncrementRatio = ConfigUtils.inheritOverwritableProperty(greatDelugeWaterLevelIncrementRatio,
inheritedConfig.getGreatDelugeWaterLevelIncrementRatio());
stepCountingHillClimbingSize = ConfigUtils.inheritOverwritableProperty(stepCountingHillClimbingSize,
inheritedConfig.getStepCountingHillClimbingSize());
stepCountingHillClimbingType = ConfigUtils.inheritOverwritableProperty(stepCountingHillClimbingType,
inheritedConfig.getStepCountingHillClimbingType());
return this;
}
@Override
public @NonNull LocalSearchAcceptorConfig copyConfig() {
return new LocalSearchAcceptorConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
// No referenced classes
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider/acceptor/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.localsearch.decider.acceptor;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider/acceptor | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider/acceptor/stepcountinghillclimbing/StepCountingHillClimbingType.java | package ai.timefold.solver.core.config.localsearch.decider.acceptor.stepcountinghillclimbing;
import jakarta.xml.bind.annotation.XmlEnum;
import ai.timefold.solver.core.api.score.Score;
import ai.timefold.solver.core.config.localsearch.decider.forager.LocalSearchForagerConfig;
/**
* Determines what increment the counter of Step Counting Hill Climbing.
*/
@XmlEnum
public enum StepCountingHillClimbingType {
/**
* Every selected move is counted.
*/
SELECTED_MOVE,
/**
* Every accepted move is counted.
* <p>
* Note: If {@link LocalSearchForagerConfig#getAcceptedCountLimit()} = 1,
* then this behaves exactly the same as {link #STEP}.
*/
ACCEPTED_MOVE,
/**
* Every step is counted. Every step was always an accepted move. This is the default.
*/
STEP,
/**
* Every step that equals or improves the {@link Score} of the last step is counted.
*/
EQUAL_OR_IMPROVING_STEP,
/**
* Every step that improves the {@link Score} of the last step is counted.
*/
IMPROVING_STEP;
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider/acceptor | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider/acceptor/stepcountinghillclimbing/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.localsearch.decider.acceptor.stepcountinghillclimbing;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider/forager/FinalistPodiumType.java | package ai.timefold.solver.core.config.localsearch.decider.forager;
import jakarta.xml.bind.annotation.XmlEnum;
import ai.timefold.solver.core.impl.localsearch.decider.forager.finalist.FinalistPodium;
import ai.timefold.solver.core.impl.localsearch.decider.forager.finalist.HighestScoreFinalistPodium;
import ai.timefold.solver.core.impl.localsearch.decider.forager.finalist.StrategicOscillationByLevelFinalistPodium;
import org.jspecify.annotations.NonNull;
@XmlEnum
public enum FinalistPodiumType {
HIGHEST_SCORE,
STRATEGIC_OSCILLATION,
STRATEGIC_OSCILLATION_BY_LEVEL,
STRATEGIC_OSCILLATION_BY_LEVEL_ON_BEST_SCORE;
public <Solution_> @NonNull FinalistPodium<Solution_> buildFinalistPodium() {
switch (this) {
case HIGHEST_SCORE:
return new HighestScoreFinalistPodium<>();
case STRATEGIC_OSCILLATION:
case STRATEGIC_OSCILLATION_BY_LEVEL:
return new StrategicOscillationByLevelFinalistPodium<>(false);
case STRATEGIC_OSCILLATION_BY_LEVEL_ON_BEST_SCORE:
return new StrategicOscillationByLevelFinalistPodium<>(true);
default:
throw new IllegalStateException("The finalistPodiumType (" + this + ") is not implemented.");
}
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider/forager/LocalSearchForagerConfig.java | package ai.timefold.solver.core.config.localsearch.decider.forager;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.AbstractConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"pickEarlyType",
"acceptedCountLimit",
"finalistPodiumType",
"breakTieRandomly"
})
public class LocalSearchForagerConfig extends AbstractConfig<LocalSearchForagerConfig> {
protected LocalSearchPickEarlyType pickEarlyType = null;
protected Integer acceptedCountLimit = null;
protected FinalistPodiumType finalistPodiumType = null;
protected Boolean breakTieRandomly = null;
public @Nullable LocalSearchPickEarlyType getPickEarlyType() {
return pickEarlyType;
}
public void setPickEarlyType(@Nullable LocalSearchPickEarlyType pickEarlyType) {
this.pickEarlyType = pickEarlyType;
}
public @Nullable Integer getAcceptedCountLimit() {
return acceptedCountLimit;
}
public void setAcceptedCountLimit(@Nullable Integer acceptedCountLimit) {
this.acceptedCountLimit = acceptedCountLimit;
}
public @Nullable FinalistPodiumType getFinalistPodiumType() {
return finalistPodiumType;
}
public void setFinalistPodiumType(@Nullable FinalistPodiumType finalistPodiumType) {
this.finalistPodiumType = finalistPodiumType;
}
public @Nullable Boolean getBreakTieRandomly() {
return breakTieRandomly;
}
public void setBreakTieRandomly(@Nullable Boolean breakTieRandomly) {
this.breakTieRandomly = breakTieRandomly;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull LocalSearchForagerConfig withPickEarlyType(@NonNull LocalSearchPickEarlyType pickEarlyType) {
this.pickEarlyType = pickEarlyType;
return this;
}
public @NonNull LocalSearchForagerConfig withAcceptedCountLimit(int acceptedCountLimit) {
this.acceptedCountLimit = acceptedCountLimit;
return this;
}
public @NonNull LocalSearchForagerConfig withFinalistPodiumType(@NonNull FinalistPodiumType finalistPodiumType) {
this.finalistPodiumType = finalistPodiumType;
return this;
}
public @NonNull LocalSearchForagerConfig withBreakTieRandomly(boolean breakTieRandomly) {
this.breakTieRandomly = breakTieRandomly;
return this;
}
@Override
public @NonNull LocalSearchForagerConfig inherit(@NonNull LocalSearchForagerConfig inheritedConfig) {
pickEarlyType = ConfigUtils.inheritOverwritableProperty(pickEarlyType,
inheritedConfig.getPickEarlyType());
acceptedCountLimit = ConfigUtils.inheritOverwritableProperty(acceptedCountLimit,
inheritedConfig.getAcceptedCountLimit());
finalistPodiumType = ConfigUtils.inheritOverwritableProperty(finalistPodiumType,
inheritedConfig.getFinalistPodiumType());
breakTieRandomly = ConfigUtils.inheritOverwritableProperty(breakTieRandomly,
inheritedConfig.getBreakTieRandomly());
return this;
}
@Override
public @NonNull LocalSearchForagerConfig copyConfig() {
return new LocalSearchForagerConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
// No referenced classes
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider/forager/LocalSearchPickEarlyType.java | package ai.timefold.solver.core.config.localsearch.decider.forager;
import jakarta.xml.bind.annotation.XmlEnum;
@XmlEnum
public enum LocalSearchPickEarlyType {
NEVER,
FIRST_BEST_SCORE_IMPROVING,
FIRST_LAST_STEP_SCORE_IMPROVING;
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/localsearch/decider/forager/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.localsearch.decider.forager;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/partitionedsearch/PartitionedSearchPhaseConfig.java | package ai.timefold.solver.core.config.partitionedsearch;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElements;
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import ai.timefold.solver.core.api.score.director.ScoreDirector;
import ai.timefold.solver.core.api.solver.Solver;
import ai.timefold.solver.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig;
import ai.timefold.solver.core.config.exhaustivesearch.ExhaustiveSearchPhaseConfig;
import ai.timefold.solver.core.config.localsearch.LocalSearchPhaseConfig;
import ai.timefold.solver.core.config.phase.NoChangePhaseConfig;
import ai.timefold.solver.core.config.phase.PhaseConfig;
import ai.timefold.solver.core.config.phase.custom.CustomPhaseConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import ai.timefold.solver.core.impl.io.jaxb.adapter.JaxbCustomPropertiesAdapter;
import ai.timefold.solver.core.impl.partitionedsearch.partitioner.SolutionPartitioner;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"solutionPartitionerClass",
"solutionPartitionerCustomProperties",
"runnablePartThreadLimit",
"phaseConfigList"
})
public class PartitionedSearchPhaseConfig extends PhaseConfig<PartitionedSearchPhaseConfig> {
public static final String XML_ELEMENT_NAME = "partitionedSearch";
public static final String ACTIVE_THREAD_COUNT_AUTO = "AUTO";
public static final String ACTIVE_THREAD_COUNT_UNLIMITED = "UNLIMITED";
// Warning: all fields are null (and not defaulted) because they can be inherited
// and also because the input config file should match the output config file
protected Class<? extends SolutionPartitioner<?>> solutionPartitionerClass = null;
@XmlJavaTypeAdapter(JaxbCustomPropertiesAdapter.class)
protected Map<String, String> solutionPartitionerCustomProperties = null;
protected String runnablePartThreadLimit = null;
@XmlElements({
@XmlElement(name = ConstructionHeuristicPhaseConfig.XML_ELEMENT_NAME,
type = ConstructionHeuristicPhaseConfig.class),
@XmlElement(name = CustomPhaseConfig.XML_ELEMENT_NAME, type = CustomPhaseConfig.class),
@XmlElement(name = ExhaustiveSearchPhaseConfig.XML_ELEMENT_NAME, type = ExhaustiveSearchPhaseConfig.class),
@XmlElement(name = LocalSearchPhaseConfig.XML_ELEMENT_NAME, type = LocalSearchPhaseConfig.class),
@XmlElement(name = NoChangePhaseConfig.XML_ELEMENT_NAME, type = NoChangePhaseConfig.class),
@XmlElement(name = PartitionedSearchPhaseConfig.XML_ELEMENT_NAME, type = PartitionedSearchPhaseConfig.class)
})
protected List<PhaseConfig> phaseConfigList = null;
// ************************************************************************
// Constructors and simple getters/setters
// ************************************************************************
public @Nullable Class<? extends SolutionPartitioner<?>> getSolutionPartitionerClass() {
return solutionPartitionerClass;
}
public void setSolutionPartitionerClass(@Nullable Class<? extends SolutionPartitioner<?>> solutionPartitionerClass) {
this.solutionPartitionerClass = solutionPartitionerClass;
}
public @Nullable Map<String, String> getSolutionPartitionerCustomProperties() {
return solutionPartitionerCustomProperties;
}
public void setSolutionPartitionerCustomProperties(@Nullable Map<String, String> solutionPartitionerCustomProperties) {
this.solutionPartitionerCustomProperties = solutionPartitionerCustomProperties;
}
/**
* Similar to a thread pool size, but instead of limiting the number of {@link Thread}s,
* it limits the number of {@link java.lang.Thread.State#RUNNABLE runnable} {@link Thread}s to avoid consuming all
* CPU resources (which would starve UI, Servlets and REST threads).
*
* <p>
* The number of {@link Thread}s is always equal to the number of partitions returned by
* {@link SolutionPartitioner#splitWorkingSolution(ScoreDirector, Integer)},
* because otherwise some partitions would never run (especially with {@link Solver#terminateEarly() asynchronous
* termination}).
* If this limit (or {@link Runtime#availableProcessors()}) is lower than the number of partitions,
* this results in a slower score calculation speed per partition {@link Solver}.
*
* <p>
* Defaults to {@value #ACTIVE_THREAD_COUNT_AUTO} which consumes the majority
* but not all of the CPU cores on multi-core machines, to prevent a livelock that hangs other processes
* (such as your IDE, REST servlets threads or SSH connections) on the machine.
*
* <p>
* Use {@value #ACTIVE_THREAD_COUNT_UNLIMITED} to give it all CPU cores.
* This is useful if you're handling the CPU consumption on an OS level.
*
* @return null, a number, {@value #ACTIVE_THREAD_COUNT_AUTO} or {@value #ACTIVE_THREAD_COUNT_UNLIMITED}.
*/
public @Nullable String getRunnablePartThreadLimit() {
return runnablePartThreadLimit;
}
public void setRunnablePartThreadLimit(@Nullable String runnablePartThreadLimit) {
this.runnablePartThreadLimit = runnablePartThreadLimit;
}
public @Nullable List<@NonNull PhaseConfig> getPhaseConfigList() {
return phaseConfigList;
}
public void setPhaseConfigList(@Nullable List<@NonNull PhaseConfig> phaseConfigList) {
this.phaseConfigList = phaseConfigList;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull PartitionedSearchPhaseConfig withSolutionPartitionerClass(
@NonNull Class<? extends SolutionPartitioner<?>> solutionPartitionerClass) {
this.setSolutionPartitionerClass(solutionPartitionerClass);
return this;
}
public @NonNull PartitionedSearchPhaseConfig withSolutionPartitionerCustomProperties(
@NonNull Map<String, String> solutionPartitionerCustomProperties) {
this.setSolutionPartitionerCustomProperties(solutionPartitionerCustomProperties);
return this;
}
public @NonNull PartitionedSearchPhaseConfig withRunnablePartThreadLimit(@NonNull String runnablePartThreadLimit) {
this.setRunnablePartThreadLimit(runnablePartThreadLimit);
return this;
}
public @NonNull PartitionedSearchPhaseConfig withPhaseConfigList(@NonNull List<@NonNull PhaseConfig> phaseConfigList) {
this.setPhaseConfigList(phaseConfigList);
return this;
}
public @NonNull PartitionedSearchPhaseConfig withPhaseConfigs(@NonNull PhaseConfig @NonNull... phaseConfigs) {
this.setPhaseConfigList(List.of(phaseConfigs));
return this;
}
@Override
public @NonNull PartitionedSearchPhaseConfig inherit(@NonNull PartitionedSearchPhaseConfig inheritedConfig) {
super.inherit(inheritedConfig);
solutionPartitionerClass = ConfigUtils.inheritOverwritableProperty(solutionPartitionerClass,
inheritedConfig.getSolutionPartitionerClass());
solutionPartitionerCustomProperties = ConfigUtils.inheritMergeableMapProperty(
solutionPartitionerCustomProperties, inheritedConfig.getSolutionPartitionerCustomProperties());
runnablePartThreadLimit = ConfigUtils.inheritOverwritableProperty(runnablePartThreadLimit,
inheritedConfig.getRunnablePartThreadLimit());
phaseConfigList = ConfigUtils.inheritMergeableListConfig(
phaseConfigList, inheritedConfig.getPhaseConfigList());
return this;
}
@Override
public @NonNull PartitionedSearchPhaseConfig copyConfig() {
return new PartitionedSearchPhaseConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
if (terminationConfig != null) {
terminationConfig.visitReferencedClasses(classVisitor);
}
classVisitor.accept(solutionPartitionerClass);
if (phaseConfigList != null) {
phaseConfigList.forEach(pc -> pc.visitReferencedClasses(classVisitor));
}
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/partitionedsearch/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.partitionedsearch;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/phase/NoChangePhaseConfig.java | package ai.timefold.solver.core.config.phase;
import java.util.function.Consumer;
import ai.timefold.solver.core.impl.phase.NoChangePhase;
import org.jspecify.annotations.NonNull;
/**
* @deprecated Deprecated on account of deprecating {@link NoChangePhase}.
*/
@Deprecated(forRemoval = true, since = "1.20.0")
public class NoChangePhaseConfig extends PhaseConfig<NoChangePhaseConfig> {
public static final String XML_ELEMENT_NAME = "noChangePhase";
@Override
public @NonNull NoChangePhaseConfig inherit(@NonNull NoChangePhaseConfig inheritedConfig) {
super.inherit(inheritedConfig);
return this;
}
@Override
public @NonNull NoChangePhaseConfig copyConfig() {
return new NoChangePhaseConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
if (terminationConfig != null) {
terminationConfig.visitReferencedClasses(classVisitor);
}
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/phase/PhaseConfig.java | package ai.timefold.solver.core.config.phase;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlSeeAlso;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.AbstractConfig;
import ai.timefold.solver.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig;
import ai.timefold.solver.core.config.exhaustivesearch.ExhaustiveSearchPhaseConfig;
import ai.timefold.solver.core.config.localsearch.LocalSearchPhaseConfig;
import ai.timefold.solver.core.config.partitionedsearch.PartitionedSearchPhaseConfig;
import ai.timefold.solver.core.config.phase.custom.CustomPhaseConfig;
import ai.timefold.solver.core.config.solver.termination.TerminationConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlSeeAlso({
ConstructionHeuristicPhaseConfig.class,
CustomPhaseConfig.class,
ExhaustiveSearchPhaseConfig.class,
LocalSearchPhaseConfig.class,
NoChangePhaseConfig.class,
PartitionedSearchPhaseConfig.class
})
@XmlType(propOrder = {
"terminationConfig"
})
public abstract class PhaseConfig<Config_ extends PhaseConfig<Config_>> extends AbstractConfig<Config_> {
// Warning: all fields are null (and not defaulted) because they can be inherited
// and also because the input config file should match the output config file
@XmlElement(name = "termination")
protected TerminationConfig terminationConfig = null;
// ************************************************************************
// Constructors and simple getters/setters
// ************************************************************************
public @Nullable TerminationConfig getTerminationConfig() {
return terminationConfig;
}
public void setTerminationConfig(@Nullable TerminationConfig terminationConfig) {
this.terminationConfig = terminationConfig;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull Config_ withTerminationConfig(@NonNull TerminationConfig terminationConfig) {
this.setTerminationConfig(terminationConfig);
return (Config_) this;
}
@Override
public @NonNull Config_ inherit(@NonNull Config_ inheritedConfig) {
terminationConfig = ConfigUtils.inheritConfig(terminationConfig, inheritedConfig.getTerminationConfig());
return (Config_) this;
}
@Override
public String toString() {
return getClass().getSimpleName();
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/phase/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.phase;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/phase | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/phase/custom/CustomPhaseConfig.java | package ai.timefold.solver.core.config.phase.custom;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlTransient;
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import ai.timefold.solver.core.api.solver.phase.PhaseCommand;
import ai.timefold.solver.core.config.phase.PhaseConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import ai.timefold.solver.core.impl.io.jaxb.adapter.JaxbCustomPropertiesAdapter;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"customPhaseCommandClassList",
"customProperties",
})
@NullMarked
public class CustomPhaseConfig extends PhaseConfig<CustomPhaseConfig> {
public static final String XML_ELEMENT_NAME = "customPhase";
// Warning: all fields are null (and not defaulted) because they can be inherited
// and also because the input config file should match the output config file
@XmlElement(name = "customPhaseCommandClass")
protected @Nullable List<Class<? extends PhaseCommand>> customPhaseCommandClassList = null;
@XmlJavaTypeAdapter(JaxbCustomPropertiesAdapter.class)
protected @Nullable Map<String, String> customProperties = null;
@XmlTransient
protected @Nullable List<? extends PhaseCommand> customPhaseCommandList = null;
// ************************************************************************
// Constructors and simple getters/setters
// ************************************************************************
public @Nullable List<Class<? extends PhaseCommand>> getCustomPhaseCommandClassList() {
return customPhaseCommandClassList;
}
public void setCustomPhaseCommandClassList(@Nullable List<Class<? extends PhaseCommand>> customPhaseCommandClassList) {
this.customPhaseCommandClassList = customPhaseCommandClassList;
}
public @Nullable Map<String, String> getCustomProperties() {
return customProperties;
}
public void setCustomProperties(@Nullable Map<String, String> customProperties) {
this.customProperties = customProperties;
}
public @Nullable List<? extends PhaseCommand> getCustomPhaseCommandList() {
return customPhaseCommandList;
}
public void setCustomPhaseCommandList(@Nullable List<? extends PhaseCommand> customPhaseCommandList) {
this.customPhaseCommandList = customPhaseCommandList;
}
// ************************************************************************
// With methods
// ************************************************************************
public CustomPhaseConfig withCustomPhaseCommandClassList(List<Class<? extends PhaseCommand>> customPhaseCommandClassList) {
this.customPhaseCommandClassList = customPhaseCommandClassList;
return this;
}
public CustomPhaseConfig withCustomProperties(Map<String, String> customProperties) {
this.customProperties = customProperties;
return this;
}
public CustomPhaseConfig withCustomPhaseCommandList(List<? extends PhaseCommand> customPhaseCommandList) {
boolean hasNullCommand = Objects.requireNonNullElse(customPhaseCommandList, Collections.emptyList())
.stream().anyMatch(Objects::isNull);
if (hasNullCommand) {
throw new IllegalArgumentException(
"Custom phase commands (" + customPhaseCommandList + ") must not contain a null element.");
}
this.customPhaseCommandList = List.copyOf(customPhaseCommandList);
return this;
}
public <Solution_> CustomPhaseConfig withCustomPhaseCommands(PhaseCommand<Solution_>... customPhaseCommands) {
return withCustomPhaseCommandList(Arrays.asList(customPhaseCommands));
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public CustomPhaseConfig inherit(CustomPhaseConfig inheritedConfig) {
super.inherit(inheritedConfig);
customPhaseCommandClassList = ConfigUtils.inheritMergeableListProperty(
customPhaseCommandClassList, inheritedConfig.getCustomPhaseCommandClassList());
customPhaseCommandList = ConfigUtils.inheritMergeableListProperty(
customPhaseCommandList, (List) inheritedConfig.getCustomPhaseCommandList());
customProperties = ConfigUtils.inheritMergeableMapProperty(
customProperties, inheritedConfig.getCustomProperties());
return this;
}
@Override
public CustomPhaseConfig copyConfig() {
return new CustomPhaseConfig().inherit(this);
}
@Override
public void visitReferencedClasses(Consumer<Class<?>> classVisitor) {
if (terminationConfig != null) {
terminationConfig.visitReferencedClasses(classVisitor);
}
if (customPhaseCommandClassList != null) {
customPhaseCommandClassList.forEach(classVisitor);
}
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/phase | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/phase/custom/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.phase.custom;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/score | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/score/definition/ScoreDefinitionType.java | package ai.timefold.solver.core.config.score.definition;
import jakarta.xml.bind.annotation.XmlEnum;
@XmlEnum
public enum ScoreDefinitionType {
SIMPLE,
SIMPLE_LONG,
/**
* WARNING: NOT RECOMMENDED TO USE DUE TO ROUNDING ERRORS THAT CAUSE SCORE CORRUPTION.
* Use {@link #SIMPLE_BIG_DECIMAL} instead.
*/
@Deprecated(forRemoval = true)
SIMPLE_DOUBLE,
SIMPLE_BIG_DECIMAL,
HARD_SOFT,
HARD_SOFT_LONG,
/**
* WARNING: NOT RECOMMENDED TO USE DUE TO ROUNDING ERRORS THAT CAUSE SCORE CORRUPTION.
* Use {@link #HARD_SOFT_BIG_DECIMAL} instead.
*/
@Deprecated(forRemoval = true)
HARD_SOFT_DOUBLE,
HARD_SOFT_BIG_DECIMAL,
HARD_MEDIUM_SOFT,
HARD_MEDIUM_SOFT_LONG,
BENDABLE,
BENDABLE_LONG,
BENDABLE_BIG_DECIMAL;
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/score | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/score/definition/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.score.definition;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/score | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/score/director/ScoreDirectorFactoryConfig.java | package ai.timefold.solver.core.config.score.director;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import ai.timefold.solver.core.api.score.calculator.EasyScoreCalculator;
import ai.timefold.solver.core.api.score.calculator.IncrementalScoreCalculator;
import ai.timefold.solver.core.api.score.stream.ConstraintProvider;
import ai.timefold.solver.core.api.score.stream.ConstraintStreamImplType;
import ai.timefold.solver.core.config.AbstractConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import ai.timefold.solver.core.impl.io.jaxb.adapter.JaxbCustomPropertiesAdapter;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"easyScoreCalculatorClass",
"easyScoreCalculatorCustomProperties",
"constraintProviderClass",
"constraintProviderCustomProperties",
"constraintStreamImplType",
"constraintStreamAutomaticNodeSharing",
"incrementalScoreCalculatorClass",
"incrementalScoreCalculatorCustomProperties",
"scoreDrlList",
"initializingScoreTrend",
"assertionScoreDirectorFactory"
})
public class ScoreDirectorFactoryConfig extends AbstractConfig<ScoreDirectorFactoryConfig> {
protected Class<? extends EasyScoreCalculator> easyScoreCalculatorClass = null;
@XmlJavaTypeAdapter(JaxbCustomPropertiesAdapter.class)
protected Map<String, String> easyScoreCalculatorCustomProperties = null;
protected Class<? extends ConstraintProvider> constraintProviderClass = null;
@XmlJavaTypeAdapter(JaxbCustomPropertiesAdapter.class)
protected Map<String, String> constraintProviderCustomProperties = null;
protected ConstraintStreamImplType constraintStreamImplType;
protected Boolean constraintStreamAutomaticNodeSharing;
protected Class<? extends IncrementalScoreCalculator> incrementalScoreCalculatorClass = null;
@XmlJavaTypeAdapter(JaxbCustomPropertiesAdapter.class)
protected Map<String, String> incrementalScoreCalculatorCustomProperties = null;
@Deprecated(forRemoval = true)
@XmlElement(name = "scoreDrl")
protected List<String> scoreDrlList = null;
// TODO: this should be rather an enum?
protected String initializingScoreTrend = null;
@XmlElement(name = "assertionScoreDirectorFactory")
protected ScoreDirectorFactoryConfig assertionScoreDirectorFactory = null;
// ************************************************************************
// Constructors and simple getters/setters
// ************************************************************************
public @Nullable Class<? extends EasyScoreCalculator> getEasyScoreCalculatorClass() {
return easyScoreCalculatorClass;
}
public void setEasyScoreCalculatorClass(@Nullable Class<? extends EasyScoreCalculator> easyScoreCalculatorClass) {
this.easyScoreCalculatorClass = easyScoreCalculatorClass;
}
public @Nullable Map<@NonNull String, @NonNull String> getEasyScoreCalculatorCustomProperties() {
return easyScoreCalculatorCustomProperties;
}
public void setEasyScoreCalculatorCustomProperties(
@Nullable Map<@NonNull String, @NonNull String> easyScoreCalculatorCustomProperties) {
this.easyScoreCalculatorCustomProperties = easyScoreCalculatorCustomProperties;
}
public @Nullable Class<? extends ConstraintProvider> getConstraintProviderClass() {
return constraintProviderClass;
}
public void setConstraintProviderClass(@Nullable Class<? extends ConstraintProvider> constraintProviderClass) {
this.constraintProviderClass = constraintProviderClass;
}
public @Nullable Map<@NonNull String, @NonNull String> getConstraintProviderCustomProperties() {
return constraintProviderCustomProperties;
}
public void setConstraintProviderCustomProperties(
@Nullable Map<@NonNull String, @NonNull String> constraintProviderCustomProperties) {
this.constraintProviderCustomProperties = constraintProviderCustomProperties;
}
/**
* @deprecated There is only one implementation, so this method is deprecated.
* This method no longer has any effect.
*/
@Deprecated(forRemoval = true, since = "1.16.0")
public @Nullable ConstraintStreamImplType getConstraintStreamImplType() {
return constraintStreamImplType;
}
/**
* @deprecated There is only one implementation, so this method is deprecated.
* This method no longer has any effect.
*/
@Deprecated(forRemoval = true, since = "1.16.0")
public void setConstraintStreamImplType(@Nullable ConstraintStreamImplType constraintStreamImplType) {
this.constraintStreamImplType = constraintStreamImplType;
}
public @Nullable Boolean getConstraintStreamAutomaticNodeSharing() {
return constraintStreamAutomaticNodeSharing;
}
public void setConstraintStreamAutomaticNodeSharing(@Nullable Boolean constraintStreamAutomaticNodeSharing) {
this.constraintStreamAutomaticNodeSharing = constraintStreamAutomaticNodeSharing;
}
public @Nullable Class<? extends IncrementalScoreCalculator> getIncrementalScoreCalculatorClass() {
return incrementalScoreCalculatorClass;
}
public void setIncrementalScoreCalculatorClass(
@Nullable Class<? extends IncrementalScoreCalculator> incrementalScoreCalculatorClass) {
this.incrementalScoreCalculatorClass = incrementalScoreCalculatorClass;
}
public @Nullable Map<@NonNull String, @NonNull String> getIncrementalScoreCalculatorCustomProperties() {
return incrementalScoreCalculatorCustomProperties;
}
public void setIncrementalScoreCalculatorCustomProperties(
@Nullable Map<@NonNull String, @NonNull String> incrementalScoreCalculatorCustomProperties) {
this.incrementalScoreCalculatorCustomProperties = incrementalScoreCalculatorCustomProperties;
}
/**
* @deprecated All support for Score DRL was removed when Timefold was forked from OptaPlanner.
* See <a href="https://timefold.ai/blog/migrating-score-drl-to-constraint-streams">DRL to Constraint Streams
* migration recipe</a>.
*/
@Deprecated(forRemoval = true)
public List<String> getScoreDrlList() {
return scoreDrlList;
}
/**
* @deprecated All support for Score DRL was removed when Timefold was forked from OptaPlanner.
* See <a href="https://timefold.ai/blog/migrating-score-drl-to-constraint-streams">DRL to Constraint Streams
* migration recipe</a>.
*/
@Deprecated(forRemoval = true)
public void setScoreDrlList(List<String> scoreDrlList) {
this.scoreDrlList = scoreDrlList;
}
public @Nullable String getInitializingScoreTrend() {
return initializingScoreTrend;
}
public void setInitializingScoreTrend(@Nullable String initializingScoreTrend) {
this.initializingScoreTrend = initializingScoreTrend;
}
public @Nullable ScoreDirectorFactoryConfig getAssertionScoreDirectorFactory() {
return assertionScoreDirectorFactory;
}
public void setAssertionScoreDirectorFactory(@Nullable ScoreDirectorFactoryConfig assertionScoreDirectorFactory) {
this.assertionScoreDirectorFactory = assertionScoreDirectorFactory;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull ScoreDirectorFactoryConfig
withEasyScoreCalculatorClass(@NonNull Class<? extends EasyScoreCalculator> easyScoreCalculatorClass) {
this.easyScoreCalculatorClass = easyScoreCalculatorClass;
return this;
}
public @NonNull ScoreDirectorFactoryConfig
withEasyScoreCalculatorCustomProperties(
@NonNull Map<@NonNull String, @NonNull String> easyScoreCalculatorCustomProperties) {
this.easyScoreCalculatorCustomProperties = easyScoreCalculatorCustomProperties;
return this;
}
public @NonNull ScoreDirectorFactoryConfig
withConstraintProviderClass(@NonNull Class<? extends ConstraintProvider> constraintProviderClass) {
this.constraintProviderClass = constraintProviderClass;
return this;
}
public @NonNull ScoreDirectorFactoryConfig
withConstraintProviderCustomProperties(
@NonNull Map<@NonNull String, @NonNull String> constraintProviderCustomProperties) {
this.constraintProviderCustomProperties = constraintProviderCustomProperties;
return this;
}
/**
* @deprecated There is only one implementation, so this method is deprecated.
* This method no longer has any effect.
*/
@Deprecated(forRemoval = true, since = "1.16.0")
public @NonNull ScoreDirectorFactoryConfig
withConstraintStreamImplType(@NonNull ConstraintStreamImplType constraintStreamImplType) {
this.constraintStreamImplType = constraintStreamImplType;
return this;
}
public @NonNull ScoreDirectorFactoryConfig
withConstraintStreamAutomaticNodeSharing(@NonNull Boolean constraintStreamAutomaticNodeSharing) {
this.constraintStreamAutomaticNodeSharing = constraintStreamAutomaticNodeSharing;
return this;
}
public @NonNull ScoreDirectorFactoryConfig
withIncrementalScoreCalculatorClass(
@NonNull Class<? extends IncrementalScoreCalculator> incrementalScoreCalculatorClass) {
this.incrementalScoreCalculatorClass = incrementalScoreCalculatorClass;
return this;
}
public @NonNull ScoreDirectorFactoryConfig
withIncrementalScoreCalculatorCustomProperties(
@NonNull Map<@NonNull String, @NonNull String> incrementalScoreCalculatorCustomProperties) {
this.incrementalScoreCalculatorCustomProperties = incrementalScoreCalculatorCustomProperties;
return this;
}
/**
* @deprecated All support for Score DRL was removed when Timefold was forked from OptaPlanner.
* See <a href="https://timefold.ai/blog/migrating-score-drl-to-constraint-streams">DRL to Constraint Streams
* migration recipe</a>.
*/
@Deprecated(forRemoval = true)
public ScoreDirectorFactoryConfig withScoreDrlList(List<String> scoreDrlList) {
this.scoreDrlList = scoreDrlList;
return this;
}
/**
* @deprecated All support for Score DRL was removed when Timefold was forked from OptaPlanner.
* See <a href="https://timefold.ai/blog/migrating-score-drl-to-constraint-streams">DRL to Constraint Streams
* migration recipe</a>.
*/
@Deprecated(forRemoval = true)
public ScoreDirectorFactoryConfig withScoreDrls(String... scoreDrls) {
this.scoreDrlList = Arrays.asList(scoreDrls);
return this;
}
public @NonNull ScoreDirectorFactoryConfig withInitializingScoreTrend(@NonNull String initializingScoreTrend) {
this.initializingScoreTrend = initializingScoreTrend;
return this;
}
public @NonNull ScoreDirectorFactoryConfig withAssertionScoreDirectorFactory(
@NonNull ScoreDirectorFactoryConfig assertionScoreDirectorFactory) {
this.assertionScoreDirectorFactory = assertionScoreDirectorFactory;
return this;
}
@Override
public @NonNull ScoreDirectorFactoryConfig inherit(@NonNull ScoreDirectorFactoryConfig inheritedConfig) {
easyScoreCalculatorClass = ConfigUtils.inheritOverwritableProperty(
easyScoreCalculatorClass, inheritedConfig.getEasyScoreCalculatorClass());
easyScoreCalculatorCustomProperties = ConfigUtils.inheritMergeableMapProperty(
easyScoreCalculatorCustomProperties, inheritedConfig.getEasyScoreCalculatorCustomProperties());
constraintProviderClass = ConfigUtils.inheritOverwritableProperty(
constraintProviderClass, inheritedConfig.getConstraintProviderClass());
constraintProviderCustomProperties = ConfigUtils.inheritMergeableMapProperty(
constraintProviderCustomProperties, inheritedConfig.getConstraintProviderCustomProperties());
constraintStreamImplType = ConfigUtils.inheritOverwritableProperty(
constraintStreamImplType, inheritedConfig.getConstraintStreamImplType());
constraintStreamAutomaticNodeSharing = ConfigUtils.inheritOverwritableProperty(constraintStreamAutomaticNodeSharing,
inheritedConfig.getConstraintStreamAutomaticNodeSharing());
incrementalScoreCalculatorClass = ConfigUtils.inheritOverwritableProperty(
incrementalScoreCalculatorClass, inheritedConfig.getIncrementalScoreCalculatorClass());
incrementalScoreCalculatorCustomProperties = ConfigUtils.inheritMergeableMapProperty(
incrementalScoreCalculatorCustomProperties, inheritedConfig.getIncrementalScoreCalculatorCustomProperties());
scoreDrlList = ConfigUtils.inheritMergeableListProperty(
scoreDrlList, inheritedConfig.getScoreDrlList());
initializingScoreTrend = ConfigUtils.inheritOverwritableProperty(
initializingScoreTrend, inheritedConfig.getInitializingScoreTrend());
assertionScoreDirectorFactory = ConfigUtils.inheritOverwritableProperty(
assertionScoreDirectorFactory, inheritedConfig.getAssertionScoreDirectorFactory());
return this;
}
@Override
public @NonNull ScoreDirectorFactoryConfig copyConfig() {
return new ScoreDirectorFactoryConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
classVisitor.accept(easyScoreCalculatorClass);
classVisitor.accept(constraintProviderClass);
classVisitor.accept(incrementalScoreCalculatorClass);
if (assertionScoreDirectorFactory != null) {
assertionScoreDirectorFactory.visitReferencedClasses(classVisitor);
}
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/score | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/score/director/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.score.director;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/score | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/score/trend/InitializingScoreTrendLevel.java | package ai.timefold.solver.core.config.score.trend;
import jakarta.xml.bind.annotation.XmlEnum;
import ai.timefold.solver.core.api.domain.solution.PlanningSolution;
import ai.timefold.solver.core.api.score.Score;
import ai.timefold.solver.core.impl.score.trend.InitializingScoreTrend;
/**
* Bounds 1 score level of the possible {@link Score}s for a {@link PlanningSolution} as more and more variables are initialized
* (while the already initialized variables don't change).
*
* @see InitializingScoreTrend
*/
@XmlEnum
public enum InitializingScoreTrendLevel {
/**
* No predictions can be made.
*/
ANY,
/**
* During initialization, the {@link Score} is monotonically increasing.
* This means: given a non-fully initialized {@link PlanningSolution} with a {@link Score} A,
* initializing 1 or more variables (without altering the already initialized variables)
* will give a {@link PlanningSolution} for which the {@link Score} is better or equal to A.
* <p>
* In practice, this means that the score constraints of this score level are all positive,
* and initializing a variable cannot unmatch an already matched positive constraint.
* <p>
* Also implies the perfect minimum score is 0.
*/
ONLY_UP,
/**
* During initialization, the {@link Score} is monotonically decreasing.
* This means: given a non-fully initialized {@link PlanningSolution} with a {@link Score} A,
* initializing 1 or more variables (without altering the already initialized variables)
* will give a {@link PlanningSolution} for which the {@link Score} is worse or equal to A.
* <p>
* In practice, this means that the score constraints of this score level are all negative,
* and initializing a variable cannot unmatch an already matched negative constraint.
* <p>
* Also implies the perfect maximum score is 0.
*/
ONLY_DOWN;
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/score | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/score/trend/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.score.trend;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/EnvironmentMode.java | package ai.timefold.solver.core.config.solver;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import jakarta.xml.bind.annotation.XmlEnum;
import ai.timefold.solver.core.api.domain.entity.PlanningEntity;
import ai.timefold.solver.core.api.domain.variable.VariableListener;
import ai.timefold.solver.core.api.solver.Solver;
import ai.timefold.solver.core.impl.heuristic.move.Move;
import ai.timefold.solver.core.impl.score.director.InnerScoreDirector;
/**
* The environment mode also allows you to detect common bugs in your implementation.
* <p>
* Also, a {@link Solver} has a single {@link Random} instance.
* Some optimization algorithms use the {@link Random} instance a lot more than others.
* For example simulated annealing depends highly on random numbers,
* while tabu search only depends on it to deal with score ties.
* This environment mode influences the seed of that {@link Random} instance.
*/
@XmlEnum
public enum EnvironmentMode {
/**
* This mode turns on {@link #FULL_ASSERT} and enables variable tracking to fail-fast on a bug in a {@link Move}
* implementation,
* a constraint, the engine itself or something else at the highest performance cost.
* <p>
* Because it tracks genuine and shadow variables, it is able to report precisely what variables caused the corruption and
* report any missed {@link VariableListener} events.
* <p>
* This mode is reproducible (see {@link #PHASE_ASSERT} mode).
* <p>
* This mode is intrusive because it calls the {@link InnerScoreDirector#calculateScore()} more frequently than a non assert
* mode.
* <p>
* This mode is by far the slowest of all the modes.
*/
TRACKED_FULL_ASSERT(true),
/**
* This mode turns on all assertions
* to fail-fast on a bug in a {@link Move} implementation, a constraint, the engine itself or something else
* at a horrible performance cost.
* <p>
* This mode is reproducible (see {@link #PHASE_ASSERT} mode).
* <p>
* This mode is intrusive because it calls the {@link InnerScoreDirector#calculateScore()} more frequently
* than a non assert mode.
* <p>
* This mode is horribly slow.
*/
FULL_ASSERT(true),
/**
* This mode turns on several assertions (but not all of them)
* to fail-fast on a bug in a {@link Move} implementation, a constraint, the engine itself or something else
* at an overwhelming performance cost.
* <p>
* This mode is reproducible (see {@link #PHASE_ASSERT} mode).
* <p>
* This mode is non-intrusive, unlike {@link #FULL_ASSERT} and {@link #STEP_ASSERT}.
* <p>
* This mode is horribly slow.
*/
NON_INTRUSIVE_FULL_ASSERT(true),
/**
* @deprecated Prefer {@link #STEP_ASSERT}.
*/
@Deprecated(forRemoval = true, since = "1.20.0")
FAST_ASSERT(true),
/**
* This mode turns on several assertions to fail-fast
* on a bug in a {@link Move} implementation, a constraint rule, the engine itself or something else
* at a reasonable performance cost (in development at least).
* <p>
* This mode is reproducible (see {@link #PHASE_ASSERT} mode).
* <p>
* This mode is intrusive because it calls the {@link InnerScoreDirector#calculateScore()} more frequently
* than a non-assert mode.
* <p>
* This mode is slow.
*/
STEP_ASSERT(true),
/**
* This is the default mode as it is recommended during development,
* and runs minimal correctness checks that serve to quickly identify score corruption bugs.
* <p>
* In this mode, two runs on the same computer will execute the same code in the same order.
* They will also yield the same result, except if they use a time based termination
* and they have a sufficiently large difference in allocated CPU time.
* This allows you to benchmark new optimizations (such as a new {@link Move} implementation) fairly
* and reproduce bugs in your code reliably.
* <p>
* Warning: some code can disrupt reproducibility regardless of this mode.
* This typically happens when user code serves data such as {@link PlanningEntity planning entities}
* from collections without defined iteration order, such as {@link HashSet} or {@link HashMap}.
* <p>
* In practice, this mode uses the default random seed,
* and it also disables certain concurrency optimizations, such as work stealing.
*/
PHASE_ASSERT(true),
/**
* @deprecated Prefer {@link #NO_ASSERT}.
*/
@Deprecated(forRemoval = true, since = "1.20.0")
REPRODUCIBLE(false),
/**
* As defined by {@link #PHASE_ASSERT}, but disables every single bug detection mechanism.
* This mode will run negligibly faster than {@link #PHASE_ASSERT},
* but will allow some bugs in user code (such as score corruptions) to go unnoticed.
* Use this mode when you are confident that your code is bug-free,
* or when you want to ignore a known bug temporarily.
*/
NO_ASSERT(false),
/**
* The non-reproducible mode is equally fast or slightly faster than {@link #NO_ASSERT}.
* <p>
* The random seed is different on every run, which makes it more robust against an unlucky random seed.
* An unlucky random seed gives a bad result on a certain data set with a certain solver configuration.
* Note that in most use cases, the impact of the random seed is relatively low on the result.
* An occasional bad result is far more likely to be caused by another issue (such as a score trap).
* <p>
* In multithreaded scenarios, this mode allows the use of work stealing and other non-deterministic speed tricks.
*/
NON_REPRODUCIBLE(false);
private final boolean asserted;
EnvironmentMode(boolean asserted) {
this.asserted = asserted;
}
public boolean isStepAssertOrMore() {
if (!isAsserted()) {
return false;
}
return this != PHASE_ASSERT;
}
public boolean isAsserted() {
return asserted;
}
public boolean isFullyAsserted() {
return switch (this) {
case TRACKED_FULL_ASSERT, FULL_ASSERT, NON_INTRUSIVE_FULL_ASSERT -> true;
case STEP_ASSERT, FAST_ASSERT, PHASE_ASSERT, REPRODUCIBLE, NO_ASSERT, NON_REPRODUCIBLE -> false;
};
}
/**
* @deprecated Use {@link #isFullyAsserted()} instead.
*/
@Deprecated(forRemoval = true, since = "1.20.0")
public boolean isNonIntrusiveFullAsserted() {
return isFullyAsserted();
}
public boolean isIntrusivelyAsserted() {
return switch (this) {
// STEP_ASSERT = former FAST_ASSERT
case TRACKED_FULL_ASSERT, FULL_ASSERT, STEP_ASSERT, FAST_ASSERT -> true;
// NO_ASSERT = former REPRODUCIBLE
case NON_INTRUSIVE_FULL_ASSERT, PHASE_ASSERT, NO_ASSERT, NON_REPRODUCIBLE, REPRODUCIBLE -> false;
};
}
/**
* @deprecated Use {@link #isIntrusivelyAsserted()} instead.
*/
@Deprecated(forRemoval = true, since = "1.20.0")
public boolean isIntrusiveFastAsserted() {
return isIntrusivelyAsserted();
}
public boolean isReproducible() {
return this != NON_REPRODUCIBLE;
}
public boolean isTracking() {
return this == TRACKED_FULL_ASSERT;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/PreviewFeature.java | package ai.timefold.solver.core.config.solver;
/**
* Lists features available in Timefold Solver on a preview basis.
* These preview features are developed to the same standard as the rest of Timefold Solver.
* However, their APIs are not yet considered stable, pending user feedback.
* Any class, method, or field related to these features may change or be removed without prior notice,
* although we will strive to avoid this as much as possible.
* We encourage you to try these preview features and give us feedback on your experience with them.
* Please direct your feedback to our Github Discussions.
*
* <p>
* This list is not constant and is evolving over time,
* with items being added and removed without warning.
* It should not be treated as part of our public API,
* just like the preview features themselves.
*
* @see <a href="https://github.com/TimefoldAI/timefold-solver/discussions">Timefold Solver Github Discussions</a>
*/
public enum PreviewFeature {
DIVERSIFIED_LATE_ACCEPTANCE,
PLANNING_SOLUTION_DIFF,
/**
* Unlike other preview features, Move Streams are an active research project.
* It is intended to simplify the creation of custom moves, eventually replacing move selectors.
* The component is under heavy development, entirely undocumented, and many key features are yet to be delivered.
* Neither the API nor the feature set are complete, and any part can change or be removed at any time.
*
* Move Streams will eventually stabilize and be promoted from a research project to a true preview feature.
* We only expose it now to be able to use it for experimentation and testing.
* As such, it is an exception to the rule;
* this preview feature is not finished, and it is not yet ready for feedback.
*/
MOVE_STREAMS
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/SolverConfig.java | package ai.timefold.solver.core.config.solver;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.time.Clock;
import java.time.Duration;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ThreadFactory;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElements;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlTransient;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.api.domain.common.DomainAccessType;
import ai.timefold.solver.core.api.domain.solution.cloner.SolutionCloner;
import ai.timefold.solver.core.api.score.calculator.EasyScoreCalculator;
import ai.timefold.solver.core.api.score.stream.ConstraintProvider;
import ai.timefold.solver.core.api.score.stream.ConstraintStreamImplType;
import ai.timefold.solver.core.api.solver.Solver;
import ai.timefold.solver.core.api.solver.SolverFactory;
import ai.timefold.solver.core.config.AbstractConfig;
import ai.timefold.solver.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig;
import ai.timefold.solver.core.config.exhaustivesearch.ExhaustiveSearchPhaseConfig;
import ai.timefold.solver.core.config.localsearch.LocalSearchPhaseConfig;
import ai.timefold.solver.core.config.partitionedsearch.PartitionedSearchPhaseConfig;
import ai.timefold.solver.core.config.phase.NoChangePhaseConfig;
import ai.timefold.solver.core.config.phase.PhaseConfig;
import ai.timefold.solver.core.config.phase.custom.CustomPhaseConfig;
import ai.timefold.solver.core.config.score.director.ScoreDirectorFactoryConfig;
import ai.timefold.solver.core.config.solver.monitoring.MonitoringConfig;
import ai.timefold.solver.core.config.solver.monitoring.SolverMetric;
import ai.timefold.solver.core.config.solver.random.RandomType;
import ai.timefold.solver.core.config.solver.termination.TerminationConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import ai.timefold.solver.core.impl.domain.common.accessor.MemberAccessor;
import ai.timefold.solver.core.impl.heuristic.selector.common.nearby.NearbyDistanceMeter;
import ai.timefold.solver.core.impl.io.jaxb.SolverConfigIO;
import ai.timefold.solver.core.impl.io.jaxb.TimefoldXmlSerializationException;
import ai.timefold.solver.core.impl.phase.PhaseFactory;
import ai.timefold.solver.core.impl.solver.random.RandomFactory;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
/**
* To read it from XML, use {@link #createFromXmlResource(String)}.
* To build a {@link SolverFactory} with it, use {@link SolverFactory#create(SolverConfig)}.
*/
@XmlRootElement(name = SolverConfig.XML_ELEMENT_NAME)
@XmlType(name = SolverConfig.XML_TYPE_NAME, propOrder = {
"enablePreviewFeatureSet",
"environmentMode",
"daemon",
"randomType",
"randomSeed",
"randomFactoryClass",
"moveThreadCount",
"moveThreadBufferSize",
"threadFactoryClass",
"monitoringConfig",
"solutionClass",
"entityClassList",
"domainAccessType",
"scoreDirectorFactoryConfig",
"terminationConfig",
"nearbyDistanceMeterClass",
"phaseConfigList",
})
public class SolverConfig extends AbstractConfig<SolverConfig> {
public static final String XML_ELEMENT_NAME = "solver";
public static final String XML_NAMESPACE = "https://timefold.ai/xsd/solver";
public static final String XML_TYPE_NAME = "solverConfig";
/**
* Reads an XML solver configuration from the classpath.
*
* @param solverConfigResource a classpath resource as defined by {@link ClassLoader#getResource(String)}
*/
public static @NonNull SolverConfig createFromXmlResource(@NonNull String solverConfigResource) {
return createFromXmlResource(solverConfigResource, null);
}
/**
* As defined by {@link #createFromXmlResource(String)}.
*
* @param solverConfigResource a classpath resource
* as defined by {@link ClassLoader#getResource(String)}
* @param classLoader the {@link ClassLoader} to use for loading all resources and {@link Class}es,
* null to use the default {@link ClassLoader}
*/
public static @NonNull SolverConfig createFromXmlResource(@NonNull String solverConfigResource,
@Nullable ClassLoader classLoader) {
ClassLoader actualClassLoader = classLoader != null ? classLoader : Thread.currentThread().getContextClassLoader();
try (InputStream in = actualClassLoader.getResourceAsStream(solverConfigResource)) {
if (in == null) {
String errorMessage = "The solverConfigResource (" + solverConfigResource
+ ") does not exist as a classpath resource in the classLoader (" + actualClassLoader + ").";
if (solverConfigResource.startsWith("/")) {
errorMessage += "\nA classpath resource should not start with a slash (/)."
+ " A solverConfigResource adheres to ClassLoader.getResource(String)."
+ " Maybe remove the leading slash from the solverConfigResource.";
}
throw new IllegalArgumentException(errorMessage);
}
return createFromXmlInputStream(in, classLoader);
} catch (TimefoldXmlSerializationException e) {
throw new IllegalArgumentException("Unmarshalling of solverConfigResource (" + solverConfigResource + ") fails.",
e);
} catch (IOException e) {
throw new IllegalArgumentException("Reading the solverConfigResource (" + solverConfigResource + ") fails.", e);
}
}
/**
* Reads an XML solver configuration from the file system.
* <p>
* Warning: this leads to platform dependent code,
* it's recommend to use {@link #createFromXmlResource(String)} instead.
*
*/
public static @NonNull SolverConfig createFromXmlFile(@NonNull File solverConfigFile) {
return createFromXmlFile(solverConfigFile, null);
}
/**
* As defined by {@link #createFromXmlFile(File)}.
*
* @param classLoader the {@link ClassLoader} to use for loading all resources and {@link Class}es,
* null to use the default {@link ClassLoader}
*/
public static @NonNull SolverConfig createFromXmlFile(@NonNull File solverConfigFile, @Nullable ClassLoader classLoader) {
try (InputStream in = new FileInputStream(solverConfigFile)) {
return createFromXmlInputStream(in, classLoader);
} catch (TimefoldXmlSerializationException e) {
throw new IllegalArgumentException("Unmarshalling the solverConfigFile (" + solverConfigFile + ") fails.", e);
} catch (FileNotFoundException e) {
throw new IllegalArgumentException("The solverConfigFile (" + solverConfigFile + ") was not found.", e);
} catch (IOException e) {
throw new IllegalArgumentException("Reading the solverConfigFile (" + solverConfigFile + ") fails.", e);
}
}
/**
* @param in gets closed
*/
public static @NonNull SolverConfig createFromXmlInputStream(@NonNull InputStream in) {
return createFromXmlInputStream(in, null);
}
/**
* As defined by {@link #createFromXmlInputStream(InputStream)}.
*
* @param in gets closed
* @param classLoader the {@link ClassLoader} to use for loading all resources and {@link Class}es,
* null to use the default {@link ClassLoader}
*/
public static @NonNull SolverConfig createFromXmlInputStream(@NonNull InputStream in, @Nullable ClassLoader classLoader) {
try (Reader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) {
return createFromXmlReader(reader, classLoader);
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("This vm does not support the charset (" + StandardCharsets.UTF_8 + ").", e);
} catch (IOException e) {
throw new IllegalArgumentException("Reading solverConfigInputStream fails.", e);
}
}
/**
* @param reader gets closed
*/
public static @NonNull SolverConfig createFromXmlReader(@NonNull Reader reader) {
return createFromXmlReader(reader, null);
}
/**
* As defined by {@link #createFromXmlReader(Reader)}.
*
* @param reader gets closed
* @param classLoader the {@link ClassLoader} to use for loading all resources and {@link Class}es,
* null to use the default {@link ClassLoader}
*/
public static @NonNull SolverConfig createFromXmlReader(@NonNull Reader reader, @Nullable ClassLoader classLoader) {
SolverConfigIO solverConfigIO = new SolverConfigIO();
SolverConfig solverConfig = solverConfigIO.read(reader);
solverConfig.setClassLoader(classLoader);
return solverConfig;
}
// ************************************************************************
// Fields
// ************************************************************************
public static final String MOVE_THREAD_COUNT_NONE = "NONE";
public static final String MOVE_THREAD_COUNT_AUTO = "AUTO";
@XmlTransient
private Clock clock = null;
@XmlTransient
private ClassLoader classLoader = null;
// Warning: all fields are null (and not defaulted) because they can be inherited
// and also because the input config file should match the output config file
@XmlElement(name = "enablePreviewFeature")
protected Set<PreviewFeature> enablePreviewFeatureSet = null;
protected EnvironmentMode environmentMode = null;
protected Boolean daemon = null;
protected RandomType randomType = null;
protected Long randomSeed = null;
protected Class<? extends RandomFactory> randomFactoryClass = null;
protected String moveThreadCount = null;
protected Integer moveThreadBufferSize = null;
protected Class<? extends ThreadFactory> threadFactoryClass = null;
protected Class<?> solutionClass = null;
@XmlElement(name = "entityClass")
protected List<Class<?>> entityClassList = null;
protected DomainAccessType domainAccessType = null;
@XmlTransient
protected Map<String, MemberAccessor> gizmoMemberAccessorMap = null;
@XmlTransient
protected Map<String, SolutionCloner> gizmoSolutionClonerMap = null;
@XmlElement(name = "scoreDirectorFactory")
protected ScoreDirectorFactoryConfig scoreDirectorFactoryConfig = null;
@XmlElement(name = "termination")
private TerminationConfig terminationConfig;
protected Class<? extends NearbyDistanceMeter<?, ?>> nearbyDistanceMeterClass = null;
@XmlElements({
@XmlElement(name = ConstructionHeuristicPhaseConfig.XML_ELEMENT_NAME,
type = ConstructionHeuristicPhaseConfig.class),
@XmlElement(name = CustomPhaseConfig.XML_ELEMENT_NAME, type = CustomPhaseConfig.class),
@XmlElement(name = ExhaustiveSearchPhaseConfig.XML_ELEMENT_NAME, type = ExhaustiveSearchPhaseConfig.class),
@XmlElement(name = LocalSearchPhaseConfig.XML_ELEMENT_NAME, type = LocalSearchPhaseConfig.class),
@XmlElement(name = NoChangePhaseConfig.XML_ELEMENT_NAME, type = NoChangePhaseConfig.class),
@XmlElement(name = PartitionedSearchPhaseConfig.XML_ELEMENT_NAME, type = PartitionedSearchPhaseConfig.class)
})
protected List<PhaseConfig> phaseConfigList = null;
@XmlElement(name = "monitoring")
protected MonitoringConfig monitoringConfig = null;
// ************************************************************************
// Constructors and simple getters/setters
// ************************************************************************
/**
* Create an empty solver config.
*/
public SolverConfig() {
}
/**
* For testing purposes only.
*/
public SolverConfig(@NonNull Clock clock) {
this.clock = Objects.requireNonNull(clock);
}
public SolverConfig(@Nullable ClassLoader classLoader) {
this.classLoader = classLoader;
}
/**
* Allows you to programmatically change the {@link SolverConfig} per concurrent request,
* based on a template solver config,
* by building a separate {@link SolverFactory} with {@link SolverFactory#create(SolverConfig)}
* and a separate {@link Solver} per request to avoid race conditions.
*
*/
public SolverConfig(@NonNull SolverConfig inheritedConfig) {
inherit(inheritedConfig);
}
/**
* For testing purposes only.
*
* @return null if system default should be used
*/
public @Nullable Clock getClock() {
return clock;
}
/**
* For testing purposes only.
*/
public void setClock(@Nullable Clock clock) {
this.clock = clock;
}
public @Nullable ClassLoader getClassLoader() {
return classLoader;
}
public void setClassLoader(@Nullable ClassLoader classLoader) {
this.classLoader = classLoader;
}
public @Nullable Set<PreviewFeature> getEnablePreviewFeatureSet() {
return enablePreviewFeatureSet;
}
public void setEnablePreviewFeatureSet(@Nullable Set<PreviewFeature> enablePreviewFeatureSet) {
this.enablePreviewFeatureSet = enablePreviewFeatureSet;
}
public @Nullable EnvironmentMode getEnvironmentMode() {
return environmentMode;
}
public void setEnvironmentMode(@Nullable EnvironmentMode environmentMode) {
this.environmentMode = environmentMode;
}
public @Nullable Boolean getDaemon() {
return daemon;
}
public void setDaemon(@Nullable Boolean daemon) {
this.daemon = daemon;
}
public @Nullable RandomType getRandomType() {
return randomType;
}
public void setRandomType(@Nullable RandomType randomType) {
this.randomType = randomType;
}
public @Nullable Long getRandomSeed() {
return randomSeed;
}
public void setRandomSeed(@Nullable Long randomSeed) {
this.randomSeed = randomSeed;
}
public @Nullable Class<? extends RandomFactory> getRandomFactoryClass() {
return randomFactoryClass;
}
public void setRandomFactoryClass(@Nullable Class<? extends RandomFactory> randomFactoryClass) {
this.randomFactoryClass = randomFactoryClass;
}
public @Nullable String getMoveThreadCount() {
return moveThreadCount;
}
public void setMoveThreadCount(@Nullable String moveThreadCount) {
this.moveThreadCount = moveThreadCount;
}
public @Nullable Integer getMoveThreadBufferSize() {
return moveThreadBufferSize;
}
public void setMoveThreadBufferSize(@Nullable Integer moveThreadBufferSize) {
this.moveThreadBufferSize = moveThreadBufferSize;
}
public @Nullable Class<? extends ThreadFactory> getThreadFactoryClass() {
return threadFactoryClass;
}
public void setThreadFactoryClass(@Nullable Class<? extends ThreadFactory> threadFactoryClass) {
this.threadFactoryClass = threadFactoryClass;
}
public @Nullable Class<?> getSolutionClass() {
return solutionClass;
}
public void setSolutionClass(@Nullable Class<?> solutionClass) {
this.solutionClass = solutionClass;
}
public @Nullable List<Class<?>> getEntityClassList() {
return entityClassList;
}
public void setEntityClassList(@Nullable List<Class<?>> entityClassList) {
this.entityClassList = entityClassList;
}
public @Nullable DomainAccessType getDomainAccessType() {
return domainAccessType;
}
public void setDomainAccessType(@Nullable DomainAccessType domainAccessType) {
this.domainAccessType = domainAccessType;
}
public @Nullable Map<@NonNull String, @NonNull MemberAccessor> getGizmoMemberAccessorMap() {
return gizmoMemberAccessorMap;
}
public void setGizmoMemberAccessorMap(@Nullable Map<@NonNull String, @NonNull MemberAccessor> gizmoMemberAccessorMap) {
this.gizmoMemberAccessorMap = gizmoMemberAccessorMap;
}
public @Nullable Map<@NonNull String, @NonNull SolutionCloner> getGizmoSolutionClonerMap() {
return gizmoSolutionClonerMap;
}
public void setGizmoSolutionClonerMap(@Nullable Map<@NonNull String, @NonNull SolutionCloner> gizmoSolutionClonerMap) {
this.gizmoSolutionClonerMap = gizmoSolutionClonerMap;
}
public @Nullable ScoreDirectorFactoryConfig getScoreDirectorFactoryConfig() {
return scoreDirectorFactoryConfig;
}
public void setScoreDirectorFactoryConfig(@Nullable ScoreDirectorFactoryConfig scoreDirectorFactoryConfig) {
this.scoreDirectorFactoryConfig = scoreDirectorFactoryConfig;
}
public @Nullable TerminationConfig getTerminationConfig() {
return terminationConfig;
}
public void setTerminationConfig(@Nullable TerminationConfig terminationConfig) {
this.terminationConfig = terminationConfig;
}
public @Nullable Class<? extends NearbyDistanceMeter<?, ?>> getNearbyDistanceMeterClass() {
return nearbyDistanceMeterClass;
}
public void setNearbyDistanceMeterClass(@Nullable Class<? extends NearbyDistanceMeter<?, ?>> nearbyDistanceMeterClass) {
this.nearbyDistanceMeterClass = nearbyDistanceMeterClass;
}
public @Nullable List<@NonNull PhaseConfig> getPhaseConfigList() {
return phaseConfigList;
}
public void setPhaseConfigList(@Nullable List<@NonNull PhaseConfig> phaseConfigList) {
this.phaseConfigList = phaseConfigList;
}
public @Nullable MonitoringConfig getMonitoringConfig() {
return monitoringConfig;
}
public void setMonitoringConfig(@Nullable MonitoringConfig monitoringConfig) {
this.monitoringConfig = monitoringConfig;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull SolverConfig withPreviewFeature(@NonNull PreviewFeature... previewFeature) {
enablePreviewFeatureSet = EnumSet.copyOf(Arrays.asList(previewFeature));
return this;
}
public @NonNull SolverConfig withEnvironmentMode(@NonNull EnvironmentMode environmentMode) {
this.environmentMode = environmentMode;
return this;
}
public @NonNull SolverConfig withDaemon(@NonNull Boolean daemon) {
this.daemon = daemon;
return this;
}
public @NonNull SolverConfig withRandomType(@NonNull RandomType randomType) {
this.randomType = randomType;
return this;
}
public @NonNull SolverConfig withRandomSeed(@NonNull Long randomSeed) {
this.randomSeed = randomSeed;
return this;
}
public @NonNull SolverConfig withRandomFactoryClass(@NonNull Class<? extends RandomFactory> randomFactoryClass) {
this.randomFactoryClass = randomFactoryClass;
return this;
}
public @NonNull SolverConfig withMoveThreadCount(@NonNull String moveThreadCount) {
this.moveThreadCount = moveThreadCount;
return this;
}
public @NonNull SolverConfig withMoveThreadBufferSize(@NonNull Integer moveThreadBufferSize) {
this.moveThreadBufferSize = moveThreadBufferSize;
return this;
}
public @NonNull SolverConfig withThreadFactoryClass(@NonNull Class<? extends ThreadFactory> threadFactoryClass) {
this.threadFactoryClass = threadFactoryClass;
return this;
}
public @NonNull SolverConfig withSolutionClass(@NonNull Class<?> solutionClass) {
this.solutionClass = solutionClass;
return this;
}
public @NonNull SolverConfig withEntityClassList(@NonNull List<Class<?>> entityClassList) {
this.entityClassList = entityClassList;
return this;
}
public @NonNull SolverConfig withEntityClasses(@NonNull Class<?>... entityClasses) {
this.entityClassList = Arrays.asList(entityClasses);
return this;
}
public @NonNull SolverConfig withDomainAccessType(@NonNull DomainAccessType domainAccessType) {
this.domainAccessType = domainAccessType;
return this;
}
public @NonNull SolverConfig
withGizmoMemberAccessorMap(@NonNull Map<@NonNull String, @NonNull MemberAccessor> memberAccessorMap) {
this.gizmoMemberAccessorMap = memberAccessorMap;
return this;
}
public @NonNull SolverConfig
withGizmoSolutionClonerMap(@NonNull Map<@NonNull String, @NonNull SolutionCloner> solutionClonerMap) {
this.gizmoSolutionClonerMap = solutionClonerMap;
return this;
}
public @NonNull SolverConfig withScoreDirectorFactory(@NonNull ScoreDirectorFactoryConfig scoreDirectorFactoryConfig) {
this.scoreDirectorFactoryConfig = scoreDirectorFactoryConfig;
return this;
}
public @NonNull SolverConfig withClassLoader(@NonNull ClassLoader classLoader) {
this.setClassLoader(classLoader);
return this;
}
/**
* As defined by {@link ScoreDirectorFactoryConfig#withEasyScoreCalculatorClass(Class)}, but returns this.
*/
public @NonNull SolverConfig withEasyScoreCalculatorClass(
@NonNull Class<? extends EasyScoreCalculator> easyScoreCalculatorClass) {
if (scoreDirectorFactoryConfig == null) {
scoreDirectorFactoryConfig = new ScoreDirectorFactoryConfig();
}
scoreDirectorFactoryConfig.setEasyScoreCalculatorClass(easyScoreCalculatorClass);
return this;
}
/**
* As defined by {@link ScoreDirectorFactoryConfig#withConstraintProviderClass(Class)}, but returns this.
*/
public @NonNull SolverConfig withConstraintProviderClass(
@NonNull Class<? extends ConstraintProvider> constraintProviderClass) {
if (scoreDirectorFactoryConfig == null) {
scoreDirectorFactoryConfig = new ScoreDirectorFactoryConfig();
}
scoreDirectorFactoryConfig.setConstraintProviderClass(constraintProviderClass);
return this;
}
public @NonNull SolverConfig withConstraintStreamImplType(@NonNull ConstraintStreamImplType constraintStreamImplType) {
if (scoreDirectorFactoryConfig == null) {
scoreDirectorFactoryConfig = new ScoreDirectorFactoryConfig();
}
scoreDirectorFactoryConfig.setConstraintStreamImplType(constraintStreamImplType);
return this;
}
public @NonNull SolverConfig withTerminationConfig(@NonNull TerminationConfig terminationConfig) {
this.terminationConfig = terminationConfig;
return this;
}
/**
* As defined by {@link TerminationConfig#withSpentLimit(Duration)}, but returns this.
*/
public @NonNull SolverConfig withTerminationSpentLimit(@NonNull Duration spentLimit) {
if (terminationConfig == null) {
terminationConfig = new TerminationConfig();
}
terminationConfig.setSpentLimit(spentLimit);
return this;
}
/**
* As defined by {@link TerminationConfig#withUnimprovedSpentLimit(Duration)}, but returns this.
*/
public @NonNull SolverConfig withTerminationUnimprovedSpentLimit(@NonNull Duration unimprovedSpentLimit) {
if (terminationConfig == null) {
terminationConfig = new TerminationConfig();
}
terminationConfig.setUnimprovedSpentLimit(unimprovedSpentLimit);
return this;
}
public @NonNull SolverConfig
withNearbyDistanceMeterClass(@NonNull Class<? extends NearbyDistanceMeter<?, ?>> distanceMeterClass) {
this.nearbyDistanceMeterClass = distanceMeterClass;
return this;
}
public @NonNull SolverConfig withPhaseList(@NonNull List<@NonNull PhaseConfig> phaseConfigList) {
this.phaseConfigList = phaseConfigList;
return this;
}
public @NonNull SolverConfig withPhases(@NonNull PhaseConfig... phaseConfigs) {
this.phaseConfigList = Arrays.asList(phaseConfigs);
return this;
}
public @NonNull SolverConfig withMonitoringConfig(@NonNull MonitoringConfig monitoringConfig) {
this.monitoringConfig = monitoringConfig;
return this;
}
// ************************************************************************
// Smart getters
// ************************************************************************
/**
*
* @return true if the solver has either a global termination configured,
* or all of its phases have a termination configured
*/
public boolean canTerminate() {
if (terminationConfig != null && terminationConfig.isConfigured()) {
return true;
}
var configList = getPhaseConfigList();
if (configList == null) {
return true;
}
return configList.stream()
.allMatch(PhaseFactory::canTerminate);
}
public @NonNull EnvironmentMode determineEnvironmentMode() {
return Objects.requireNonNullElse(environmentMode, EnvironmentMode.PHASE_ASSERT);
}
public @NonNull DomainAccessType determineDomainAccessType() {
return Objects.requireNonNullElse(domainAccessType, DomainAccessType.REFLECTION);
}
public @NonNull MonitoringConfig determineMetricConfig() {
return Objects.requireNonNullElse(monitoringConfig,
new MonitoringConfig().withSolverMetricList(Arrays.asList(SolverMetric.SOLVE_DURATION, SolverMetric.ERROR_COUNT,
SolverMetric.SCORE_CALCULATION_COUNT, SolverMetric.MOVE_EVALUATION_COUNT,
SolverMetric.PROBLEM_ENTITY_COUNT, SolverMetric.PROBLEM_VARIABLE_COUNT,
SolverMetric.PROBLEM_VALUE_COUNT, SolverMetric.PROBLEM_SIZE_LOG)));
}
// ************************************************************************
// Builder methods
// ************************************************************************
public void offerRandomSeedFromSubSingleIndex(long subSingleIndex) {
if ((environmentMode == null || environmentMode.isReproducible()) && randomFactoryClass == null && randomSeed == null) {
randomSeed = subSingleIndex;
}
}
/**
* Do not use this method, it is an internal method.
* Use {@link #SolverConfig(SolverConfig)} instead.
*/
@Override
public @NonNull SolverConfig inherit(@NonNull SolverConfig inheritedConfig) {
clock = ConfigUtils.inheritOverwritableProperty(clock, inheritedConfig.getClock());
classLoader = ConfigUtils.inheritOverwritableProperty(classLoader, inheritedConfig.getClassLoader());
enablePreviewFeatureSet = ConfigUtils.inheritMergeableEnumSetProperty(enablePreviewFeatureSet,
inheritedConfig.getEnablePreviewFeatureSet());
environmentMode = ConfigUtils.inheritOverwritableProperty(environmentMode, inheritedConfig.getEnvironmentMode());
daemon = ConfigUtils.inheritOverwritableProperty(daemon, inheritedConfig.getDaemon());
randomType = ConfigUtils.inheritOverwritableProperty(randomType, inheritedConfig.getRandomType());
randomSeed = ConfigUtils.inheritOverwritableProperty(randomSeed, inheritedConfig.getRandomSeed());
randomFactoryClass = ConfigUtils.inheritOverwritableProperty(randomFactoryClass,
inheritedConfig.getRandomFactoryClass());
moveThreadCount = ConfigUtils.inheritOverwritableProperty(moveThreadCount,
inheritedConfig.getMoveThreadCount());
moveThreadBufferSize = ConfigUtils.inheritOverwritableProperty(moveThreadBufferSize,
inheritedConfig.getMoveThreadBufferSize());
threadFactoryClass = ConfigUtils.inheritOverwritableProperty(threadFactoryClass,
inheritedConfig.getThreadFactoryClass());
solutionClass = ConfigUtils.inheritOverwritableProperty(solutionClass, inheritedConfig.getSolutionClass());
entityClassList = ConfigUtils.inheritMergeableListProperty(entityClassList,
inheritedConfig.getEntityClassList());
domainAccessType = ConfigUtils.inheritOverwritableProperty(domainAccessType, inheritedConfig.getDomainAccessType());
gizmoMemberAccessorMap = ConfigUtils.inheritMergeableMapProperty(
gizmoMemberAccessorMap, inheritedConfig.getGizmoMemberAccessorMap());
gizmoSolutionClonerMap = ConfigUtils.inheritMergeableMapProperty(
gizmoSolutionClonerMap, inheritedConfig.getGizmoSolutionClonerMap());
scoreDirectorFactoryConfig = ConfigUtils.inheritConfig(scoreDirectorFactoryConfig,
inheritedConfig.getScoreDirectorFactoryConfig());
terminationConfig = ConfigUtils.inheritConfig(terminationConfig, inheritedConfig.getTerminationConfig());
nearbyDistanceMeterClass = ConfigUtils.inheritOverwritableProperty(nearbyDistanceMeterClass,
inheritedConfig.getNearbyDistanceMeterClass());
phaseConfigList = ConfigUtils.inheritMergeableListConfig(phaseConfigList, inheritedConfig.getPhaseConfigList());
monitoringConfig = ConfigUtils.inheritConfig(monitoringConfig, inheritedConfig.getMonitoringConfig());
return this;
}
@Override
public @NonNull SolverConfig copyConfig() {
return new SolverConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
classVisitor.accept(randomFactoryClass);
classVisitor.accept(threadFactoryClass);
classVisitor.accept(solutionClass);
if (entityClassList != null) {
entityClassList.forEach(classVisitor);
}
if (scoreDirectorFactoryConfig != null) {
scoreDirectorFactoryConfig.visitReferencedClasses(classVisitor);
}
if (nearbyDistanceMeterClass != null) {
classVisitor.accept(nearbyDistanceMeterClass);
}
if (terminationConfig != null) {
terminationConfig.visitReferencedClasses(classVisitor);
}
if (phaseConfigList != null) {
phaseConfigList.forEach(pc -> pc.visitReferencedClasses(classVisitor));
}
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/SolverManagerConfig.java | package ai.timefold.solver.core.config.solver;
import java.util.concurrent.ThreadFactory;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.AbstractConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@XmlType(propOrder = {
"parallelSolverCount",
"threadFactoryClass"
})
public class SolverManagerConfig extends AbstractConfig<SolverManagerConfig> {
public static final String PARALLEL_SOLVER_COUNT_AUTO = "AUTO";
private static final Logger LOGGER = LoggerFactory.getLogger(SolverManagerConfig.class);
protected String parallelSolverCount = null;
protected Class<? extends ThreadFactory> threadFactoryClass = null;
// Future features:
// throttlingDelay
// congestionStrategy
// ************************************************************************
// Constructors and simple getters/setters
// ************************************************************************
public SolverManagerConfig() {
}
public @Nullable String getParallelSolverCount() {
return parallelSolverCount;
}
public void setParallelSolverCount(@Nullable String parallelSolverCount) {
this.parallelSolverCount = parallelSolverCount;
}
public @Nullable Class<? extends ThreadFactory> getThreadFactoryClass() {
return threadFactoryClass;
}
public void setThreadFactoryClass(@Nullable Class<? extends ThreadFactory> threadFactoryClass) {
this.threadFactoryClass = threadFactoryClass;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull SolverManagerConfig withParallelSolverCount(@NonNull String parallelSolverCount) {
this.parallelSolverCount = parallelSolverCount;
return this;
}
public @NonNull SolverManagerConfig withThreadFactoryClass(@NonNull Class<? extends ThreadFactory> threadFactoryClass) {
this.threadFactoryClass = threadFactoryClass;
return this;
}
// ************************************************************************
// Builder methods
// ************************************************************************
public @NonNull Integer resolveParallelSolverCount() {
int availableProcessorCount = getAvailableProcessors();
Integer resolvedParallelSolverCount;
if (parallelSolverCount == null || parallelSolverCount.equals(PARALLEL_SOLVER_COUNT_AUTO)) {
resolvedParallelSolverCount = resolveParallelSolverCountAutomatically(availableProcessorCount);
} else {
resolvedParallelSolverCount = ConfigUtils.resolvePoolSize("parallelSolverCount",
parallelSolverCount, PARALLEL_SOLVER_COUNT_AUTO);
}
if (resolvedParallelSolverCount < 1) {
throw new IllegalArgumentException("The parallelSolverCount (" + parallelSolverCount
+ ") resulted in a resolvedParallelSolverCount (" + resolvedParallelSolverCount
+ ") that is lower than 1.");
}
if (resolvedParallelSolverCount > availableProcessorCount) {
LOGGER.warn("The resolvedParallelSolverCount ({}) is higher "
+ "than the availableProcessorCount ({}), which is counter-efficient.",
resolvedParallelSolverCount, availableProcessorCount);
// Still allow it, to reproduce issues of a high-end server machine on a low-end developer machine
}
return resolvedParallelSolverCount;
}
protected int getAvailableProcessors() {
return Runtime.getRuntime().availableProcessors();
}
protected int resolveParallelSolverCountAutomatically(int availableProcessorCount) {
// Tweaked based on experience
if (availableProcessorCount < 2) {
return 1;
} else {
return availableProcessorCount / 2;
}
}
@Override
public @NonNull SolverManagerConfig inherit(@NonNull SolverManagerConfig inheritedConfig) {
parallelSolverCount = ConfigUtils.inheritOverwritableProperty(parallelSolverCount,
inheritedConfig.getParallelSolverCount());
threadFactoryClass = ConfigUtils.inheritOverwritableProperty(threadFactoryClass,
inheritedConfig.getThreadFactoryClass());
return this;
}
@Override
public @NonNull SolverManagerConfig copyConfig() {
return new SolverManagerConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
classVisitor.accept(threadFactoryClass);
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.solver;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/monitoring/MonitoringConfig.java | package ai.timefold.solver.core.config.solver.monitoring;
import java.util.List;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import ai.timefold.solver.core.config.AbstractConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"solverMetricList",
})
public class MonitoringConfig extends AbstractConfig<MonitoringConfig> {
@XmlElement(name = "metric")
protected List<SolverMetric> solverMetricList = null;
// ************************************************************************
// Constructors and simple getters/setters
// ************************************************************************
public @Nullable List<@NonNull SolverMetric> getSolverMetricList() {
return solverMetricList;
}
public void setSolverMetricList(@Nullable List<@NonNull SolverMetric> solverMetricList) {
this.solverMetricList = solverMetricList;
}
// ************************************************************************
// With methods
// ************************************************************************
public @NonNull MonitoringConfig withSolverMetricList(@NonNull List<@NonNull SolverMetric> solverMetricList) {
this.solverMetricList = solverMetricList;
return this;
}
@Override
public @NonNull MonitoringConfig inherit(@NonNull MonitoringConfig inheritedConfig) {
solverMetricList = ConfigUtils.inheritMergeableListProperty(solverMetricList, inheritedConfig.solverMetricList);
return this;
}
@Override
public @NonNull MonitoringConfig copyConfig() {
return new MonitoringConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
// No referenced classes currently
// If we add custom metrics here, then this should
// register the custom metrics
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/monitoring/SolverMetric.java | package ai.timefold.solver.core.config.solver.monitoring;
import java.util.function.ToDoubleFunction;
import jakarta.xml.bind.annotation.XmlEnum;
import ai.timefold.solver.core.api.solver.Solver;
import ai.timefold.solver.core.impl.solver.monitoring.statistic.BestScoreStatistic;
import ai.timefold.solver.core.impl.solver.monitoring.statistic.BestSolutionMutationCountStatistic;
import ai.timefold.solver.core.impl.solver.monitoring.statistic.MemoryUseStatistic;
import ai.timefold.solver.core.impl.solver.monitoring.statistic.MoveCountPerTypeStatistic;
import ai.timefold.solver.core.impl.solver.monitoring.statistic.PickedMoveBestScoreDiffStatistic;
import ai.timefold.solver.core.impl.solver.monitoring.statistic.PickedMoveStepScoreDiffStatistic;
import ai.timefold.solver.core.impl.solver.monitoring.statistic.SolverScopeStatistic;
import ai.timefold.solver.core.impl.solver.monitoring.statistic.SolverStatistic;
import ai.timefold.solver.core.impl.solver.monitoring.statistic.StatelessSolverStatistic;
import ai.timefold.solver.core.impl.solver.scope.SolverScope;
import org.jspecify.annotations.NonNull;
@XmlEnum
public enum SolverMetric {
SOLVE_DURATION("timefold.solver.solve.duration", false),
ERROR_COUNT("timefold.solver.errors", false),
SCORE_CALCULATION_COUNT("timefold.solver.score.calculation.count",
SolverScope::getScoreCalculationCount,
false),
MOVE_EVALUATION_COUNT("timefold.solver.move.evaluation.count",
SolverScope::getMoveEvaluationCount,
false),
PROBLEM_ENTITY_COUNT("timefold.solver.problem.entities",
solverScope -> solverScope.getProblemSizeStatistics().entityCount(),
false),
PROBLEM_VARIABLE_COUNT("timefold.solver.problem.variables",
solverScope -> solverScope.getProblemSizeStatistics().variableCount(),
false),
PROBLEM_VALUE_COUNT("timefold.solver.problem.values",
solverScope -> solverScope.getProblemSizeStatistics().approximateValueCount(),
false),
PROBLEM_SIZE_LOG("timefold.solver.problem.size.log",
solverScope -> solverScope.getProblemSizeStatistics().approximateProblemSizeLog(),
false),
BEST_SCORE("timefold.solver.best.score", new BestScoreStatistic<>(), true),
STEP_SCORE("timefold.solver.step.score", false),
BEST_SOLUTION_MUTATION("timefold.solver.best.solution.mutation", new BestSolutionMutationCountStatistic<>(), true),
MOVE_COUNT_PER_STEP("timefold.solver.step.move.count", false),
MOVE_COUNT_PER_TYPE("timefold.solver.move.type.count", new MoveCountPerTypeStatistic<>(), false),
MEMORY_USE("jvm.memory.used", new MemoryUseStatistic<>(), false),
CONSTRAINT_MATCH_TOTAL_BEST_SCORE("timefold.solver.constraint.match.best.score", true, true),
CONSTRAINT_MATCH_TOTAL_STEP_SCORE("timefold.solver.constraint.match.step.score", false, true),
PICKED_MOVE_TYPE_BEST_SCORE_DIFF("timefold.solver.move.type.best.score.diff", new PickedMoveBestScoreDiffStatistic<>(),
true),
PICKED_MOVE_TYPE_STEP_SCORE_DIFF("timefold.solver.move.type.step.score.diff", new PickedMoveStepScoreDiffStatistic<>(),
false);
private final String meterId;
@SuppressWarnings("rawtypes")
private final SolverStatistic registerFunction;
private final boolean isBestSolutionBased;
private final boolean isConstraintMatchBased;
SolverMetric(String meterId, boolean isBestSolutionBased) {
this(meterId, isBestSolutionBased, false);
}
SolverMetric(String meterId, boolean isBestSolutionBased, boolean isConstraintMatchBased) {
this(meterId, new StatelessSolverStatistic<>(), isBestSolutionBased, isConstraintMatchBased);
}
SolverMetric(String meterId, ToDoubleFunction<SolverScope<Object>> gaugeFunction, boolean isBestSolutionBased) {
this(meterId, new SolverScopeStatistic<>(meterId, gaugeFunction), isBestSolutionBased, false);
}
SolverMetric(String meterId, SolverStatistic<?> registerFunction, boolean isBestSolutionBased) {
this(meterId, registerFunction, isBestSolutionBased, false);
}
SolverMetric(String meterId, SolverStatistic<?> registerFunction, boolean isBestSolutionBased,
boolean isConstraintMatchBased) {
this.meterId = meterId;
this.registerFunction = registerFunction;
this.isBestSolutionBased = isBestSolutionBased;
this.isConstraintMatchBased = isConstraintMatchBased;
}
public @NonNull String getMeterId() {
return meterId;
}
public boolean isMetricBestSolutionBased() {
return isBestSolutionBased;
}
public boolean isMetricConstraintMatchBased() {
return isConstraintMatchBased;
}
@SuppressWarnings("unchecked")
public void register(@NonNull Solver<?> solver) {
registerFunction.register(solver);
}
@SuppressWarnings("unchecked")
public void unregister(@NonNull Solver<?> solver) {
registerFunction.unregister(solver);
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/monitoring/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.solver.monitoring;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/random/RandomType.java | package ai.timefold.solver.core.config.solver.random;
import jakarta.xml.bind.annotation.XmlEnum;
/**
* Defines the pseudo random number generator.
* See the <a href="http://commons.apache.org/proper/commons-math/userguide/random.html#a2.7_PRNG_Pluggability">PRNG</a>
* documentation in commons-math.
*/
@XmlEnum
public enum RandomType {
/**
* This is the default.
*/
JDK,
MERSENNE_TWISTER,
WELL512A,
WELL1024A,
WELL19937A,
WELL19937C,
WELL44497A,
WELL44497B;
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/random/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.solver.random;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/termination/DiminishedReturnsTerminationConfig.java | package ai.timefold.solver.core.config.solver.termination;
import static ai.timefold.solver.core.config.solver.termination.TerminationConfig.requireNonNegative;
import java.time.Duration;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import ai.timefold.solver.core.config.AbstractConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import ai.timefold.solver.core.impl.io.jaxb.adapter.JaxbDurationAdapter;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"slidingWindowDuration",
"slidingWindowMilliseconds",
"slidingWindowSeconds",
"slidingWindowMinutes",
"slidingWindowHours",
"slidingWindowDays",
"minimumImprovementRatio"
})
public class DiminishedReturnsTerminationConfig extends AbstractConfig<DiminishedReturnsTerminationConfig> {
@XmlJavaTypeAdapter(JaxbDurationAdapter.class)
private Duration slidingWindowDuration = null;
private Long slidingWindowMilliseconds = null;
private Long slidingWindowSeconds = null;
private Long slidingWindowMinutes = null;
private Long slidingWindowHours = null;
private Long slidingWindowDays = null;
private Double minimumImprovementRatio = null;
public @Nullable Duration getSlidingWindowDuration() {
return slidingWindowDuration;
}
public void setSlidingWindowDuration(@Nullable Duration slidingWindowDuration) {
this.slidingWindowDuration = slidingWindowDuration;
}
public @Nullable Long getSlidingWindowMilliseconds() {
return slidingWindowMilliseconds;
}
public void setSlidingWindowMilliseconds(@Nullable Long slidingWindowMilliseconds) {
this.slidingWindowMilliseconds = slidingWindowMilliseconds;
}
public @Nullable Long getSlidingWindowSeconds() {
return slidingWindowSeconds;
}
public void setSlidingWindowSeconds(@Nullable Long slidingWindowSeconds) {
this.slidingWindowSeconds = slidingWindowSeconds;
}
public @Nullable Long getSlidingWindowMinutes() {
return slidingWindowMinutes;
}
public void setSlidingWindowMinutes(@Nullable Long slidingWindowMinutes) {
this.slidingWindowMinutes = slidingWindowMinutes;
}
public @Nullable Long getSlidingWindowHours() {
return slidingWindowHours;
}
public void setSlidingWindowHours(@Nullable Long slidingWindowHours) {
this.slidingWindowHours = slidingWindowHours;
}
public @Nullable Long getSlidingWindowDays() {
return slidingWindowDays;
}
public void setSlidingWindowDays(@Nullable Long slidingWindowDays) {
this.slidingWindowDays = slidingWindowDays;
}
public @Nullable Double getMinimumImprovementRatio() {
return minimumImprovementRatio;
}
public void setMinimumImprovementRatio(@Nullable Double minimumImprovementRatio) {
this.minimumImprovementRatio = minimumImprovementRatio;
}
// ************************************************************************
// With methods
// ************************************************************************
@NonNull
public DiminishedReturnsTerminationConfig withSlidingWindowDuration(@NonNull Duration slidingWindowDuration) {
this.slidingWindowDuration = slidingWindowDuration;
return this;
}
@NonNull
public DiminishedReturnsTerminationConfig withSlidingWindowMilliseconds(@NonNull Long slidingWindowMilliseconds) {
this.slidingWindowMilliseconds = slidingWindowMilliseconds;
return this;
}
@NonNull
public DiminishedReturnsTerminationConfig withSlidingWindowSeconds(@NonNull Long slidingWindowSeconds) {
this.slidingWindowSeconds = slidingWindowSeconds;
return this;
}
@NonNull
public DiminishedReturnsTerminationConfig withSlidingWindowMinutes(@NonNull Long slidingWindowMinutes) {
this.slidingWindowMinutes = slidingWindowMinutes;
return this;
}
@NonNull
public DiminishedReturnsTerminationConfig withSlidingWindowHours(@NonNull Long slidingWindowHours) {
this.slidingWindowHours = slidingWindowHours;
return this;
}
@NonNull
public DiminishedReturnsTerminationConfig withSlidingWindowDays(@NonNull Long slidingWindowDays) {
this.slidingWindowDays = slidingWindowDays;
return this;
}
@NonNull
public DiminishedReturnsTerminationConfig withMinimumImprovementRatio(@NonNull Double minimumImprovementRatio) {
this.minimumImprovementRatio = minimumImprovementRatio;
return this;
}
// Complex methods
@Override
public @NonNull DiminishedReturnsTerminationConfig inherit(@NonNull DiminishedReturnsTerminationConfig inheritedConfig) {
if (!slidingWindowIsSet()) {
inheritSlidingWindow(inheritedConfig);
}
minimumImprovementRatio = ConfigUtils.inheritOverwritableProperty(minimumImprovementRatio,
inheritedConfig.getMinimumImprovementRatio());
return this;
}
private void inheritSlidingWindow(@NonNull DiminishedReturnsTerminationConfig parent) {
slidingWindowDuration =
ConfigUtils.inheritOverwritableProperty(slidingWindowDuration, parent.getSlidingWindowDuration());
slidingWindowMilliseconds = ConfigUtils.inheritOverwritableProperty(slidingWindowMilliseconds,
parent.getSlidingWindowMilliseconds());
slidingWindowSeconds = ConfigUtils.inheritOverwritableProperty(slidingWindowSeconds, parent.getSlidingWindowSeconds());
slidingWindowMinutes = ConfigUtils.inheritOverwritableProperty(slidingWindowMinutes, parent.getSlidingWindowMinutes());
slidingWindowHours = ConfigUtils.inheritOverwritableProperty(slidingWindowHours, parent.getSlidingWindowHours());
slidingWindowDays = ConfigUtils.inheritOverwritableProperty(slidingWindowDays, parent.getSlidingWindowDays());
}
@Override
public @NonNull DiminishedReturnsTerminationConfig copyConfig() {
return new DiminishedReturnsTerminationConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
// intentionally empty - no classes to visit
}
/** Check whether any slidingWindow... is non-null. */
public boolean slidingWindowIsSet() {
return slidingWindowDuration != null
|| slidingWindowMilliseconds != null
|| slidingWindowSeconds != null
|| slidingWindowMinutes != null
|| slidingWindowHours != null
|| slidingWindowDays != null;
}
public @Nullable Long calculateSlidingWindowMilliseconds() {
if (slidingWindowMilliseconds == null && slidingWindowSeconds == null
&& slidingWindowMinutes == null && slidingWindowHours == null
&& slidingWindowDays == null) {
if (slidingWindowDuration != null) {
if (slidingWindowDuration.getNano() % 1000 != 0) {
throw new IllegalArgumentException("The termination slidingWindowDuration (" + slidingWindowDuration
+ ") cannot use nanoseconds.");
}
return slidingWindowDuration.toMillis();
}
return null;
}
if (slidingWindowDuration != null) {
throw new IllegalArgumentException("The termination slidingWindowDuration (" + slidingWindowDuration
+ ") cannot be combined with slidingWindowMilliseconds (" + slidingWindowMilliseconds
+ "), slidingWindowSeconds (" + slidingWindowSeconds
+ "), slidingWindowMinutes (" + slidingWindowMinutes
+ "), slidingWindowHours (" + slidingWindowHours + "),"
+ ") or slidingWindowDays (" + slidingWindowDays + ").");
}
long slidingWindowMillis = 0L
+ requireNonNegative(slidingWindowMilliseconds, "slidingWindowMilliseconds")
+ requireNonNegative(slidingWindowSeconds, "slidingWindowSeconds") * 1000L
+ requireNonNegative(slidingWindowMinutes, "slidingWindowMinutes") * 60_000L
+ requireNonNegative(slidingWindowHours, "slidingWindowHours") * 3_600_000L
+ requireNonNegative(slidingWindowDays, "slidingWindowDays") * 86_400_000L;
return slidingWindowMillis;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/termination/TerminationCompositionStyle.java | package ai.timefold.solver.core.config.solver.termination;
import jakarta.xml.bind.annotation.XmlEnum;
@XmlEnum
public enum TerminationCompositionStyle {
AND,
OR;
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/termination/TerminationConfig.java | package ai.timefold.solver.core.config.solver.termination;
import java.time.Duration;
import java.util.List;
import java.util.function.Consumer;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlTransient;
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import ai.timefold.solver.core.config.AbstractConfig;
import ai.timefold.solver.core.config.util.ConfigUtils;
import ai.timefold.solver.core.impl.io.jaxb.adapter.JaxbDurationAdapter;
import ai.timefold.solver.core.impl.solver.termination.Termination;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@XmlType(propOrder = {
"terminationClass",
"terminationCompositionStyle",
"diminishedReturnsConfig",
"spentLimit",
"millisecondsSpentLimit",
"secondsSpentLimit",
"minutesSpentLimit",
"hoursSpentLimit",
"daysSpentLimit",
"unimprovedSpentLimit",
"unimprovedMillisecondsSpentLimit",
"unimprovedSecondsSpentLimit",
"unimprovedMinutesSpentLimit",
"unimprovedHoursSpentLimit",
"unimprovedDaysSpentLimit",
"unimprovedScoreDifferenceThreshold",
"bestScoreLimit",
"bestScoreFeasible",
"stepCountLimit",
"unimprovedStepCountLimit",
"scoreCalculationCountLimit",
"moveCountLimit",
"terminationConfigList"
})
public class TerminationConfig extends AbstractConfig<TerminationConfig> {
/**
* @deprecated A custom terminationClass is deprecated and will be removed in a future major version of Timefold.
*/
@Deprecated(forRemoval = true)
private Class<? extends Termination> terminationClass = null;
private TerminationCompositionStyle terminationCompositionStyle = null;
@XmlElement(name = "diminishedReturns")
private DiminishedReturnsTerminationConfig diminishedReturnsConfig = null;
@XmlJavaTypeAdapter(JaxbDurationAdapter.class)
private Duration spentLimit = null;
private Long millisecondsSpentLimit = null;
private Long secondsSpentLimit = null;
private Long minutesSpentLimit = null;
private Long hoursSpentLimit = null;
private Long daysSpentLimit = null;
@XmlJavaTypeAdapter(JaxbDurationAdapter.class)
private Duration unimprovedSpentLimit = null;
private Long unimprovedMillisecondsSpentLimit = null;
private Long unimprovedSecondsSpentLimit = null;
private Long unimprovedMinutesSpentLimit = null;
private Long unimprovedHoursSpentLimit = null;
private Long unimprovedDaysSpentLimit = null;
private String unimprovedScoreDifferenceThreshold = null;
private String bestScoreLimit = null;
private Boolean bestScoreFeasible = null;
private Integer stepCountLimit = null;
private Integer unimprovedStepCountLimit = null;
private Long scoreCalculationCountLimit = null;
private Long moveCountLimit = null;
@XmlElement(name = "termination")
private List<TerminationConfig> terminationConfigList = null;
/**
* @deprecated A custom terminationClass is deprecated and will be removed in a future major version of Timefold.
*/
@Deprecated(forRemoval = true)
public Class<? extends Termination> getTerminationClass() {
return terminationClass;
}
/**
* @deprecated A custom terminationClass is deprecated and will be removed in a future major version of Timefold.
*/
@Deprecated(forRemoval = true)
public void setTerminationClass(Class<? extends Termination> terminationClass) {
this.terminationClass = terminationClass;
}
public @Nullable TerminationCompositionStyle getTerminationCompositionStyle() {
return terminationCompositionStyle;
}
public void setTerminationCompositionStyle(@Nullable TerminationCompositionStyle terminationCompositionStyle) {
this.terminationCompositionStyle = terminationCompositionStyle;
}
public @Nullable DiminishedReturnsTerminationConfig getDiminishedReturnsConfig() {
return diminishedReturnsConfig;
}
public void setDiminishedReturnsConfig(
@Nullable DiminishedReturnsTerminationConfig diminishedReturnsConfig) {
this.diminishedReturnsConfig = diminishedReturnsConfig;
}
public @Nullable Duration getSpentLimit() {
return spentLimit;
}
public void setSpentLimit(@Nullable Duration spentLimit) {
this.spentLimit = spentLimit;
}
public @Nullable Long getMillisecondsSpentLimit() {
return millisecondsSpentLimit;
}
public void setMillisecondsSpentLimit(@Nullable Long millisecondsSpentLimit) {
this.millisecondsSpentLimit = millisecondsSpentLimit;
}
public @Nullable Long getSecondsSpentLimit() {
return secondsSpentLimit;
}
public void setSecondsSpentLimit(@Nullable Long secondsSpentLimit) {
this.secondsSpentLimit = secondsSpentLimit;
}
public @Nullable Long getMinutesSpentLimit() {
return minutesSpentLimit;
}
public void setMinutesSpentLimit(@Nullable Long minutesSpentLimit) {
this.minutesSpentLimit = minutesSpentLimit;
}
public @Nullable Long getHoursSpentLimit() {
return hoursSpentLimit;
}
public void setHoursSpentLimit(@Nullable Long hoursSpentLimit) {
this.hoursSpentLimit = hoursSpentLimit;
}
public @Nullable Long getDaysSpentLimit() {
return daysSpentLimit;
}
public void setDaysSpentLimit(@Nullable Long daysSpentLimit) {
this.daysSpentLimit = daysSpentLimit;
}
public @Nullable Duration getUnimprovedSpentLimit() {
return unimprovedSpentLimit;
}
public void setUnimprovedSpentLimit(@Nullable Duration unimprovedSpentLimit) {
this.unimprovedSpentLimit = unimprovedSpentLimit;
}
public @Nullable Long getUnimprovedMillisecondsSpentLimit() {
return unimprovedMillisecondsSpentLimit;
}
public void setUnimprovedMillisecondsSpentLimit(@Nullable Long unimprovedMillisecondsSpentLimit) {
this.unimprovedMillisecondsSpentLimit = unimprovedMillisecondsSpentLimit;
}
public @Nullable Long getUnimprovedSecondsSpentLimit() {
return unimprovedSecondsSpentLimit;
}
public void setUnimprovedSecondsSpentLimit(@Nullable Long unimprovedSecondsSpentLimit) {
this.unimprovedSecondsSpentLimit = unimprovedSecondsSpentLimit;
}
public @Nullable Long getUnimprovedMinutesSpentLimit() {
return unimprovedMinutesSpentLimit;
}
public void setUnimprovedMinutesSpentLimit(@Nullable Long unimprovedMinutesSpentLimit) {
this.unimprovedMinutesSpentLimit = unimprovedMinutesSpentLimit;
}
public @Nullable Long getUnimprovedHoursSpentLimit() {
return unimprovedHoursSpentLimit;
}
public void setUnimprovedHoursSpentLimit(@Nullable Long unimprovedHoursSpentLimit) {
this.unimprovedHoursSpentLimit = unimprovedHoursSpentLimit;
}
public @Nullable Long getUnimprovedDaysSpentLimit() {
return unimprovedDaysSpentLimit;
}
public void setUnimprovedDaysSpentLimit(@Nullable Long unimprovedDaysSpentLimit) {
this.unimprovedDaysSpentLimit = unimprovedDaysSpentLimit;
}
public @Nullable String getUnimprovedScoreDifferenceThreshold() {
return unimprovedScoreDifferenceThreshold;
}
public void setUnimprovedScoreDifferenceThreshold(@Nullable String unimprovedScoreDifferenceThreshold) {
this.unimprovedScoreDifferenceThreshold = unimprovedScoreDifferenceThreshold;
}
public @Nullable String getBestScoreLimit() {
return bestScoreLimit;
}
public void setBestScoreLimit(@Nullable String bestScoreLimit) {
this.bestScoreLimit = bestScoreLimit;
}
public @Nullable Boolean getBestScoreFeasible() {
return bestScoreFeasible;
}
public void setBestScoreFeasible(@Nullable Boolean bestScoreFeasible) {
this.bestScoreFeasible = bestScoreFeasible;
}
public @Nullable Integer getStepCountLimit() {
return stepCountLimit;
}
public void setStepCountLimit(@Nullable Integer stepCountLimit) {
this.stepCountLimit = stepCountLimit;
}
public @Nullable Integer getUnimprovedStepCountLimit() {
return unimprovedStepCountLimit;
}
public void setUnimprovedStepCountLimit(@Nullable Integer unimprovedStepCountLimit) {
this.unimprovedStepCountLimit = unimprovedStepCountLimit;
}
public @Nullable Long getScoreCalculationCountLimit() {
return scoreCalculationCountLimit;
}
public void setScoreCalculationCountLimit(@Nullable Long scoreCalculationCountLimit) {
this.scoreCalculationCountLimit = scoreCalculationCountLimit;
}
public @Nullable Long getMoveCountLimit() {
return moveCountLimit;
}
public void setMoveCountLimit(@Nullable Long moveCountLimit) {
this.moveCountLimit = moveCountLimit;
}
public @Nullable List<@NonNull TerminationConfig> getTerminationConfigList() {
return terminationConfigList;
}
public void setTerminationConfigList(@Nullable List<@NonNull TerminationConfig> terminationConfigList) {
this.terminationConfigList = terminationConfigList;
}
// ************************************************************************
// With methods
// ************************************************************************
/**
* @deprecated A custom terminationClass is deprecated and will be removed in a future major version of Timefold.
*/
@Deprecated(forRemoval = true)
public TerminationConfig withTerminationClass(Class<? extends Termination> terminationClass) {
this.terminationClass = terminationClass;
return this;
}
public @NonNull TerminationConfig
withTerminationCompositionStyle(@NonNull TerminationCompositionStyle terminationCompositionStyle) {
this.terminationCompositionStyle = terminationCompositionStyle;
return this;
}
public @NonNull TerminationConfig withDiminishedReturns() {
return withDiminishedReturnsConfig(new DiminishedReturnsTerminationConfig());
}
public @NonNull TerminationConfig
withDiminishedReturnsConfig(@NonNull DiminishedReturnsTerminationConfig diminishedReturnsConfig) {
this.diminishedReturnsConfig = diminishedReturnsConfig;
return this;
}
public @NonNull TerminationConfig withSpentLimit(@NonNull Duration spentLimit) {
this.spentLimit = spentLimit;
return this;
}
public @NonNull TerminationConfig withMillisecondsSpentLimit(@NonNull Long millisecondsSpentLimit) {
this.millisecondsSpentLimit = millisecondsSpentLimit;
return this;
}
public @NonNull TerminationConfig withSecondsSpentLimit(@NonNull Long secondsSpentLimit) {
this.secondsSpentLimit = secondsSpentLimit;
return this;
}
public @NonNull TerminationConfig withMinutesSpentLimit(@NonNull Long minutesSpentLimit) {
this.minutesSpentLimit = minutesSpentLimit;
return this;
}
public @NonNull TerminationConfig withHoursSpentLimit(@NonNull Long hoursSpentLimit) {
this.hoursSpentLimit = hoursSpentLimit;
return this;
}
public @NonNull TerminationConfig withDaysSpentLimit(@NonNull Long daysSpentLimit) {
this.daysSpentLimit = daysSpentLimit;
return this;
}
public @NonNull TerminationConfig withUnimprovedSpentLimit(@NonNull Duration unimprovedSpentLimit) {
this.unimprovedSpentLimit = unimprovedSpentLimit;
return this;
}
public @NonNull TerminationConfig withUnimprovedMillisecondsSpentLimit(@NonNull Long unimprovedMillisecondsSpentLimit) {
this.unimprovedMillisecondsSpentLimit = unimprovedMillisecondsSpentLimit;
return this;
}
public @NonNull TerminationConfig withUnimprovedSecondsSpentLimit(@NonNull Long unimprovedSecondsSpentLimit) {
this.unimprovedSecondsSpentLimit = unimprovedSecondsSpentLimit;
return this;
}
public @NonNull TerminationConfig withUnimprovedMinutesSpentLimit(@NonNull Long unimprovedMinutesSpentLimit) {
this.unimprovedMinutesSpentLimit = unimprovedMinutesSpentLimit;
return this;
}
public @NonNull TerminationConfig withUnimprovedHoursSpentLimit(@NonNull Long unimprovedHoursSpentLimit) {
this.unimprovedHoursSpentLimit = unimprovedHoursSpentLimit;
return this;
}
public @NonNull TerminationConfig withUnimprovedDaysSpentLimit(@NonNull Long unimprovedDaysSpentLimit) {
this.unimprovedDaysSpentLimit = unimprovedDaysSpentLimit;
return this;
}
public @NonNull TerminationConfig
withUnimprovedScoreDifferenceThreshold(@NonNull String unimprovedScoreDifferenceThreshold) {
this.unimprovedScoreDifferenceThreshold = unimprovedScoreDifferenceThreshold;
return this;
}
public @NonNull TerminationConfig withBestScoreLimit(@NonNull String bestScoreLimit) {
this.bestScoreLimit = bestScoreLimit;
return this;
}
public @NonNull TerminationConfig withBestScoreFeasible(@NonNull Boolean bestScoreFeasible) {
this.bestScoreFeasible = bestScoreFeasible;
return this;
}
public @NonNull TerminationConfig withStepCountLimit(@NonNull Integer stepCountLimit) {
this.stepCountLimit = stepCountLimit;
return this;
}
public @NonNull TerminationConfig withUnimprovedStepCountLimit(@NonNull Integer unimprovedStepCountLimit) {
this.unimprovedStepCountLimit = unimprovedStepCountLimit;
return this;
}
public @NonNull TerminationConfig withScoreCalculationCountLimit(@NonNull Long scoreCalculationCountLimit) {
this.scoreCalculationCountLimit = scoreCalculationCountLimit;
return this;
}
public @NonNull TerminationConfig withMoveCountLimit(@NonNull Long moveCountLimit) {
this.moveCountLimit = moveCountLimit;
return this;
}
public @NonNull TerminationConfig
withTerminationConfigList(@NonNull List<@NonNull TerminationConfig> terminationConfigList) {
this.terminationConfigList = terminationConfigList;
return this;
}
public void overwriteSpentLimit(@Nullable Duration spentLimit) {
setSpentLimit(spentLimit);
setMillisecondsSpentLimit(null);
setSecondsSpentLimit(null);
setMinutesSpentLimit(null);
setHoursSpentLimit(null);
setDaysSpentLimit(null);
}
public @Nullable Long calculateTimeMillisSpentLimit() {
if (millisecondsSpentLimit == null && secondsSpentLimit == null
&& minutesSpentLimit == null && hoursSpentLimit == null && daysSpentLimit == null) {
if (spentLimit != null) {
if (spentLimit.getNano() % 1000 != 0) {
throw new IllegalArgumentException("The termination spentLimit (" + spentLimit
+ ") cannot use nanoseconds.");
}
return spentLimit.toMillis();
}
return null;
}
if (spentLimit != null) {
throw new IllegalArgumentException("The termination spentLimit (" + spentLimit
+ ") cannot be combined with millisecondsSpentLimit (" + millisecondsSpentLimit
+ "), secondsSpentLimit (" + secondsSpentLimit
+ "), minutesSpentLimit (" + minutesSpentLimit
+ "), hoursSpentLimit (" + hoursSpentLimit
+ ") or daysSpentLimit (" + daysSpentLimit + ").");
}
long timeMillisSpentLimit = 0L
+ requireNonNegative(millisecondsSpentLimit, "millisecondsSpentLimit")
+ requireNonNegative(secondsSpentLimit, "secondsSpentLimit") * 1_000L
+ requireNonNegative(minutesSpentLimit, "minutesSpentLimit") * 60_000L
+ requireNonNegative(hoursSpentLimit, "hoursSpentLimit") * 3_600_000L
+ requireNonNegative(daysSpentLimit, "daysSpentLimit") * 86_400_000L;
return timeMillisSpentLimit;
}
public void shortenTimeMillisSpentLimit(long timeMillisSpentLimit) {
Long oldLimit = calculateTimeMillisSpentLimit();
if (oldLimit == null || timeMillisSpentLimit < oldLimit) {
spentLimit = null;
millisecondsSpentLimit = timeMillisSpentLimit;
secondsSpentLimit = null;
minutesSpentLimit = null;
hoursSpentLimit = null;
daysSpentLimit = null;
}
}
public void overwriteUnimprovedSpentLimit(@Nullable Duration unimprovedSpentLimit) {
setUnimprovedSpentLimit(unimprovedSpentLimit);
setUnimprovedMillisecondsSpentLimit(null);
setUnimprovedSecondsSpentLimit(null);
setUnimprovedMinutesSpentLimit(null);
setUnimprovedHoursSpentLimit(null);
setUnimprovedDaysSpentLimit(null);
}
public @Nullable Long calculateUnimprovedTimeMillisSpentLimit() {
if (unimprovedMillisecondsSpentLimit == null && unimprovedSecondsSpentLimit == null
&& unimprovedMinutesSpentLimit == null && unimprovedHoursSpentLimit == null
&& unimprovedDaysSpentLimit == null) {
if (unimprovedSpentLimit != null) {
if (unimprovedSpentLimit.getNano() % 1000 != 0) {
throw new IllegalArgumentException("The termination unimprovedSpentLimit (" + unimprovedSpentLimit
+ ") cannot use nanoseconds.");
}
return unimprovedSpentLimit.toMillis();
}
return null;
}
if (unimprovedSpentLimit != null) {
throw new IllegalArgumentException("The termination unimprovedSpentLimit (" + unimprovedSpentLimit
+ ") cannot be combined with unimprovedMillisecondsSpentLimit (" + unimprovedMillisecondsSpentLimit
+ "), unimprovedSecondsSpentLimit (" + unimprovedSecondsSpentLimit
+ "), unimprovedMinutesSpentLimit (" + unimprovedMinutesSpentLimit
+ "), unimprovedHoursSpentLimit (" + unimprovedHoursSpentLimit + "),"
+ ") or unimprovedDaysSpentLimit (" + unimprovedDaysSpentLimit + ").");
}
long unimprovedTimeMillisSpentLimit = 0L
+ requireNonNegative(unimprovedMillisecondsSpentLimit, "unimprovedMillisecondsSpentLimit")
+ requireNonNegative(unimprovedSecondsSpentLimit, "unimprovedSecondsSpentLimit") * 1000L
+ requireNonNegative(unimprovedMinutesSpentLimit, "unimprovedMinutesSpentLimit") * 60_000L
+ requireNonNegative(unimprovedHoursSpentLimit, "unimprovedHoursSpentLimit") * 3_600_000L
+ requireNonNegative(unimprovedDaysSpentLimit, "unimprovedDaysSpentLimit") * 86_400_000L;
return unimprovedTimeMillisSpentLimit;
}
/**
* Return true if this TerminationConfig configures a termination condition.
* Note: this does not mean it will always terminate: ex: bestScoreLimit configured,
* but it is impossible to reach the bestScoreLimit.
*/
@XmlTransient
public boolean isConfigured() {
return terminationClass != null ||
timeSpentLimitIsSet() ||
unimprovedTimeSpentLimitIsSet() ||
diminishedReturnsConfig != null ||
bestScoreLimit != null ||
bestScoreFeasible != null ||
stepCountLimit != null ||
unimprovedStepCountLimit != null ||
scoreCalculationCountLimit != null ||
moveCountLimit != null ||
isTerminationListConfigured();
}
private boolean isTerminationListConfigured() {
if (terminationConfigList == null || terminationCompositionStyle == null) {
return false;
}
return switch (terminationCompositionStyle) {
case AND -> terminationConfigList.stream().allMatch(TerminationConfig::isConfigured);
case OR -> terminationConfigList.stream().anyMatch(TerminationConfig::isConfigured);
};
}
@Override
public @NonNull TerminationConfig inherit(@NonNull TerminationConfig inheritedConfig) {
if (!timeSpentLimitIsSet()) {
inheritTimeSpentLimit(inheritedConfig);
}
if (!unimprovedTimeSpentLimitIsSet()) {
inheritUnimprovedTimeSpentLimit(inheritedConfig);
}
diminishedReturnsConfig = ConfigUtils.inheritConfig(diminishedReturnsConfig,
inheritedConfig.getDiminishedReturnsConfig());
terminationClass = ConfigUtils.inheritOverwritableProperty(terminationClass,
inheritedConfig.getTerminationClass());
terminationCompositionStyle = ConfigUtils.inheritOverwritableProperty(terminationCompositionStyle,
inheritedConfig.getTerminationCompositionStyle());
unimprovedScoreDifferenceThreshold = ConfigUtils.inheritOverwritableProperty(unimprovedScoreDifferenceThreshold,
inheritedConfig.getUnimprovedScoreDifferenceThreshold());
bestScoreLimit = ConfigUtils.inheritOverwritableProperty(bestScoreLimit,
inheritedConfig.getBestScoreLimit());
bestScoreFeasible = ConfigUtils.inheritOverwritableProperty(bestScoreFeasible,
inheritedConfig.getBestScoreFeasible());
stepCountLimit = ConfigUtils.inheritOverwritableProperty(stepCountLimit,
inheritedConfig.getStepCountLimit());
unimprovedStepCountLimit = ConfigUtils.inheritOverwritableProperty(unimprovedStepCountLimit,
inheritedConfig.getUnimprovedStepCountLimit());
scoreCalculationCountLimit = ConfigUtils.inheritOverwritableProperty(scoreCalculationCountLimit,
inheritedConfig.getScoreCalculationCountLimit());
moveCountLimit = ConfigUtils.inheritOverwritableProperty(moveCountLimit,
inheritedConfig.getMoveCountLimit());
terminationConfigList = ConfigUtils.inheritMergeableListConfig(
terminationConfigList, inheritedConfig.getTerminationConfigList());
return this;
}
@Override
public @NonNull TerminationConfig copyConfig() {
return new TerminationConfig().inherit(this);
}
@Override
public void visitReferencedClasses(@NonNull Consumer<Class<?>> classVisitor) {
classVisitor.accept(terminationClass);
if (terminationConfigList != null) {
terminationConfigList.forEach(tc -> tc.visitReferencedClasses(classVisitor));
}
if (diminishedReturnsConfig != null) {
diminishedReturnsConfig.visitReferencedClasses(classVisitor);
}
}
private TerminationConfig inheritTimeSpentLimit(TerminationConfig parent) {
spentLimit = ConfigUtils.inheritOverwritableProperty(spentLimit,
parent.getSpentLimit());
millisecondsSpentLimit = ConfigUtils.inheritOverwritableProperty(millisecondsSpentLimit,
parent.getMillisecondsSpentLimit());
secondsSpentLimit = ConfigUtils.inheritOverwritableProperty(secondsSpentLimit,
parent.getSecondsSpentLimit());
minutesSpentLimit = ConfigUtils.inheritOverwritableProperty(minutesSpentLimit,
parent.getMinutesSpentLimit());
hoursSpentLimit = ConfigUtils.inheritOverwritableProperty(hoursSpentLimit,
parent.getHoursSpentLimit());
daysSpentLimit = ConfigUtils.inheritOverwritableProperty(daysSpentLimit,
parent.getDaysSpentLimit());
return this;
}
private TerminationConfig inheritUnimprovedTimeSpentLimit(TerminationConfig parent) {
unimprovedSpentLimit = ConfigUtils.inheritOverwritableProperty(unimprovedSpentLimit,
parent.getUnimprovedSpentLimit());
unimprovedMillisecondsSpentLimit = ConfigUtils.inheritOverwritableProperty(unimprovedMillisecondsSpentLimit,
parent.getUnimprovedMillisecondsSpentLimit());
unimprovedSecondsSpentLimit = ConfigUtils.inheritOverwritableProperty(unimprovedSecondsSpentLimit,
parent.getUnimprovedSecondsSpentLimit());
unimprovedMinutesSpentLimit = ConfigUtils.inheritOverwritableProperty(unimprovedMinutesSpentLimit,
parent.getUnimprovedMinutesSpentLimit());
unimprovedHoursSpentLimit = ConfigUtils.inheritOverwritableProperty(unimprovedHoursSpentLimit,
parent.getUnimprovedHoursSpentLimit());
unimprovedDaysSpentLimit = ConfigUtils.inheritOverwritableProperty(unimprovedDaysSpentLimit,
parent.getUnimprovedDaysSpentLimit());
return this;
}
/**
* Assert that the parameter is non-negative and return its value,
* converting {@code null} to 0.
*
* @param param the parameter to test/convert
* @param name the name of the parameter, for use in the exception message
* @throws IllegalArgumentException iff param is negative
*/
static Long requireNonNegative(Long param, String name) {
if (param == null) {
return 0L; // Makes adding a null param a NOP.
} else if (param < 0L) {
String msg = String.format("The termination %s (%d) cannot be negative.", name, param);
throw new IllegalArgumentException(msg);
} else {
return param;
}
}
/** Check whether any ...SpentLimit is non-null. */
private boolean timeSpentLimitIsSet() {
return getDaysSpentLimit() != null
|| getHoursSpentLimit() != null
|| getMinutesSpentLimit() != null
|| getSecondsSpentLimit() != null
|| getMillisecondsSpentLimit() != null
|| getSpentLimit() != null;
}
/** Check whether any unimproved...SpentLimit is non-null. */
private boolean unimprovedTimeSpentLimitIsSet() {
return getUnimprovedDaysSpentLimit() != null
|| getUnimprovedHoursSpentLimit() != null
|| getUnimprovedMinutesSpentLimit() != null
|| getUnimprovedSecondsSpentLimit() != null
|| getUnimprovedMillisecondsSpentLimit() != null
|| getUnimprovedSpentLimit() != null;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/solver/termination/package-info.java | @XmlSchema(
namespace = SolverConfig.XML_NAMESPACE,
elementFormDefault = XmlNsForm.QUALIFIED)
package ai.timefold.solver.core.config.solver.termination;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
import ai.timefold.solver.core.config.solver.SolverConfig;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/config/util/ConfigUtils.java | package ai.timefold.solver.core.config.util;
import static ai.timefold.solver.core.impl.domain.common.accessor.MemberAccessorFactory.MemberAccessorType.FIELD_OR_READ_METHOD;
import static ai.timefold.solver.core.impl.domain.solution.cloner.DeepCloningUtils.IMMUTABLE_CLASSES;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.WildcardType;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import ai.timefold.solver.core.api.domain.common.DomainAccessType;
import ai.timefold.solver.core.api.domain.lookup.PlanningId;
import ai.timefold.solver.core.config.AbstractConfig;
import ai.timefold.solver.core.impl.domain.common.AlphabeticMemberComparator;
import ai.timefold.solver.core.impl.domain.common.ReflectionHelper;
import ai.timefold.solver.core.impl.domain.common.accessor.MemberAccessor;
import ai.timefold.solver.core.impl.domain.common.accessor.MemberAccessorFactory;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
public class ConfigUtils {
private static final AlphabeticMemberComparator alphabeticMemberComparator = new AlphabeticMemberComparator();
/**
* Create a new instance of clazz from a config's property.
* <p>
* If the instantiation fails, the simple class name of {@code configBean} will be used as the owner of
* {@code propertyName}.
* <p>
* Intended usage:
*
* <pre>
* selectionFilter = ConfigUtils.newInstance(config, "filterClass", config.getFilterClass());
* </pre>
*
* @param configBean the bean holding the {@code clazz} to be instantiated
* @param propertyName {@code configBean}'s property holding {@code clazz}
* @param clazz {@code Class} representation of the type {@code T}
* @param <T> the new instance type
* @return new instance of clazz
*/
public static <T> @NonNull T newInstance(@Nullable Object configBean, @NonNull String propertyName,
@NonNull Class<T> clazz) {
return newInstance(() -> (configBean == null ? "?" : configBean.getClass().getSimpleName()), propertyName, clazz);
}
/**
* Create a new instance of clazz from a general source.
* <p>
* If the instantiation fails, the result of {@code ownerDescriptor} will be used to describe the owner of
* {@code propertyName}.
*
* @param ownerDescriptor describes the owner of {@code propertyName}
* @param propertyName property holding the {@code clazz}
* @param clazz {@code Class} representation of the type {@code T}
* @param <T> the new instance type
* @return new instance of clazz
*/
public static <T> @NonNull T newInstance(@NonNull Supplier<String> ownerDescriptor, @NonNull String propertyName,
@NonNull Class<T> clazz) {
try {
return clazz.getDeclaredConstructor().newInstance();
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
// Inner classes include local, anonymous and non-static member classes
throw new IllegalArgumentException("The %s's %s (%s) does not have a public no-arg constructor%s"
.formatted(ownerDescriptor.get(), propertyName, clazz.getName(),
((clazz.isLocalClass() || clazz.isAnonymousClass() || clazz.isMemberClass())
&& !Modifier.isStatic(clazz.getModifiers()) ? " because it is an inner class." : ".")),
e);
}
}
public static void applyCustomProperties(@NonNull Object bean, @NonNull String beanClassPropertyName,
@Nullable Map<@NonNull String, @NonNull String> customProperties, @NonNull String customPropertiesPropertyName) {
if (customProperties == null) {
return;
}
var beanClass = bean.getClass();
customProperties.forEach((propertyName, valueString) -> {
var setterMethod = ReflectionHelper.getSetterMethod(beanClass, propertyName);
if (setterMethod == null) {
throw new IllegalStateException(
"""
The custom property %s (%s) in the %s cannot be set on the %s (%s) because that class has no public setter for that property.
Maybe add a public setter for that custom property (%s) on that class (%s).
Maybe don't configure that custom property %s (%s) in the %s."""
.formatted(propertyName, valueString, customPropertiesPropertyName, beanClassPropertyName,
beanClass, propertyName, beanClass.getSimpleName(), propertyName, valueString,
customPropertiesPropertyName));
}
var propertyType = setterMethod.getParameterTypes()[0];
Object typedValue;
try {
if (propertyType.equals(String.class)) {
typedValue = valueString;
} else if (propertyType.equals(Boolean.TYPE) || propertyType.equals(Boolean.class)) {
typedValue = Boolean.parseBoolean(valueString);
} else if (propertyType.equals(Integer.TYPE) || propertyType.equals(Integer.class)) {
typedValue = Integer.parseInt(valueString);
} else if (propertyType.equals(Long.TYPE) || propertyType.equals(Long.class)) {
typedValue = Long.parseLong(valueString);
} else if (propertyType.equals(Float.TYPE) || propertyType.equals(Float.class)) {
typedValue = Float.parseFloat(valueString);
} else if (propertyType.equals(Double.TYPE) || propertyType.equals(Double.class)) {
typedValue = Double.parseDouble(valueString);
} else if (propertyType.equals(BigDecimal.class)) {
typedValue = new BigDecimal(valueString);
} else if (propertyType.isEnum()) {
typedValue = Enum.valueOf((Class<? extends Enum>) propertyType, valueString);
} else {
throw new IllegalStateException(
"The custom property %s (%s) in the %s has an unsupported propertyType (%s) for value (%s)."
.formatted(propertyName, valueString, customPropertiesPropertyName, propertyType,
valueString));
}
} catch (NumberFormatException e) {
throw new IllegalStateException(
"The custom property %s (%s) in the %s cannot be parsed to the propertyType (%s) of the setterMethod (%s)."
.formatted(propertyName, valueString, customPropertiesPropertyName, propertyType,
setterMethod));
}
try {
setterMethod.invoke(bean, typedValue);
} catch (IllegalAccessException e) {
throw new IllegalStateException(
"The custom property %s (%s) in the %s has a setterMethod (%s) on the beanClass (%s) that cannot be called for the typedValue (%s)."
.formatted(propertyName, valueString, customPropertiesPropertyName, setterMethod, beanClass,
typedValue),
e);
} catch (InvocationTargetException e) {
throw new IllegalStateException(
"The custom property %s (%s) in the %s has a setterMethod (%s) on the beanClass (%s) that throws an exception for the typedValue (%s)."
.formatted(propertyName, valueString, customPropertiesPropertyName, setterMethod, beanClass,
typedValue),
e.getCause());
}
});
}
public static <Config_ extends AbstractConfig<Config_>> @Nullable Config_ inheritConfig(@Nullable Config_ original,
@Nullable Config_ inherited) {
if (inherited != null) {
if (original == null) {
original = inherited.copyConfig();
} else {
original.inherit(inherited);
}
}
return original;
}
public static <Config_ extends AbstractConfig<Config_>> @Nullable List<Config_> inheritMergeableListConfig(
@Nullable List<Config_> originalList, @Nullable List<Config_> inheritedList) {
if (inheritedList != null) {
List<Config_> mergedList = new ArrayList<>(inheritedList.size()
+ (originalList == null ? 0 : originalList.size()));
// The inheritedList should be before the originalList
for (var inherited : inheritedList) {
var copy = inherited.copyConfig();
mergedList.add(copy);
}
if (originalList != null) {
mergedList.addAll(originalList);
}
originalList = mergedList;
}
return originalList;
}
public static <T> @Nullable T inheritOverwritableProperty(@Nullable T original, @Nullable T inherited) {
if (original != null) {
// Original overwrites inherited
return original;
} else {
return inherited;
}
}
public static <T> @Nullable List<T> inheritMergeableListProperty(@Nullable List<T> originalList,
@Nullable List<T> inheritedList) {
if (inheritedList == null) {
return originalList;
} else if (originalList == null) {
// Shallow clone due to modifications after calling inherit
return new ArrayList<>(inheritedList);
} else {
// The inheritedList should be before the originalList
List<T> mergedList = new ArrayList<>(inheritedList);
mergedList.addAll(originalList);
return mergedList;
}
}
public static <E extends Enum<E>> @Nullable Set<E> inheritMergeableEnumSetProperty(@Nullable Set<E> originalSet,
@Nullable Set<E> inheritedSet) {
if (inheritedSet == null) {
return originalSet;
} else if (originalSet == null) {
return EnumSet.copyOf(inheritedSet);
} else {
var newSet = EnumSet.copyOf(originalSet);
newSet.addAll(inheritedSet);
return newSet;
}
}
public static <T> @Nullable List<T> inheritUniqueMergeableListProperty(@Nullable List<T> originalList,
@Nullable List<T> inheritedList) {
if (inheritedList == null) {
return originalList;
} else if (originalList == null) {
// Shallow clone due to modifications after calling inherit
return new ArrayList<>(inheritedList);
} else {
// The inheritedMap should be before the originalMap
Set<T> mergedSet = new LinkedHashSet<>(inheritedList);
mergedSet.addAll(originalList);
return new ArrayList<>(mergedSet);
}
}
public static <K, T> @Nullable Map<K, T> inheritMergeableMapProperty(@Nullable Map<K, T> originalMap,
@Nullable Map<K, T> inheritedMap) {
if (inheritedMap == null) {
return originalMap;
} else if (originalMap == null) {
return inheritedMap;
} else {
Map<K, T> mergedMap = new LinkedHashMap<>(inheritedMap);
mergedMap.putAll(originalMap);
return mergedMap;
}
}
public static <T> @Nullable T mergeProperty(@Nullable T a, @Nullable T b) {
return Objects.equals(a, b) ? a : null;
}
/**
* A relaxed version of {@link #mergeProperty(Object, Object)}. Used primarily for merging failed benchmarks,
* where a property remains the same over benchmark runs (for example: dataset problem size), but the property in
* the failed benchmark isn't initialized, therefore null. When merging, we can still use the correctly initialized
* property of the benchmark that didn't fail.
* <p>
* Null-handling:
* <ul>
* <li>if <strong>both</strong> properties <strong>are null</strong>, returns null</li>
* <li>if <strong>only one</strong> of the properties <strong>is not null</strong>, returns that property</li>
* <li>if <strong>both</strong> properties <strong>are not null</strong>, returns
* {@link #mergeProperty(Object, Object)}</li>
* </ul>
*
* @see #mergeProperty(Object, Object)
* @param a property {@code a}
* @param b property {@code b}
* @param <T> the type of property {@code a} and {@code b}
* @return sometimes null
*/
public static <T> @Nullable T meldProperty(@Nullable T a, @Nullable T b) {
if (a == null && b == null) {
return null;
}
if (a == null) {
return b;
}
if (b == null) {
return a;
}
return mergeProperty(a, b);
}
public static boolean isEmptyCollection(@Nullable Collection<?> collection) {
return collection == null || collection.isEmpty();
}
/**
* Divides and ceils the result without using floating point arithmetic. For floor division,
* see {@link Math#floorDiv(long, long)}.
*
* @throws ArithmeticException if {@code divisor == 0}
* @param dividend the dividend
* @param divisor the divisor
* @return dividend / divisor, ceiled
*/
public static int ceilDivide(int dividend, int divisor) {
if (divisor == 0) {
throw new ArithmeticException("Cannot divide by zero: %d/%d".formatted(dividend, divisor));
}
int correction;
if (dividend % divisor == 0) {
correction = 0;
} else if (Integer.signum(dividend) * Integer.signum(divisor) < 0) {
correction = 0;
} else {
correction = 1;
}
return (dividend / divisor) + correction;
}
public static int resolvePoolSize(@NonNull String propertyName, @NonNull String value,
@NonNull String @NonNull... magicValues) {
try {
return Integer.parseInt(value);
} catch (NumberFormatException ex) {
throw new IllegalStateException("The %s (%s) resolved to neither of (%s) nor a number.".formatted(propertyName,
value, Arrays.toString(magicValues)));
}
}
// ************************************************************************
// Member and annotation methods
// ************************************************************************
public static @NonNull List<@NonNull Class<?>> getAllParents(@Nullable Class<?> bottomClass) {
if (bottomClass == null || bottomClass == Object.class) {
return Collections.emptyList();
}
var superclass = bottomClass.getSuperclass();
var lineageClassList = new ArrayList<>(getAllParents(superclass));
for (var superInterface : bottomClass.getInterfaces()) {
lineageClassList.addAll(getAllParents(superInterface));
}
lineageClassList.add(bottomClass);
return lineageClassList;
}
public static @NonNull List<@NonNull Class<?>> getAllAnnotatedLineageClasses(@Nullable Class<?> bottomClass,
@NonNull Class<? extends Annotation> annotation) {
if (bottomClass == null || !bottomClass.isAnnotationPresent(annotation)) {
return Collections.emptyList();
}
List<Class<?>> lineageClassList = new ArrayList<>();
lineageClassList.add(bottomClass);
var superclass = bottomClass.getSuperclass();
lineageClassList.addAll(getAllAnnotatedLineageClasses(superclass, annotation));
for (var superInterface : bottomClass.getInterfaces()) {
lineageClassList.addAll(getAllAnnotatedLineageClasses(superInterface, annotation));
}
return lineageClassList;
}
/**
* @return sorted by type (fields before methods), then by {@link AlphabeticMemberComparator}.
*/
public static @NonNull List<Member> getDeclaredMembers(@NonNull Class<?> baseClass) {
var fieldStream = Stream.of(baseClass.getDeclaredFields())
// A synthetic field is a field generated by the compiler that
// does not exist in the source code. It is used mainly in
// nested classes so the inner class can access the fields
// of the outer class.
.filter(field -> !field.isSynthetic())
.sorted(alphabeticMemberComparator);
var methodStream = Stream.of(baseClass.getDeclaredMethods())
// A synthetic method is a method generated by the compiler that does
// not exist in the source code. These include bridge methods.
// A bridge method is a generic variant that duplicates a concrete method
// Example: "Score getScore()" that duplicates "HardSoftScore getScore()"
.filter(method -> !method.isSynthetic())
.sorted(alphabeticMemberComparator);
return Stream.concat(fieldStream, methodStream)
.collect(Collectors.toList());
}
/**
* @return sorted by type (fields before methods), then by {@link AlphabeticMemberComparator}.
*/
public static @NonNull List<Member> getAllMembers(@NonNull Class<?> baseClass,
@NonNull Class<? extends Annotation> annotationClass) {
var clazz = baseClass;
Stream<Member> memberStream = Stream.empty();
while (clazz != null) {
var fieldStream = Stream.of(clazz.getDeclaredFields())
.filter(field -> field.isAnnotationPresent(annotationClass) && !field.isSynthetic());
// Implementations of an interface method do not inherit the annotations of the declared method in
// the interface, so we need to also add the interface's methods to the stream.
var methodStream = Stream.concat(
Stream.of(clazz.getDeclaredMethods()),
Arrays.stream(clazz.getInterfaces())
.flatMap(implementedInterface -> Arrays.stream(implementedInterface.getMethods())))
.filter(method -> method.isAnnotationPresent(annotationClass) && !method.isSynthetic());
memberStream = Stream.concat(memberStream, Stream.concat(fieldStream, methodStream));
clazz = clazz.getSuperclass();
}
return memberStream.distinct().sorted(alphabeticMemberComparator).collect(Collectors.toList());
}
@SafeVarargs
public static Class<? extends Annotation> extractAnnotationClass(@NonNull Member member,
@NonNull Class<? extends Annotation>... annotationClasses) {
var classList = extractAnnotationClasses(member, annotationClasses);
if (classList.isEmpty()) {
return null;
} else if (classList.size() > 1) {
throw new IllegalStateException(
"The class (%s) has a member (%s) that has both a @%s annotation and a @%s annotation.".formatted(
member.getDeclaringClass(), member, classList.get(0).getSimpleName(),
classList.get(1).getSimpleName()));
} else {
return classList.get(0);
}
}
@SafeVarargs
public static List<Class<? extends Annotation>> extractAnnotationClasses(@NonNull Member member,
@NonNull Class<? extends Annotation>... annotationClasses) {
var annotationClassList = new ArrayList<Class<? extends Annotation>>();
for (var detectedAnnotationClass : annotationClasses) {
if (((AnnotatedElement) member).isAnnotationPresent(detectedAnnotationClass)) {
annotationClassList.add(detectedAnnotationClass);
}
}
return annotationClassList;
}
public static Class<?> extractGenericTypeParameterOrFail(@NonNull String parentClassConcept, @NonNull Class<?> parentClass,
@NonNull Class<?> type, @NonNull Type genericType, @Nullable Class<? extends Annotation> annotationClass,
@NonNull String memberName) {
return extractGenericTypeParameter(parentClassConcept, parentClass, type, genericType, annotationClass, memberName)
.orElseThrow(() -> new IllegalArgumentException("""
The %s (%s) has a %s member (%s) with a member type (%s) which has no generic parameters.
Maybe the member (%s) should return a parameterized %s."""
.formatted(parentClassConcept, parentClass,
annotationClass == null ? "auto discovered"
: "@" + annotationClass.getSimpleName() + " annotated",
memberName, type, memberName, type.getSimpleName())));
}
/**
* @param type the class type
* @return true if it is immutable; otherwise false
*/
public static boolean isGenericTypeImmutable(Class<?> type) {
if (type == null) {
return false;
}
return type.isRecord() || IMMUTABLE_CLASSES.contains(type);
}
public static Optional<Class<?>> extractGenericTypeParameter(@NonNull String parentClassConcept,
@NonNull Class<?> parentClass, @NonNull Class<?> type, @NonNull Type genericType,
@Nullable Class<? extends Annotation> annotationClass, @NonNull String memberName) {
if (!(genericType instanceof ParameterizedType parameterizedType)) {
return Optional.empty();
}
var typeArguments = parameterizedType.getActualTypeArguments();
if (typeArguments.length != 1) {
throw new IllegalArgumentException("""
The %s (%s) has a %s member (%s) with a member type (%s) which is a parameterized collection \
with an unsupported number of generic parameters (%s)."""
.formatted(parentClassConcept, parentClass,
annotationClass == null ? "auto discovered" : "@" + annotationClass.getSimpleName() + " annotated",
memberName, type, typeArguments.length));
}
var typeArgument = typeArguments[0];
if (typeArgument instanceof ParameterizedType parameterizedTypeArgument) {
// Remove the type parameters, so it can be cast to a Class.
typeArgument = parameterizedTypeArgument.getRawType();
}
if (typeArgument instanceof WildcardType wildcardType) {
var upperBounds = wildcardType.getUpperBounds();
typeArgument = switch (upperBounds.length) {
case 0 -> Object.class;
case 1 -> upperBounds[0];
// Multiple upper bounds are impossible in traditional Java.
// Other JVM languages or future java versions might enable triggering this.
default -> throw new IllegalArgumentException("""
The %s (%s) has a %s member (%s) with a member type (%s) which is a parameterized collection \
with a wildcard type argument (%s) that has multiple upper bounds (%s).
Maybe don't use wildcards with multiple upper bounds for the member (%s)."""
.formatted(parentClassConcept, parentClass,
annotationClass == null ? "auto discovered"
: "@" + annotationClass.getSimpleName() + " annotated",
memberName, type, typeArgument, Arrays.toString(upperBounds), memberName));
};
}
if (typeArgument instanceof Class<?> class1) {
return Optional.of(class1);
} else if (typeArgument instanceof ParameterizedType parameterizedTypeArgument) {
// Turns SomeGenericType<T> into SomeGenericType.
return Optional.of((Class<?>) parameterizedTypeArgument.getRawType());
} else {
throw new IllegalArgumentException("""
The %s (%s) has a %s member (%s) with a member type (%s) which is a parameterized collection \
with a type argument (%s) that is not a class or interface."""
.formatted(parentClassConcept, parentClass,
annotationClass == null ? "auto discovered" : "@" + annotationClass.getSimpleName() + " annotated",
memberName, type, typeArgument));
}
}
/**
* This method is heavy, and it is effectively a computed constant.
* It is recommended that its results are cached at call sites.
*
* @return null if no accessor found
* @param <C> the class type
*/
public static <C> @Nullable MemberAccessor findPlanningIdMemberAccessor(@NonNull Class<C> clazz,
@NonNull MemberAccessorFactory memberAccessorFactory, @NonNull DomainAccessType domainAccessType) {
var member = getSingleMember(clazz, PlanningId.class);
if (member == null) {
return null;
}
var memberAccessor =
memberAccessorFactory.buildAndCacheMemberAccessor(member, FIELD_OR_READ_METHOD, PlanningId.class,
domainAccessType);
assertPlanningIdMemberIsComparable(clazz, member, memberAccessor);
return memberAccessor;
}
private static void assertPlanningIdMemberIsComparable(Class<?> clazz, Member member, MemberAccessor memberAccessor) {
if (!memberAccessor.getType().isPrimitive() && !Comparable.class.isAssignableFrom(memberAccessor.getType())) {
throw new IllegalArgumentException(
"""
The class (%s) has a member (%s) with a @%s annotation that returns a type (%s) that does not implement %s.
Maybe use a %s or %s type instead."""
.formatted(clazz, member, PlanningId.class.getSimpleName(), memberAccessor.getType(),
Comparable.class.getSimpleName(), Long.class.getSimpleName(),
String.class.getSimpleName()));
}
}
private static <C> Member getSingleMember(Class<C> clazz, Class<? extends Annotation> annotationClass) {
var memberList = getAllMembers(clazz, annotationClass);
if (memberList.isEmpty()) {
return null;
}
var size = memberList.size();
if (clazz.isRecord()) {
/*
* A record has a field and a getter for each record component.
* When the component is annotated with @PlanningId,
* the annotation ends up both on the field and on the getter.
*/
if (size == 2) { // The getter is used to retrieve the value of the record component.
var methodMembers = getMembers(memberList, true);
if (methodMembers.isEmpty()) {
throw new IllegalStateException("Impossible state: record (%s) doesn't have any method members (%s)."
.formatted(clazz.getCanonicalName(), memberList));
}
return methodMembers.get(0);
} else { // There is more than one component annotated with @PlanningId; take the fields and fail.
var componentList = getMembers(memberList, false)
.stream()
.map(Member::getName)
.toList();
throw new IllegalArgumentException("The record (%s) has %s components (%s) with %s annotation."
.formatted(clazz, componentList.size(), componentList, annotationClass.getSimpleName()));
}
} else if (size > 1) {
throw new IllegalArgumentException("The class (%s) has %s members (%s) with %s annotation."
.formatted(clazz, memberList.size(), memberList, annotationClass.getSimpleName()));
}
return memberList.get(0);
}
private static List<Member> getMembers(List<Member> memberList, boolean needMethod) {
var filteredMemberList = new ArrayList<Member>(memberList.size());
for (var member : memberList) {
if (member instanceof Method && needMethod) {
filteredMemberList.add(member);
} else if (member instanceof Field && !needMethod) {
filteredMemberList.add(member);
}
}
return filteredMemberList;
}
public static @NonNull String abbreviate(@Nullable List<@Nullable String> list, int limit) {
if (list == null || list.isEmpty()) {
return "";
}
var abbreviation = list.stream().limit(limit).collect(Collectors.joining(", "));
if (list.size() > limit) {
abbreviation += ", ...";
}
return abbreviation;
}
public static @NonNull String abbreviate(@Nullable List<@Nullable String> list) {
return abbreviate(list, 3);
}
public static String addRandomSuffix(String name, Random random) {
var value = new StringBuilder(name);
value.append("-");
random.ints(97, 122) // ['a', 'z']
.limit(4) // 4 letters
.forEach(value::appendCodePoint);
return value.toString();
}
// ************************************************************************
// Private constructor
// ************************************************************************
private ConfigUtils() {
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/enterprise/TimefoldSolverEnterpriseService.java | package ai.timefold.solver.core.enterprise;
import java.lang.reflect.InvocationTargetException;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
import ai.timefold.solver.core.api.score.stream.ConstraintProvider;
import ai.timefold.solver.core.api.solver.SolverFactory;
import ai.timefold.solver.core.config.heuristic.selector.common.SelectionCacheType;
import ai.timefold.solver.core.config.heuristic.selector.common.SelectionOrder;
import ai.timefold.solver.core.config.heuristic.selector.common.nearby.NearbySelectionConfig;
import ai.timefold.solver.core.config.heuristic.selector.entity.EntitySelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.list.DestinationSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.list.SubListSelectorConfig;
import ai.timefold.solver.core.config.heuristic.selector.value.ValueSelectorConfig;
import ai.timefold.solver.core.config.partitionedsearch.PartitionedSearchPhaseConfig;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.constructionheuristic.decider.ConstructionHeuristicDecider;
import ai.timefold.solver.core.impl.constructionheuristic.decider.forager.ConstructionHeuristicForager;
import ai.timefold.solver.core.impl.domain.entity.descriptor.EntityDescriptor;
import ai.timefold.solver.core.impl.domain.variable.declarative.TopologicalOrderGraph;
import ai.timefold.solver.core.impl.heuristic.HeuristicConfigPolicy;
import ai.timefold.solver.core.impl.heuristic.selector.entity.EntitySelector;
import ai.timefold.solver.core.impl.heuristic.selector.list.DestinationSelector;
import ai.timefold.solver.core.impl.heuristic.selector.list.ElementDestinationSelector;
import ai.timefold.solver.core.impl.heuristic.selector.list.RandomSubListSelector;
import ai.timefold.solver.core.impl.heuristic.selector.list.SubListSelector;
import ai.timefold.solver.core.impl.heuristic.selector.value.ValueSelector;
import ai.timefold.solver.core.impl.localsearch.decider.LocalSearchDecider;
import ai.timefold.solver.core.impl.localsearch.decider.acceptor.Acceptor;
import ai.timefold.solver.core.impl.localsearch.decider.forager.LocalSearchForager;
import ai.timefold.solver.core.impl.move.MoveRepository;
import ai.timefold.solver.core.impl.partitionedsearch.PartitionedSearchPhase;
import ai.timefold.solver.core.impl.solver.termination.PhaseTermination;
import ai.timefold.solver.core.impl.solver.termination.SolverTermination;
public interface TimefoldSolverEnterpriseService {
String SOLVER_NAME = "Timefold Solver";
String COMMUNITY_NAME = "Community Edition";
String COMMUNITY_COORDINATES = "ai.timefold.solver:timefold-solver-core";
String ENTERPRISE_NAME = "Enterprise Edition";
String ENTERPRISE_COORDINATES = "ai.timefold.solver.enterprise:timefold-solver-enterprise-core";
String DEVELOPMENT_SNAPSHOT = "Development Snapshot";
static String identifySolverVersion() {
var packaging = COMMUNITY_NAME;
try {
load();
packaging = ENTERPRISE_NAME;
} catch (Exception e) {
// No need to do anything, just checking if Enterprise exists.
}
var version = getVersionString(SolverFactory.class);
return packaging + " " + version;
}
private static String getVersionString(Class<?> clz) {
var version = clz.getPackage().getImplementationVersion();
return (version == null ? DEVELOPMENT_SNAPSHOT : "v" + version);
}
static TimefoldSolverEnterpriseService load() throws ClassNotFoundException, NoSuchMethodException,
InvocationTargetException, InstantiationException, IllegalAccessException {
// Avoids ServiceLoader by using reflection directly.
var clz = (Class<? extends TimefoldSolverEnterpriseService>) Class
.forName("ai.timefold.solver.enterprise.core.DefaultTimefoldSolverEnterpriseService");
return clz.getDeclaredConstructor().newInstance();
}
static TimefoldSolverEnterpriseService loadOrFail(Feature feature) {
TimefoldSolverEnterpriseService service;
try {
service = load();
} catch (Exception cause) {
throw new IllegalStateException("""
%s requested but %s %s not found on classpath.
Either add the %s dependency, or %s.
Note: %s %s is a commercial product. Visit https://timefold.ai to find out more."""
.formatted(feature.getName(), SOLVER_NAME, ENTERPRISE_NAME, feature.getWorkaround(),
ENTERPRISE_COORDINATES, SOLVER_NAME, ENTERPRISE_NAME),
cause);
}
var communityVersion = getVersionString(TimefoldSolverEnterpriseService.class);
var enterpriseVersion = getVersionString(service.getClass());
if (Objects.equals(communityVersion, enterpriseVersion)) { // Identical versions.
return service;
} else if (enterpriseVersion.equals(DEVELOPMENT_SNAPSHOT)) { // Don't enforce when running Enterprise tests.
return service;
}
throw new IllegalStateException("""
Detected mismatch between versions of %s %s (%s) and %s (%s).
Ensure your project uses the same version of %s and %s dependencies."""
.formatted(SOLVER_NAME, COMMUNITY_NAME, communityVersion, ENTERPRISE_NAME, enterpriseVersion,
COMMUNITY_COORDINATES, ENTERPRISE_COORDINATES));
}
static <T> T buildOrDefault(Function<TimefoldSolverEnterpriseService, T> builder, Supplier<T> defaultValue) {
try {
var service = load();
return builder.apply(service);
} catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | InstantiationException
| IllegalAccessException e) {
return defaultValue.get();
}
}
TopologicalOrderGraph buildTopologyGraph(int size);
Class<? extends ConstraintProvider>
buildLambdaSharedConstraintProvider(Class<? extends ConstraintProvider> originalConstraintProvider);
<Solution_> ConstructionHeuristicDecider<Solution_> buildConstructionHeuristic(PhaseTermination<Solution_> termination,
ConstructionHeuristicForager<Solution_> forager, HeuristicConfigPolicy<Solution_> configPolicy);
<Solution_> LocalSearchDecider<Solution_> buildLocalSearch(int moveThreadCount, PhaseTermination<Solution_> termination,
MoveRepository<Solution_> moveRepository, Acceptor<Solution_> acceptor, LocalSearchForager<Solution_> forager,
EnvironmentMode environmentMode, HeuristicConfigPolicy<Solution_> configPolicy);
<Solution_> PartitionedSearchPhase<Solution_> buildPartitionedSearch(int phaseIndex,
PartitionedSearchPhaseConfig phaseConfig, HeuristicConfigPolicy<Solution_> solverConfigPolicy,
SolverTermination<Solution_> solverTermination,
BiFunction<HeuristicConfigPolicy<Solution_>, SolverTermination<Solution_>, PhaseTermination<Solution_>> phaseTerminationFunction);
<Solution_> EntitySelector<Solution_> applyNearbySelection(EntitySelectorConfig entitySelectorConfig,
HeuristicConfigPolicy<Solution_> configPolicy, NearbySelectionConfig nearbySelectionConfig,
SelectionCacheType minimumCacheType, SelectionOrder resolvedSelectionOrder,
EntitySelector<Solution_> entitySelector);
<Solution_> ValueSelector<Solution_> applyNearbySelection(ValueSelectorConfig valueSelectorConfig,
HeuristicConfigPolicy<Solution_> configPolicy, EntityDescriptor<Solution_> entityDescriptor,
SelectionCacheType minimumCacheType, SelectionOrder resolvedSelectionOrder, ValueSelector<Solution_> valueSelector);
<Solution_> SubListSelector<Solution_> applyNearbySelection(SubListSelectorConfig subListSelectorConfig,
HeuristicConfigPolicy<Solution_> configPolicy, SelectionCacheType minimumCacheType,
SelectionOrder resolvedSelectionOrder, RandomSubListSelector<Solution_> subListSelector);
<Solution_> DestinationSelector<Solution_> applyNearbySelection(DestinationSelectorConfig destinationSelectorConfig,
HeuristicConfigPolicy<Solution_> configPolicy, SelectionCacheType minimumCacheType,
SelectionOrder resolvedSelectionOrder, ElementDestinationSelector<Solution_> destinationSelector);
enum Feature {
MULTITHREADED_SOLVING("Multi-threaded solving", "remove moveThreadCount from solver configuration"),
PARTITIONED_SEARCH("Partitioned search", "remove partitioned search phase from solver configuration"),
NEARBY_SELECTION("Nearby selection", "remove nearby selection from solver configuration"),
AUTOMATIC_NODE_SHARING("Automatic node sharing",
"remove automatic node sharing from solver configuration");
private final String name;
private final String workaround;
Feature(String name, String workaround) {
this.name = name;
this.workaround = workaround;
}
public String getName() {
return name;
}
public String getWorkaround() {
return workaround;
}
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/AbstractFromConfigFactory.java | package ai.timefold.solver.core.impl;
import java.util.List;
import java.util.Objects;
import ai.timefold.solver.core.api.domain.solution.PlanningSolution;
import ai.timefold.solver.core.config.AbstractConfig;
import ai.timefold.solver.core.config.heuristic.selector.common.SelectionCacheType;
import ai.timefold.solver.core.config.heuristic.selector.common.SelectionOrder;
import ai.timefold.solver.core.config.heuristic.selector.entity.EntitySelectorConfig;
import ai.timefold.solver.core.impl.domain.entity.descriptor.EntityDescriptor;
import ai.timefold.solver.core.impl.domain.solution.descriptor.SolutionDescriptor;
import ai.timefold.solver.core.impl.domain.variable.descriptor.GenuineVariableDescriptor;
import ai.timefold.solver.core.impl.heuristic.HeuristicConfigPolicy;
public abstract class AbstractFromConfigFactory<Solution_, Config_ extends AbstractConfig<Config_>> {
protected final Config_ config;
protected AbstractFromConfigFactory(Config_ config) {
this.config = config;
}
public static <Solution_> EntitySelectorConfig getDefaultEntitySelectorConfigForEntity(
HeuristicConfigPolicy<Solution_> configPolicy, EntityDescriptor<Solution_> entityDescriptor) {
var entityClass = entityDescriptor.getEntityClass();
var entitySelectorConfig = new EntitySelectorConfig()
.withId(entityClass.getName())
.withEntityClass(entityClass);
return deduceEntitySortManner(configPolicy, entityDescriptor, entitySelectorConfig);
}
public static <Solution_> EntitySelectorConfig deduceEntitySortManner(HeuristicConfigPolicy<Solution_> configPolicy,
EntityDescriptor<Solution_> entityDescriptor, EntitySelectorConfig entitySelectorConfig) {
if (configPolicy.getEntitySorterManner() != null
&& EntitySelectorConfig.hasSorter(configPolicy.getEntitySorterManner(), entityDescriptor)) {
entitySelectorConfig = entitySelectorConfig.withCacheType(SelectionCacheType.PHASE)
.withSelectionOrder(SelectionOrder.SORTED)
.withSorterManner(configPolicy.getEntitySorterManner());
}
return entitySelectorConfig;
}
protected EntityDescriptor<Solution_> deduceEntityDescriptor(HeuristicConfigPolicy<Solution_> configPolicy,
Class<?> entityClass) {
var solutionDescriptor = configPolicy.getSolutionDescriptor();
return entityClass == null
? getTheOnlyEntityDescriptor(solutionDescriptor)
: getEntityDescriptorForClass(solutionDescriptor, entityClass);
}
private EntityDescriptor<Solution_> getEntityDescriptorForClass(SolutionDescriptor<Solution_> solutionDescriptor,
Class<?> entityClass) {
var entityDescriptor = solutionDescriptor.getEntityDescriptorStrict(entityClass);
if (entityDescriptor == null) {
throw new IllegalArgumentException(
"""
The config (%s) has an entityClass (%s) that is not a known planning entity.
Check your solver configuration. If that class (%s) is not in the entityClassSet (%s), check your @%s implementation's annotated methods too."""
.formatted(config, entityClass, entityClass.getSimpleName(), solutionDescriptor.getEntityClassSet(),
PlanningSolution.class.getSimpleName()));
}
return entityDescriptor;
}
protected EntityDescriptor<Solution_> getTheOnlyEntityDescriptor(SolutionDescriptor<Solution_> solutionDescriptor) {
var entityDescriptors = solutionDescriptor.getGenuineEntityDescriptors();
if (entityDescriptors.size() != 1) {
throw new IllegalArgumentException(
"The config (%s) has no entityClass configured and because there are multiple in the entityClassSet (%s), it cannot be deduced automatically."
.formatted(config, solutionDescriptor.getEntityClassSet()));
}
return entityDescriptors.iterator().next();
}
protected EntityDescriptor<Solution_>
getTheOnlyEntityDescriptorWithBasicVariables(SolutionDescriptor<Solution_> solutionDescriptor) {
var entityDescriptors = solutionDescriptor.getGenuineEntityDescriptors()
.stream()
.filter(EntityDescriptor::hasAnyGenuineBasicVariables)
.toList();
if (entityDescriptors.size() != 1) {
throw new IllegalArgumentException(
"The config (%s) has no entityClass configured and because there are multiple in the entityClassSet (%s) defining basic variables, it cannot be deduced automatically."
.formatted(config, solutionDescriptor.getEntityClassSet()));
}
return entityDescriptors.iterator().next();
}
protected EntityDescriptor<Solution_>
getTheOnlyEntityDescriptorWithListVariable(SolutionDescriptor<Solution_> solutionDescriptor) {
var entityDescriptors = solutionDescriptor.getGenuineEntityDescriptors()
.stream()
.filter(EntityDescriptor::hasAnyGenuineListVariables)
.toList();
if (entityDescriptors.size() != 1) {
throw new IllegalArgumentException(
"Impossible state: the config (%s) has no entityClass configured and because there are multiple in the entityClassSet (%s), it cannot be deduced automatically."
.formatted(config, solutionDescriptor.getEntityClassSet()));
}
return entityDescriptors.iterator().next();
}
protected GenuineVariableDescriptor<Solution_> deduceGenuineVariableDescriptor(EntityDescriptor<Solution_> entityDescriptor,
String variableName) {
return variableName == null
? getTheOnlyVariableDescriptor(entityDescriptor)
: getVariableDescriptorForName(entityDescriptor, variableName);
}
protected GenuineVariableDescriptor<Solution_> getVariableDescriptorForName(EntityDescriptor<Solution_> entityDescriptor,
String variableName) {
var variableDescriptor = entityDescriptor.getGenuineVariableDescriptor(variableName);
if (variableDescriptor == null) {
throw new IllegalArgumentException(
"""
The config (%s) has a variableName (%s) which is not a valid planning variable on entityClass (%s).
%s""".formatted(config, variableName, entityDescriptor.getEntityClass(),
entityDescriptor.buildInvalidVariableNameExceptionMessage(variableName)));
}
return variableDescriptor;
}
protected GenuineVariableDescriptor<Solution_> getTheOnlyVariableDescriptor(EntityDescriptor<Solution_> entityDescriptor) {
var variableDescriptorList = entityDescriptor.getGenuineVariableDescriptorList();
if (variableDescriptorList.size() != 1) {
throw new IllegalArgumentException(
"The config (%s) has no configured variableName for entityClass (%s) and because there are multiple variableNames (%s), it cannot be deduced automatically."
.formatted(config, entityDescriptor.getEntityClass(),
entityDescriptor.getGenuineVariableNameSet()));
}
return variableDescriptorList.iterator().next();
}
protected List<GenuineVariableDescriptor<Solution_>> deduceVariableDescriptorList(
EntityDescriptor<Solution_> entityDescriptor, List<String> variableNameIncludeList) {
Objects.requireNonNull(entityDescriptor);
var variableDescriptorList = entityDescriptor.getGenuineVariableDescriptorList();
if (variableNameIncludeList == null) {
return variableDescriptorList;
}
return variableNameIncludeList.stream()
.map(variableNameInclude -> variableDescriptorList.stream()
.filter(variableDescriptor -> variableDescriptor.getVariableName().equals(variableNameInclude))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(
"The config (%s) has a variableNameInclude (%s) which does not exist in the entity (%s)'s variableDescriptorList (%s)."
.formatted(config, variableNameInclude, entityDescriptor.getEntityClass(),
variableDescriptorList))))
.toList();
}
protected List<GenuineVariableDescriptor<Solution_>> deduceBasicVariableDescriptorList(
EntityDescriptor<Solution_> entityDescriptor, List<String> variableNameIncludeList) {
Objects.requireNonNull(entityDescriptor);
var variableDescriptorList = entityDescriptor.getGenuineBasicVariableDescriptorList();
if (variableNameIncludeList == null) {
return variableDescriptorList;
}
return variableNameIncludeList.stream()
.map(variableNameInclude -> variableDescriptorList.stream()
.filter(variableDescriptor -> variableDescriptor.getVariableName().equals(variableNameInclude))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(
"The config (%s) has a variableNameInclude (%s) which does not exist in the entity (%s)'s variableDescriptorList (%s)."
.formatted(config, variableNameInclude, entityDescriptor.getEntityClass(),
variableDescriptorList))))
.toList();
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/package-info.java | /**
* Implementation classes of Timefold.
* <p>
* All classes in this namespace are NOT backwards compatible: they might change in future releases
* (including hotfix releases). All relevant changes are documented in
* <a href="https://docs.timefold.ai/timefold-solver/latest/upgrading-timefold-solver/upgrade-to-latest-version">the upgrade
* recipe</a>.
*/
package ai.timefold.solver.core.impl;
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/AbstractSession.java | package ai.timefold.solver.core.impl.bavet;
import java.util.IdentityHashMap;
import java.util.Map;
import ai.timefold.solver.core.impl.bavet.uni.AbstractForEachUniNode;
import ai.timefold.solver.core.impl.bavet.uni.AbstractForEachUniNode.LifecycleOperation;
public abstract class AbstractSession {
private final NodeNetwork nodeNetwork;
private final Map<Class<?>, AbstractForEachUniNode<Object>[]> insertEffectiveClassToNodeArrayMap;
private final Map<Class<?>, AbstractForEachUniNode<Object>[]> updateEffectiveClassToNodeArrayMap;
private final Map<Class<?>, AbstractForEachUniNode<Object>[]> retractEffectiveClassToNodeArrayMap;
protected AbstractSession(NodeNetwork nodeNetwork) {
this.nodeNetwork = nodeNetwork;
this.insertEffectiveClassToNodeArrayMap = new IdentityHashMap<>(nodeNetwork.forEachNodeCount());
this.updateEffectiveClassToNodeArrayMap = new IdentityHashMap<>(nodeNetwork.forEachNodeCount());
this.retractEffectiveClassToNodeArrayMap = new IdentityHashMap<>(nodeNetwork.forEachNodeCount());
}
public final void insert(Object fact) {
var factClass = fact.getClass();
for (var node : findNodes(factClass, LifecycleOperation.INSERT)) {
node.insert(fact);
}
}
@SuppressWarnings("unchecked")
private AbstractForEachUniNode<Object>[] findNodes(Class<?> factClass, LifecycleOperation lifecycleOperation) {
var effectiveClassToNodeArrayMap = switch (lifecycleOperation) {
case INSERT -> insertEffectiveClassToNodeArrayMap;
case UPDATE -> updateEffectiveClassToNodeArrayMap;
case RETRACT -> retractEffectiveClassToNodeArrayMap;
};
// Map.computeIfAbsent() would have created lambdas on the hot path, this will not.
var nodeArray = effectiveClassToNodeArrayMap.get(factClass);
if (nodeArray == null) {
nodeArray = nodeNetwork.getForEachNodes(factClass)
.filter(node -> node.supports(lifecycleOperation))
.toArray(AbstractForEachUniNode[]::new);
effectiveClassToNodeArrayMap.put(factClass, nodeArray);
}
return nodeArray;
}
public final void update(Object fact) {
var factClass = fact.getClass();
for (var node : findNodes(factClass, LifecycleOperation.UPDATE)) {
node.update(fact);
}
}
public final void retract(Object fact) {
var factClass = fact.getClass();
for (var node : findNodes(factClass, LifecycleOperation.RETRACT)) {
node.retract(fact);
}
}
public void settle() {
nodeNetwork.settle();
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/NodeNetwork.java | package ai.timefold.solver.core.impl.bavet;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Stream;
import ai.timefold.solver.core.api.domain.solution.PlanningSolution;
import ai.timefold.solver.core.impl.bavet.common.Propagator;
import ai.timefold.solver.core.impl.bavet.uni.AbstractForEachUniNode;
/**
* Represents Bavet's network of nodes, specific to a particular session.
* Nodes only used by disabled constraints have already been removed.
*
* @param declaredClassToNodeMap starting nodes, one for each class used in the constraints;
* root nodes, layer index 0.
* @param layeredNodes nodes grouped first by their layer, then by their index within the layer;
* propagation needs to happen in this order.
*/
public record NodeNetwork(Map<Class<?>, List<AbstractForEachUniNode<?>>> declaredClassToNodeMap,
Propagator[][] layeredNodes) {
public static final NodeNetwork EMPTY = new NodeNetwork(Map.of(), new Propagator[0][0]);
public int forEachNodeCount() {
return declaredClassToNodeMap.size();
}
public int layerCount() {
return layeredNodes.length;
}
public Stream<AbstractForEachUniNode<?>> getForEachNodes(Class<?> factClass) {
// The node needs to match the fact, or the node needs to be applicable to the entire solution.
// The latter is for FromSolution nodes.
return declaredClassToNodeMap.entrySet()
.stream()
.filter(entry -> factClass == PlanningSolution.class || entry.getKey().isAssignableFrom(factClass))
.map(Map.Entry::getValue)
.flatMap(List::stream);
}
public void settle() {
for (var layerIndex = 0; layerIndex < layerCount(); layerIndex++) {
settleLayer(layeredNodes[layerIndex]);
}
}
private static void settleLayer(Propagator[] nodesInLayer) {
var nodeCount = nodesInLayer.length;
if (nodeCount == 1) {
nodesInLayer[0].propagateEverything();
} else {
for (var node : nodesInLayer) {
node.propagateRetracts();
}
for (var node : nodesInLayer) {
node.propagateUpdates();
}
for (var node : nodesInLayer) {
node.propagateInserts();
}
}
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof NodeNetwork that))
return false;
return Objects.equals(declaredClassToNodeMap, that.declaredClassToNodeMap)
&& Objects.deepEquals(layeredNodes, that.layeredNodes);
}
@Override
public int hashCode() {
return Objects.hash(declaredClassToNodeMap, Arrays.deepHashCode(layeredNodes));
}
@Override
public String toString() {
return "%s with %d forEach nodes."
.formatted(getClass().getSimpleName(), forEachNodeCount());
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/AbstractGroupBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.function.Function;
import ai.timefold.solver.core.api.function.TriFunction;
import ai.timefold.solver.core.api.score.stream.bi.BiConstraintCollector;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.AbstractGroupNode;
import ai.timefold.solver.core.impl.bavet.common.tuple.AbstractTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
abstract class AbstractGroupBiNode<OldA, OldB, OutTuple_ extends AbstractTuple, GroupKey_, ResultContainer_, Result_>
extends AbstractGroupNode<BiTuple<OldA, OldB>, OutTuple_, GroupKey_, ResultContainer_, Result_> {
private final TriFunction<ResultContainer_, OldA, OldB, Runnable> accumulator;
protected AbstractGroupBiNode(int groupStoreIndex, int undoStoreIndex,
Function<BiTuple<OldA, OldB>, GroupKey_> groupKeyFunction,
BiConstraintCollector<OldA, OldB, ResultContainer_, Result_> collector,
TupleLifecycle<OutTuple_> nextNodesTupleLifecycle, EnvironmentMode environmentMode) {
super(groupStoreIndex, undoStoreIndex,
groupKeyFunction,
collector == null ? null : collector.supplier(),
collector == null ? null : collector.finisher(),
nextNodesTupleLifecycle, environmentMode);
accumulator = collector == null ? null : collector.accumulator();
}
protected AbstractGroupBiNode(int groupStoreIndex,
Function<BiTuple<OldA, OldB>, GroupKey_> groupKeyFunction, TupleLifecycle<OutTuple_> nextNodesTupleLifecycle,
EnvironmentMode environmentMode) {
super(groupStoreIndex,
groupKeyFunction, nextNodesTupleLifecycle, environmentMode);
accumulator = null;
}
@Override
protected final Runnable accumulate(ResultContainer_ resultContainer, BiTuple<OldA, OldB> tuple) {
return accumulator.apply(resultContainer, tuple.factA, tuple.factB);
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/ConcatBiBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import ai.timefold.solver.core.impl.bavet.common.AbstractConcatNode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
public final class ConcatBiBiNode<A, B>
extends AbstractConcatNode<BiTuple<A, B>, BiTuple<A, B>, BiTuple<A, B>> {
public ConcatBiBiNode(TupleLifecycle<BiTuple<A, B>> nextNodesTupleLifecycle,
int inputStoreIndexLeftOutTupleList, int inputStoreIndexRightOutTupleList,
int outputStoreSize) {
super(nextNodesTupleLifecycle, inputStoreIndexLeftOutTupleList, inputStoreIndexRightOutTupleList, outputStoreSize);
}
@Override
protected BiTuple<A, B> getOutTupleFromLeft(BiTuple<A, B> leftTuple) {
return new BiTuple<>(leftTuple.factA, leftTuple.factB, outputStoreSize);
}
@Override
protected BiTuple<A, B> getOutTupleFromRight(BiTuple<A, B> rightTuple) {
return new BiTuple<>(rightTuple.factA, rightTuple.factB, outputStoreSize);
}
@Override
protected void updateOutTupleFromLeft(BiTuple<A, B> leftTuple, BiTuple<A, B> outTuple) {
outTuple.factA = leftTuple.factA;
outTuple.factB = leftTuple.factB;
}
@Override
protected void updateOutTupleFromRight(BiTuple<A, B> rightTuple, BiTuple<A, B> outTuple) {
outTuple.factA = rightTuple.factA;
outTuple.factB = rightTuple.factB;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/ConcatBiUniNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.function.Function;
import ai.timefold.solver.core.impl.bavet.common.AbstractConcatNode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.bavet.common.tuple.UniTuple;
public final class ConcatBiUniNode<A, B>
extends AbstractConcatNode<BiTuple<A, B>, UniTuple<A>, BiTuple<A, B>> {
private final Function<A, B> paddingFunction;
public ConcatBiUniNode(Function<A, B> paddingFunction, TupleLifecycle<BiTuple<A, B>> nextNodesTupleLifecycle,
int inputStoreIndexLeftOutTupleList, int inputStoreIndexRightOutTupleList,
int outputStoreSize) {
super(nextNodesTupleLifecycle, inputStoreIndexLeftOutTupleList, inputStoreIndexRightOutTupleList, outputStoreSize);
this.paddingFunction = paddingFunction;
}
@Override
protected BiTuple<A, B> getOutTupleFromLeft(BiTuple<A, B> leftTuple) {
return new BiTuple<>(leftTuple.factA, leftTuple.factB, outputStoreSize);
}
@Override
protected BiTuple<A, B> getOutTupleFromRight(UniTuple<A> rightTuple) {
var factA = rightTuple.factA;
return new BiTuple<>(factA, paddingFunction.apply(factA), outputStoreSize);
}
@Override
protected void updateOutTupleFromLeft(BiTuple<A, B> leftTuple, BiTuple<A, B> outTuple) {
outTuple.factA = leftTuple.factA;
outTuple.factB = leftTuple.factB;
}
@Override
protected void updateOutTupleFromRight(UniTuple<A> rightTuple, BiTuple<A, B> outTuple) {
outTuple.factA = rightTuple.factA;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/ConcatUniBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.function.Function;
import ai.timefold.solver.core.impl.bavet.common.AbstractConcatNode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.bavet.common.tuple.UniTuple;
public final class ConcatUniBiNode<A, B>
extends AbstractConcatNode<UniTuple<A>, BiTuple<A, B>, BiTuple<A, B>> {
private final Function<A, B> paddingFunction;
public ConcatUniBiNode(Function<A, B> paddingFunction, TupleLifecycle<BiTuple<A, B>> nextNodesTupleLifecycle,
int inputStoreIndexLeftOutTupleList, int inputStoreIndexRightOutTupleList,
int outputStoreSize) {
super(nextNodesTupleLifecycle, inputStoreIndexLeftOutTupleList, inputStoreIndexRightOutTupleList,
outputStoreSize);
this.paddingFunction = paddingFunction;
}
@Override
protected BiTuple<A, B> getOutTupleFromLeft(UniTuple<A> leftTuple) {
var factA = leftTuple.factA;
return new BiTuple<>(factA, paddingFunction.apply(factA), outputStoreSize);
}
@Override
protected BiTuple<A, B> getOutTupleFromRight(BiTuple<A, B> rightTuple) {
return new BiTuple<>(rightTuple.factA, rightTuple.factB, outputStoreSize);
}
@Override
protected void updateOutTupleFromLeft(UniTuple<A> leftTuple, BiTuple<A, B> outTuple) {
outTuple.factA = leftTuple.factA;
}
@Override
protected void updateOutTupleFromRight(BiTuple<A, B> rightTuple, BiTuple<A, B> outTuple) {
outTuple.factA = rightTuple.factA;
outTuple.factB = rightTuple.factB;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/FlattenLastBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.function.Function;
import ai.timefold.solver.core.impl.bavet.common.AbstractFlattenLastNode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
public final class FlattenLastBiNode<A, B, NewB> extends AbstractFlattenLastNode<BiTuple<A, B>, BiTuple<A, NewB>, B, NewB> {
private final int outputStoreSize;
public FlattenLastBiNode(int flattenLastStoreIndex, Function<B, Iterable<NewB>> mappingFunction,
TupleLifecycle<BiTuple<A, NewB>> nextNodesTupleLifecycle, int outputStoreSize) {
super(flattenLastStoreIndex, mappingFunction, nextNodesTupleLifecycle);
this.outputStoreSize = outputStoreSize;
}
@Override
protected BiTuple<A, NewB> createTuple(BiTuple<A, B> originalTuple, NewB newB) {
return new BiTuple<>(originalTuple.factA, newB, outputStoreSize);
}
@Override
protected B getEffectiveFactIn(BiTuple<A, B> tuple) {
return tuple.factB;
}
@Override
protected NewB getEffectiveFactOut(BiTuple<A, NewB> outTuple) {
return outTuple.factB;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group0Mapping1CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import ai.timefold.solver.core.api.score.stream.bi.BiConstraintCollector;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.bavet.common.tuple.UniTuple;
public final class Group0Mapping1CollectorBiNode<OldA, OldB, A, ResultContainer_>
extends AbstractGroupBiNode<OldA, OldB, UniTuple<A>, Void, ResultContainer_, A> {
private final int outputStoreSize;
public Group0Mapping1CollectorBiNode(int groupStoreIndex, int undoStoreIndex,
BiConstraintCollector<OldA, OldB, ResultContainer_, A> collector,
TupleLifecycle<UniTuple<A>> nextNodesTupleLifecycle, int outputStoreSize, EnvironmentMode environmentMode) {
super(groupStoreIndex, undoStoreIndex,
null, collector, nextNodesTupleLifecycle, environmentMode);
this.outputStoreSize = outputStoreSize;
}
@Override
protected UniTuple<A> createOutTuple(Void groupKey) {
return new UniTuple<>(null, outputStoreSize);
}
@Override
protected void updateOutTupleToResult(UniTuple<A> outTuple, A a) {
outTuple.factA = a;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group0Mapping2CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import ai.timefold.solver.core.api.score.stream.ConstraintCollectors;
import ai.timefold.solver.core.api.score.stream.bi.BiConstraintCollector;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.util.Pair;
public final class Group0Mapping2CollectorBiNode<OldA, OldB, A, B, ResultContainerA_, ResultContainerB_>
extends AbstractGroupBiNode<OldA, OldB, BiTuple<A, B>, Void, Object, Pair<A, B>> {
private final int outputStoreSize;
public Group0Mapping2CollectorBiNode(int groupStoreIndex, int undoStoreIndex,
BiConstraintCollector<OldA, OldB, ResultContainerA_, A> collectorA,
BiConstraintCollector<OldA, OldB, ResultContainerB_, B> collectorB,
TupleLifecycle<BiTuple<A, B>> nextNodesTupleLifecycle, int outputStoreSize, EnvironmentMode environmentMode) {
super(groupStoreIndex, undoStoreIndex,
null, mergeCollectors(collectorA, collectorB), nextNodesTupleLifecycle, environmentMode);
this.outputStoreSize = outputStoreSize;
}
static <OldA, OldB, A, B, ResultContainerA_, ResultContainerB_>
BiConstraintCollector<OldA, OldB, Object, Pair<A, B>> mergeCollectors(
BiConstraintCollector<OldA, OldB, ResultContainerA_, A> collectorA,
BiConstraintCollector<OldA, OldB, ResultContainerB_, B> collectorB) {
return (BiConstraintCollector<OldA, OldB, Object, Pair<A, B>>) ConstraintCollectors.compose(collectorA, collectorB,
Pair::new);
}
@Override
protected BiTuple<A, B> createOutTuple(Void groupKey) {
return new BiTuple<>(null, null, outputStoreSize);
}
@Override
protected void updateOutTupleToResult(BiTuple<A, B> outTuple, Pair<A, B> result) {
outTuple.factA = result.key();
outTuple.factB = result.value();
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group0Mapping3CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import ai.timefold.solver.core.api.score.stream.ConstraintCollectors;
import ai.timefold.solver.core.api.score.stream.bi.BiConstraintCollector;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.TriTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.util.Triple;
public final class Group0Mapping3CollectorBiNode<OldA, OldB, A, B, C, ResultContainerA_, ResultContainerB_, ResultContainerC_>
extends AbstractGroupBiNode<OldA, OldB, TriTuple<A, B, C>, Void, Object, Triple<A, B, C>> {
private final int outputStoreSize;
public Group0Mapping3CollectorBiNode(int groupStoreIndex, int undoStoreIndex,
BiConstraintCollector<OldA, OldB, ResultContainerA_, A> collectorA,
BiConstraintCollector<OldA, OldB, ResultContainerB_, B> collectorB,
BiConstraintCollector<OldA, OldB, ResultContainerC_, C> collectorC,
TupleLifecycle<TriTuple<A, B, C>> nextNodesTupleLifecycle, int outputStoreSize, EnvironmentMode environmentMode) {
super(groupStoreIndex, undoStoreIndex,
null, mergeCollectors(collectorA, collectorB, collectorC),
nextNodesTupleLifecycle, environmentMode);
this.outputStoreSize = outputStoreSize;
}
static <OldA, OldB, A, B, C, ResultContainerA_, ResultContainerB_, ResultContainerC_>
BiConstraintCollector<OldA, OldB, Object, Triple<A, B, C>> mergeCollectors(
BiConstraintCollector<OldA, OldB, ResultContainerA_, A> collectorA,
BiConstraintCollector<OldA, OldB, ResultContainerB_, B> collectorB,
BiConstraintCollector<OldA, OldB, ResultContainerC_, C> collectorC) {
return (BiConstraintCollector<OldA, OldB, Object, Triple<A, B, C>>) ConstraintCollectors.compose(collectorA, collectorB,
collectorC, Triple::new);
}
@Override
protected TriTuple<A, B, C> createOutTuple(Void groupKey) {
return new TriTuple<>(null, null, null, outputStoreSize);
}
@Override
protected void updateOutTupleToResult(TriTuple<A, B, C> outTuple, Triple<A, B, C> result) {
outTuple.factA = result.a();
outTuple.factB = result.b();
outTuple.factC = result.c();
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group0Mapping4CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import ai.timefold.solver.core.api.score.stream.ConstraintCollectors;
import ai.timefold.solver.core.api.score.stream.bi.BiConstraintCollector;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.QuadTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.util.Quadruple;
public final class Group0Mapping4CollectorBiNode<OldA, OldB, A, B, C, D, ResultContainerA_, ResultContainerB_, ResultContainerC_, ResultContainerD_>
extends
AbstractGroupBiNode<OldA, OldB, QuadTuple<A, B, C, D>, Void, Object, Quadruple<A, B, C, D>> {
private final int outputStoreSize;
public Group0Mapping4CollectorBiNode(int groupStoreIndex, int undoStoreIndex,
BiConstraintCollector<OldA, OldB, ResultContainerA_, A> collectorA,
BiConstraintCollector<OldA, OldB, ResultContainerB_, B> collectorB,
BiConstraintCollector<OldA, OldB, ResultContainerC_, C> collectorC,
BiConstraintCollector<OldA, OldB, ResultContainerD_, D> collectorD,
TupleLifecycle<QuadTuple<A, B, C, D>> nextNodesTupleLifecycle, int outputStoreSize,
EnvironmentMode environmentMode) {
super(groupStoreIndex, undoStoreIndex,
null, mergeCollectors(collectorA, collectorB, collectorC, collectorD),
nextNodesTupleLifecycle, environmentMode);
this.outputStoreSize = outputStoreSize;
}
private static <OldA, OldB, A, B, C, D, ResultContainerA_, ResultContainerB_, ResultContainerC_, ResultContainerD_>
BiConstraintCollector<OldA, OldB, Object, Quadruple<A, B, C, D>> mergeCollectors(
BiConstraintCollector<OldA, OldB, ResultContainerA_, A> collectorA,
BiConstraintCollector<OldA, OldB, ResultContainerB_, B> collectorB,
BiConstraintCollector<OldA, OldB, ResultContainerC_, C> collectorC,
BiConstraintCollector<OldA, OldB, ResultContainerD_, D> collectorD) {
return (BiConstraintCollector<OldA, OldB, Object, Quadruple<A, B, C, D>>) ConstraintCollectors.compose(collectorA,
collectorB, collectorC, collectorD, Quadruple::new);
}
@Override
protected QuadTuple<A, B, C, D> createOutTuple(Void groupKey) {
return new QuadTuple<>(null, null, null, null, outputStoreSize);
}
@Override
protected void updateOutTupleToResult(QuadTuple<A, B, C, D> outTuple, Quadruple<A, B, C, D> result) {
outTuple.factA = result.a();
outTuple.factB = result.b();
outTuple.factC = result.c();
outTuple.factD = result.d();
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group1Mapping0CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.function.BiFunction;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.bavet.common.tuple.UniTuple;
public final class Group1Mapping0CollectorBiNode<OldA, OldB, A>
extends AbstractGroupBiNode<OldA, OldB, UniTuple<A>, A, Void, Void> {
private final int outputStoreSize;
public Group1Mapping0CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMapping,
int groupStoreIndex,
TupleLifecycle<UniTuple<A>> nextNodesTupleLifecycle, int outputStoreSize, EnvironmentMode environmentMode) {
super(groupStoreIndex,
tuple -> createGroupKey(groupKeyMapping, tuple), nextNodesTupleLifecycle, environmentMode);
this.outputStoreSize = outputStoreSize;
}
static <A, OldA, OldB> A createGroupKey(BiFunction<OldA, OldB, A> groupKeyMapping, BiTuple<OldA, OldB> tuple) {
return groupKeyMapping.apply(tuple.factA, tuple.factB);
}
@Override
protected UniTuple<A> createOutTuple(A a) {
return new UniTuple<>(a, outputStoreSize);
}
@Override
protected void updateOutTupleToResult(UniTuple<A> aUniTuple, Void unused) {
throw new IllegalStateException("Impossible state: collector is null.");
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group1Mapping1CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import static ai.timefold.solver.core.impl.bavet.bi.Group1Mapping0CollectorBiNode.createGroupKey;
import java.util.function.BiFunction;
import ai.timefold.solver.core.api.score.stream.bi.BiConstraintCollector;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
public final class Group1Mapping1CollectorBiNode<OldA, OldB, A, B, ResultContainer_>
extends AbstractGroupBiNode<OldA, OldB, BiTuple<A, B>, A, ResultContainer_, B> {
private final int outputStoreSize;
public Group1Mapping1CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMapping,
int groupStoreIndex, int undoStoreIndex,
BiConstraintCollector<OldA, OldB, ResultContainer_, B> collector,
TupleLifecycle<BiTuple<A, B>> nextNodesTupleLifecycle, int outputStoreSize, EnvironmentMode environmentMode) {
super(groupStoreIndex, undoStoreIndex,
tuple -> createGroupKey(groupKeyMapping, tuple), collector,
nextNodesTupleLifecycle, environmentMode);
this.outputStoreSize = outputStoreSize;
}
@Override
protected BiTuple<A, B> createOutTuple(A a) {
return new BiTuple<>(a, null, outputStoreSize);
}
@Override
protected void updateOutTupleToResult(BiTuple<A, B> outTuple, B b) {
outTuple.factB = b;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group1Mapping2CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import static ai.timefold.solver.core.impl.bavet.bi.Group1Mapping0CollectorBiNode.createGroupKey;
import java.util.function.BiFunction;
import ai.timefold.solver.core.api.score.stream.bi.BiConstraintCollector;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.TriTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.util.Pair;
public final class Group1Mapping2CollectorBiNode<OldA, OldB, A, B, C, ResultContainerB_, ResultContainerC_>
extends AbstractGroupBiNode<OldA, OldB, TriTuple<A, B, C>, A, Object, Pair<B, C>> {
private final int outputStoreSize;
public Group1Mapping2CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMapping,
int groupStoreIndex, int undoStoreIndex,
BiConstraintCollector<OldA, OldB, ResultContainerB_, B> collectorB,
BiConstraintCollector<OldA, OldB, ResultContainerC_, C> collectorC,
TupleLifecycle<TriTuple<A, B, C>> nextNodesTupleLifecycle, int outputStoreSize, EnvironmentMode environmentMode) {
super(groupStoreIndex, undoStoreIndex,
tuple -> createGroupKey(groupKeyMapping, tuple),
Group0Mapping2CollectorBiNode.mergeCollectors(collectorB, collectorC), nextNodesTupleLifecycle,
environmentMode);
this.outputStoreSize = outputStoreSize;
}
@Override
protected TriTuple<A, B, C> createOutTuple(A a) {
return new TriTuple<>(a, null, null, outputStoreSize);
}
@Override
protected void updateOutTupleToResult(TriTuple<A, B, C> outTuple, Pair<B, C> result) {
outTuple.factB = result.key();
outTuple.factC = result.value();
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group1Mapping3CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import static ai.timefold.solver.core.impl.bavet.bi.Group0Mapping3CollectorBiNode.mergeCollectors;
import static ai.timefold.solver.core.impl.bavet.bi.Group1Mapping0CollectorBiNode.createGroupKey;
import java.util.function.BiFunction;
import ai.timefold.solver.core.api.score.stream.bi.BiConstraintCollector;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.QuadTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.util.Triple;
public final class Group1Mapping3CollectorBiNode<OldA, OldB, A, B, C, D, ResultContainerB_, ResultContainerC_, ResultContainerD_>
extends AbstractGroupBiNode<OldA, OldB, QuadTuple<A, B, C, D>, A, Object, Triple<B, C, D>> {
private final int outputStoreSize;
public Group1Mapping3CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMapping,
int groupStoreIndex, int undoStoreIndex,
BiConstraintCollector<OldA, OldB, ResultContainerB_, B> collectorB,
BiConstraintCollector<OldA, OldB, ResultContainerC_, C> collectorC,
BiConstraintCollector<OldA, OldB, ResultContainerD_, D> collectorD,
TupleLifecycle<QuadTuple<A, B, C, D>> nextNodesTupleLifecycle, int outputStoreSize,
EnvironmentMode environmentMode) {
super(groupStoreIndex, undoStoreIndex,
tuple -> createGroupKey(groupKeyMapping, tuple),
mergeCollectors(collectorB, collectorC, collectorD), nextNodesTupleLifecycle, environmentMode);
this.outputStoreSize = outputStoreSize;
}
@Override
protected QuadTuple<A, B, C, D> createOutTuple(A a) {
return new QuadTuple<>(a, null, null, null, outputStoreSize);
}
@Override
protected void updateOutTupleToResult(QuadTuple<A, B, C, D> outTuple, Triple<B, C, D> result) {
outTuple.factB = result.a();
outTuple.factC = result.b();
outTuple.factD = result.c();
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group2Mapping0CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.function.BiFunction;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.util.Pair;
public final class Group2Mapping0CollectorBiNode<OldA, OldB, A, B>
extends AbstractGroupBiNode<OldA, OldB, BiTuple<A, B>, Pair<A, B>, Void, Void> {
private final int outputStoreSize;
public Group2Mapping0CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMappingA, BiFunction<OldA, OldB, B> groupKeyMappingB,
int groupStoreIndex, TupleLifecycle<BiTuple<A, B>> nextNodesTupleLifecycle,
int outputStoreSize,
EnvironmentMode environmentMode) {
super(groupStoreIndex,
tuple -> createGroupKey(groupKeyMappingA, groupKeyMappingB, tuple), nextNodesTupleLifecycle, environmentMode);
this.outputStoreSize = outputStoreSize;
}
static <A, B, OldA, OldB> Pair<A, B> createGroupKey(BiFunction<OldA, OldB, A> groupKeyMappingA,
BiFunction<OldA, OldB, B> groupKeyMappingB, BiTuple<OldA, OldB> tuple) {
OldA oldA = tuple.factA;
OldB oldB = tuple.factB;
A a = groupKeyMappingA.apply(oldA, oldB);
B b = groupKeyMappingB.apply(oldA, oldB);
return new Pair<>(a, b);
}
@Override
protected BiTuple<A, B> createOutTuple(Pair<A, B> groupKey) {
return new BiTuple<>(groupKey.key(), groupKey.value(), outputStoreSize);
}
@Override
protected void updateOutTupleToResult(BiTuple<A, B> outTuple, Void unused) {
throw new IllegalStateException("Impossible state: collector is null.");
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group2Mapping1CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.function.BiFunction;
import ai.timefold.solver.core.api.score.stream.bi.BiConstraintCollector;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.TriTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.util.Pair;
public final class Group2Mapping1CollectorBiNode<OldA, OldB, A, B, C, ResultContainer_>
extends AbstractGroupBiNode<OldA, OldB, TriTuple<A, B, C>, Pair<A, B>, ResultContainer_, C> {
private final int outputStoreSize;
public Group2Mapping1CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMappingA, BiFunction<OldA, OldB, B> groupKeyMappingB,
int groupStoreIndex, int undoStoreIndex,
BiConstraintCollector<OldA, OldB, ResultContainer_, C> collector,
TupleLifecycle<TriTuple<A, B, C>> nextNodesTupleLifecycle, int outputStoreSize, EnvironmentMode environmentMode) {
super(groupStoreIndex, undoStoreIndex,
tuple -> Group2Mapping0CollectorBiNode.createGroupKey(groupKeyMappingA, groupKeyMappingB, tuple), collector,
nextNodesTupleLifecycle, environmentMode);
this.outputStoreSize = outputStoreSize;
}
@Override
protected TriTuple<A, B, C> createOutTuple(Pair<A, B> groupKey) {
return new TriTuple<>(groupKey.key(), groupKey.value(), null, outputStoreSize);
}
@Override
protected void updateOutTupleToResult(TriTuple<A, B, C> outTuple, C c) {
outTuple.factC = c;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group2Mapping2CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.function.BiFunction;
import ai.timefold.solver.core.api.score.stream.bi.BiConstraintCollector;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.QuadTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.util.Pair;
public final class Group2Mapping2CollectorBiNode<OldA, OldB, A, B, C, D, ResultContainerC_, ResultContainerD_>
extends
AbstractGroupBiNode<OldA, OldB, QuadTuple<A, B, C, D>, Pair<A, B>, Object, Pair<C, D>> {
private final int outputStoreSize;
public Group2Mapping2CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMappingA, BiFunction<OldA, OldB, B> groupKeyMappingB,
int groupStoreIndex, int undoStoreIndex,
BiConstraintCollector<OldA, OldB, ResultContainerC_, C> collectorC,
BiConstraintCollector<OldA, OldB, ResultContainerD_, D> collectorD,
TupleLifecycle<QuadTuple<A, B, C, D>> nextNodesTupleLifecycle, int outputStoreSize,
EnvironmentMode environmentMode) {
super(groupStoreIndex, undoStoreIndex,
tuple -> Group2Mapping0CollectorBiNode.createGroupKey(groupKeyMappingA, groupKeyMappingB, tuple),
Group0Mapping2CollectorBiNode.mergeCollectors(collectorC, collectorD), nextNodesTupleLifecycle,
environmentMode);
this.outputStoreSize = outputStoreSize;
}
@Override
protected QuadTuple<A, B, C, D> createOutTuple(Pair<A, B> groupKey) {
return new QuadTuple<>(groupKey.key(), groupKey.value(), null, null, outputStoreSize);
}
@Override
protected void updateOutTupleToResult(QuadTuple<A, B, C, D> outTuple, Pair<C, D> result) {
outTuple.factC = result.key();
outTuple.factD = result.value();
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group3Mapping0CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.function.BiFunction;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TriTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.util.Triple;
public final class Group3Mapping0CollectorBiNode<OldA, OldB, A, B, C>
extends AbstractGroupBiNode<OldA, OldB, TriTuple<A, B, C>, Triple<A, B, C>, Void, Void> {
private final int outputStoreSize;
public Group3Mapping0CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMappingA, BiFunction<OldA, OldB, B> groupKeyMappingB,
BiFunction<OldA, OldB, C> groupKeyMappingC, int groupStoreIndex,
TupleLifecycle<TriTuple<A, B, C>> nextNodesTupleLifecycle, int outputStoreSize, EnvironmentMode environmentMode) {
super(groupStoreIndex,
tuple -> createGroupKey(groupKeyMappingA, groupKeyMappingB, groupKeyMappingC, tuple),
nextNodesTupleLifecycle, environmentMode);
this.outputStoreSize = outputStoreSize;
}
static <A, B, C, OldA, OldB> Triple<A, B, C> createGroupKey(BiFunction<OldA, OldB, A> groupKeyMappingA,
BiFunction<OldA, OldB, B> groupKeyMappingB, BiFunction<OldA, OldB, C> groupKeyMappingC,
BiTuple<OldA, OldB> tuple) {
OldA oldA = tuple.factA;
OldB oldB = tuple.factB;
A a = groupKeyMappingA.apply(oldA, oldB);
B b = groupKeyMappingB.apply(oldA, oldB);
C c = groupKeyMappingC.apply(oldA, oldB);
return new Triple<>(a, b, c);
}
@Override
protected TriTuple<A, B, C> createOutTuple(Triple<A, B, C> groupKey) {
return new TriTuple<>(groupKey.a(), groupKey.b(), groupKey.c(), outputStoreSize);
}
@Override
protected void updateOutTupleToResult(TriTuple<A, B, C> outTuple, Void unused) {
throw new IllegalStateException("Impossible state: collector is null.");
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group3Mapping1CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.function.BiFunction;
import ai.timefold.solver.core.api.score.stream.bi.BiConstraintCollector;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.QuadTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.util.Triple;
public final class Group3Mapping1CollectorBiNode<OldA, OldB, A, B, C, D, ResultContainer_>
extends
AbstractGroupBiNode<OldA, OldB, QuadTuple<A, B, C, D>, Triple<A, B, C>, ResultContainer_, D> {
private final int outputStoreSize;
public Group3Mapping1CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMappingA,
BiFunction<OldA, OldB, B> groupKeyMappingB, BiFunction<OldA, OldB, C> groupKeyMappingC,
int groupStoreIndex, int undoStoreIndex,
BiConstraintCollector<OldA, OldB, ResultContainer_, D> collector,
TupleLifecycle<QuadTuple<A, B, C, D>> nextNodesTupleLifecycle, int outputStoreSize,
EnvironmentMode environmentMode) {
super(groupStoreIndex, undoStoreIndex,
tuple -> Group3Mapping0CollectorBiNode.createGroupKey(groupKeyMappingA, groupKeyMappingB, groupKeyMappingC,
tuple),
collector,
nextNodesTupleLifecycle, environmentMode);
this.outputStoreSize = outputStoreSize;
}
@Override
protected QuadTuple<A, B, C, D> createOutTuple(Triple<A, B, C> groupKey) {
return new QuadTuple<>(groupKey.a(), groupKey.b(), groupKey.c(), null, outputStoreSize);
}
@Override
protected void updateOutTupleToResult(QuadTuple<A, B, C, D> outTuple, D d) {
outTuple.factD = d;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/Group4Mapping0CollectorBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.function.BiFunction;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.QuadTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.util.Quadruple;
public final class Group4Mapping0CollectorBiNode<OldA, OldB, A, B, C, D>
extends
AbstractGroupBiNode<OldA, OldB, QuadTuple<A, B, C, D>, Quadruple<A, B, C, D>, Void, Void> {
private final int outputStoreSize;
public Group4Mapping0CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMappingA, BiFunction<OldA, OldB, B> groupKeyMappingB,
BiFunction<OldA, OldB, C> groupKeyMappingC, BiFunction<OldA, OldB, D> groupKeyMappingD,
int groupStoreIndex,
TupleLifecycle<QuadTuple<A, B, C, D>> nextNodesTupleLifecycle, int outputStoreSize,
EnvironmentMode environmentMode) {
super(groupStoreIndex,
tuple -> createGroupKey(groupKeyMappingA, groupKeyMappingB, groupKeyMappingC, groupKeyMappingD, tuple),
nextNodesTupleLifecycle, environmentMode);
this.outputStoreSize = outputStoreSize;
}
private static <A, B, C, D, OldA, OldB> Quadruple<A, B, C, D> createGroupKey(
BiFunction<OldA, OldB, A> groupKeyMappingA, BiFunction<OldA, OldB, B> groupKeyMappingB,
BiFunction<OldA, OldB, C> groupKeyMappingC, BiFunction<OldA, OldB, D> groupKeyMappingD,
BiTuple<OldA, OldB> tuple) {
OldA oldA = tuple.factA;
OldB oldB = tuple.factB;
A a = groupKeyMappingA.apply(oldA, oldB);
B b = groupKeyMappingB.apply(oldA, oldB);
C c = groupKeyMappingC.apply(oldA, oldB);
D d = groupKeyMappingD.apply(oldA, oldB);
return new Quadruple<>(a, b, c, d);
}
@Override
protected QuadTuple<A, B, C, D> createOutTuple(Quadruple<A, B, C, D> groupKey) {
return new QuadTuple<>(groupKey.a(), groupKey.b(), groupKey.c(), groupKey.d(), outputStoreSize);
}
@Override
protected void updateOutTupleToResult(QuadTuple<A, B, C, D> outTuple, Void unused) {
throw new IllegalStateException("Impossible state: collector is null.");
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/IndexedIfExistsBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import ai.timefold.solver.core.api.function.TriPredicate;
import ai.timefold.solver.core.impl.bavet.common.AbstractIndexedIfExistsNode;
import ai.timefold.solver.core.impl.bavet.common.index.IndexerFactory;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.bavet.common.tuple.UniTuple;
public final class IndexedIfExistsBiNode<A, B, C> extends AbstractIndexedIfExistsNode<BiTuple<A, B>, C> {
private final TriPredicate<A, B, C> filtering;
public IndexedIfExistsBiNode(boolean shouldExist, IndexerFactory<C> indexerFactory,
int inputStoreIndexLeftKeys, int inputStoreIndexLeftCounterEntry,
int inputStoreIndexRightKeys, int inputStoreIndexRightEntry,
TupleLifecycle<BiTuple<A, B>> nextNodesTupleLifecycle) {
this(shouldExist, indexerFactory,
inputStoreIndexLeftKeys, inputStoreIndexLeftCounterEntry, -1,
inputStoreIndexRightKeys, inputStoreIndexRightEntry, -1,
nextNodesTupleLifecycle, null);
}
public IndexedIfExistsBiNode(boolean shouldExist, IndexerFactory<C> indexerFactory,
int inputStoreIndexLeftKeys, int inputStoreIndexLeftCounterEntry, int inputStoreIndexLeftTrackerList,
int inputStoreIndexRightKeys, int inputStoreIndexRightEntry, int inputStoreIndexRightTrackerList,
TupleLifecycle<BiTuple<A, B>> nextNodesTupleLifecycle, TriPredicate<A, B, C> filtering) {
super(shouldExist, indexerFactory.buildBiLeftKeysExtractor(), indexerFactory,
inputStoreIndexLeftKeys, inputStoreIndexLeftCounterEntry, inputStoreIndexLeftTrackerList,
inputStoreIndexRightKeys, inputStoreIndexRightEntry, inputStoreIndexRightTrackerList,
nextNodesTupleLifecycle, filtering != null);
this.filtering = filtering;
}
@Override
protected boolean testFiltering(BiTuple<A, B> leftTuple, UniTuple<C> rightTuple) {
return filtering.test(leftTuple.factA, leftTuple.factB, rightTuple.factA);
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/IndexedJoinBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.function.BiPredicate;
import ai.timefold.solver.core.impl.bavet.common.AbstractIndexedJoinNode;
import ai.timefold.solver.core.impl.bavet.common.index.IndexerFactory;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.bavet.common.tuple.UniTuple;
public final class IndexedJoinBiNode<A, B> extends AbstractIndexedJoinNode<UniTuple<A>, B, BiTuple<A, B>> {
private final BiPredicate<A, B> filtering;
private final int outputStoreSize;
public IndexedJoinBiNode(IndexerFactory<B> indexerFactory,
int inputStoreIndexA, int inputStoreIndexEntryA, int inputStoreIndexOutTupleListA,
int inputStoreIndexB, int inputStoreIndexEntryB, int inputStoreIndexOutTupleListB,
TupleLifecycle<BiTuple<A, B>> nextNodesTupleLifecycle, BiPredicate<A, B> filtering,
int outputStoreSize, int outputStoreIndexOutEntryA, int outputStoreIndexOutEntryB) {
super(indexerFactory.buildUniLeftKeysExtractor(), indexerFactory,
inputStoreIndexA, inputStoreIndexEntryA, inputStoreIndexOutTupleListA,
inputStoreIndexB, inputStoreIndexEntryB, inputStoreIndexOutTupleListB,
nextNodesTupleLifecycle, filtering != null,
outputStoreIndexOutEntryA, outputStoreIndexOutEntryB);
this.filtering = filtering;
this.outputStoreSize = outputStoreSize;
}
@Override
protected BiTuple<A, B> createOutTuple(UniTuple<A> leftTuple, UniTuple<B> rightTuple) {
return new BiTuple<>(leftTuple.factA, rightTuple.factA, outputStoreSize);
}
@Override
protected void setOutTupleLeftFacts(BiTuple<A, B> outTuple, UniTuple<A> leftTuple) {
outTuple.factA = leftTuple.factA;
}
@Override
protected void setOutTupleRightFact(BiTuple<A, B> outTuple, UniTuple<B> rightTuple) {
outTuple.factB = rightTuple.factA;
}
@Override
protected boolean testFiltering(UniTuple<A> leftTuple, UniTuple<B> rightTuple) {
return filtering.test(leftTuple.factA, rightTuple.factA);
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/MapBiToBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.Objects;
import java.util.function.BiFunction;
import ai.timefold.solver.core.impl.bavet.common.AbstractMapNode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
public final class MapBiToBiNode<A, B, NewA, NewB> extends AbstractMapNode<BiTuple<A, B>, BiTuple<NewA, NewB>> {
private final BiFunction<A, B, NewA> mappingFunctionA;
private final BiFunction<A, B, NewB> mappingFunctionB;
public MapBiToBiNode(int mapStoreIndex, BiFunction<A, B, NewA> mappingFunctionA, BiFunction<A, B, NewB> mappingFunctionB,
TupleLifecycle<BiTuple<NewA, NewB>> nextNodesTupleLifecycle, int outputStoreSize) {
super(mapStoreIndex, nextNodesTupleLifecycle, outputStoreSize);
this.mappingFunctionA = Objects.requireNonNull(mappingFunctionA);
this.mappingFunctionB = Objects.requireNonNull(mappingFunctionB);
}
@Override
protected BiTuple<NewA, NewB> map(BiTuple<A, B> tuple) {
A factA = tuple.factA;
B factB = tuple.factB;
return new BiTuple<>(
mappingFunctionA.apply(factA, factB),
mappingFunctionB.apply(factA, factB),
outputStoreSize);
}
@Override
protected void remap(BiTuple<A, B> inTuple, BiTuple<NewA, NewB> outTuple) {
A factA = inTuple.factA;
B factB = inTuple.factB;
NewA newA = mappingFunctionA.apply(factA, factB);
NewB newB = mappingFunctionB.apply(factA, factB);
outTuple.factA = newA;
outTuple.factB = newB;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/MapBiToQuadNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.Objects;
import java.util.function.BiFunction;
import ai.timefold.solver.core.impl.bavet.common.AbstractMapNode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.QuadTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
public final class MapBiToQuadNode<A, B, NewA, NewB, NewC, NewD>
extends AbstractMapNode<BiTuple<A, B>, QuadTuple<NewA, NewB, NewC, NewD>> {
private final BiFunction<A, B, NewA> mappingFunctionA;
private final BiFunction<A, B, NewB> mappingFunctionB;
private final BiFunction<A, B, NewC> mappingFunctionC;
private final BiFunction<A, B, NewD> mappingFunctionD;
public MapBiToQuadNode(int mapStoreIndex, BiFunction<A, B, NewA> mappingFunctionA, BiFunction<A, B, NewB> mappingFunctionB,
BiFunction<A, B, NewC> mappingFunctionC, BiFunction<A, B, NewD> mappingFunctionD,
TupleLifecycle<QuadTuple<NewA, NewB, NewC, NewD>> nextNodesTupleLifecycle, int outputStoreSize) {
super(mapStoreIndex, nextNodesTupleLifecycle, outputStoreSize);
this.mappingFunctionA = Objects.requireNonNull(mappingFunctionA);
this.mappingFunctionB = Objects.requireNonNull(mappingFunctionB);
this.mappingFunctionC = Objects.requireNonNull(mappingFunctionC);
this.mappingFunctionD = Objects.requireNonNull(mappingFunctionD);
}
@Override
protected QuadTuple<NewA, NewB, NewC, NewD> map(BiTuple<A, B> tuple) {
A factA = tuple.factA;
B factB = tuple.factB;
return new QuadTuple<>(
mappingFunctionA.apply(factA, factB),
mappingFunctionB.apply(factA, factB),
mappingFunctionC.apply(factA, factB),
mappingFunctionD.apply(factA, factB),
outputStoreSize);
}
@Override
protected void remap(BiTuple<A, B> inTuple, QuadTuple<NewA, NewB, NewC, NewD> outTuple) {
A factA = inTuple.factA;
B factB = inTuple.factB;
NewA newA = mappingFunctionA.apply(factA, factB);
NewB newB = mappingFunctionB.apply(factA, factB);
NewC newC = mappingFunctionC.apply(factA, factB);
NewD newD = mappingFunctionD.apply(factA, factB);
outTuple.factA = newA;
outTuple.factB = newB;
outTuple.factC = newC;
outTuple.factD = newD;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/MapBiToTriNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.Objects;
import java.util.function.BiFunction;
import ai.timefold.solver.core.impl.bavet.common.AbstractMapNode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TriTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
public final class MapBiToTriNode<A, B, NewA, NewB, NewC> extends AbstractMapNode<BiTuple<A, B>, TriTuple<NewA, NewB, NewC>> {
private final BiFunction<A, B, NewA> mappingFunctionA;
private final BiFunction<A, B, NewB> mappingFunctionB;
private final BiFunction<A, B, NewC> mappingFunctionC;
public MapBiToTriNode(int mapStoreIndex, BiFunction<A, B, NewA> mappingFunctionA, BiFunction<A, B, NewB> mappingFunctionB,
BiFunction<A, B, NewC> mappingFunctionC,
TupleLifecycle<TriTuple<NewA, NewB, NewC>> nextNodesTupleLifecycle, int outputStoreSize) {
super(mapStoreIndex, nextNodesTupleLifecycle, outputStoreSize);
this.mappingFunctionA = Objects.requireNonNull(mappingFunctionA);
this.mappingFunctionB = Objects.requireNonNull(mappingFunctionB);
this.mappingFunctionC = Objects.requireNonNull(mappingFunctionC);
}
@Override
protected TriTuple<NewA, NewB, NewC> map(BiTuple<A, B> tuple) {
A factA = tuple.factA;
B factB = tuple.factB;
return new TriTuple<>(
mappingFunctionA.apply(factA, factB),
mappingFunctionB.apply(factA, factB),
mappingFunctionC.apply(factA, factB),
outputStoreSize);
}
@Override
protected void remap(BiTuple<A, B> inTuple, TriTuple<NewA, NewB, NewC> outTuple) {
A factA = inTuple.factA;
B factB = inTuple.factB;
NewA newA = mappingFunctionA.apply(factA, factB);
NewB newB = mappingFunctionB.apply(factA, factB);
NewC newC = mappingFunctionC.apply(factA, factB);
outTuple.factA = newA;
outTuple.factB = newB;
outTuple.factC = newC;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/MapBiToUniNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.Objects;
import java.util.function.BiFunction;
import ai.timefold.solver.core.impl.bavet.common.AbstractMapNode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.bavet.common.tuple.UniTuple;
public final class MapBiToUniNode<A, B, NewA> extends AbstractMapNode<BiTuple<A, B>, UniTuple<NewA>> {
private final BiFunction<A, B, NewA> mappingFunction;
public MapBiToUniNode(int mapStoreIndex, BiFunction<A, B, NewA> mappingFunction,
TupleLifecycle<UniTuple<NewA>> nextNodesTupleLifecycle, int outputStoreSize) {
super(mapStoreIndex, nextNodesTupleLifecycle, outputStoreSize);
this.mappingFunction = Objects.requireNonNull(mappingFunction);
}
@Override
protected UniTuple<NewA> map(BiTuple<A, B> tuple) {
A factA = tuple.factA;
B factB = tuple.factB;
return new UniTuple<>(
mappingFunction.apply(factA, factB),
outputStoreSize);
}
@Override
protected void remap(BiTuple<A, B> inTuple, UniTuple<NewA> outTuple) {
A factA = inTuple.factA;
B factB = inTuple.factB;
NewA newA = mappingFunction.apply(factA, factB);
outTuple.factA = newA;
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/UnindexedIfExistsBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import ai.timefold.solver.core.api.function.TriPredicate;
import ai.timefold.solver.core.impl.bavet.common.AbstractUnindexedIfExistsNode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.bavet.common.tuple.UniTuple;
public final class UnindexedIfExistsBiNode<A, B, C> extends AbstractUnindexedIfExistsNode<BiTuple<A, B>, C> {
private final TriPredicate<A, B, C> filtering;
public UnindexedIfExistsBiNode(boolean shouldExist,
int inputStoreIndexLeftCounterEntry, int inputStoreIndexRightEntry,
TupleLifecycle<BiTuple<A, B>> nextNodesTupleLifecycle) {
this(shouldExist,
inputStoreIndexLeftCounterEntry, -1, inputStoreIndexRightEntry, -1,
nextNodesTupleLifecycle, null);
}
public UnindexedIfExistsBiNode(boolean shouldExist,
int inputStoreIndexLeftCounterEntry, int inputStoreIndexLeftTrackerList, int inputStoreIndexRightEntry,
int inputStoreIndexRightTrackerList,
TupleLifecycle<BiTuple<A, B>> nextNodesTupleLifecycle,
TriPredicate<A, B, C> filtering) {
super(shouldExist,
inputStoreIndexLeftCounterEntry, inputStoreIndexLeftTrackerList, inputStoreIndexRightEntry,
inputStoreIndexRightTrackerList,
nextNodesTupleLifecycle, filtering != null);
this.filtering = filtering;
}
@Override
protected boolean testFiltering(BiTuple<A, B> leftTuple, UniTuple<C> rightTuple) {
return filtering.test(leftTuple.factA, leftTuple.factB, rightTuple.factA);
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/UnindexedJoinBiNode.java | package ai.timefold.solver.core.impl.bavet.bi;
import java.util.function.BiPredicate;
import ai.timefold.solver.core.impl.bavet.common.AbstractUnindexedJoinNode;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.bavet.common.tuple.UniTuple;
public final class UnindexedJoinBiNode<A, B>
extends AbstractUnindexedJoinNode<UniTuple<A>, B, BiTuple<A, B>> {
private final BiPredicate<A, B> filtering;
private final int outputStoreSize;
public UnindexedJoinBiNode(
int inputStoreIndexLeftEntry, int inputStoreIndexLeftOutTupleList,
int inputStoreIndexRightEntry, int inputStoreIndexRightOutTupleList,
TupleLifecycle<BiTuple<A, B>> nextNodesTupleLifecycle, BiPredicate<A, B> filtering,
int outputStoreSize,
int outputStoreIndexLeftOutEntry, int outputStoreIndexRightOutEntry) {
super(inputStoreIndexLeftEntry, inputStoreIndexLeftOutTupleList,
inputStoreIndexRightEntry, inputStoreIndexRightOutTupleList,
nextNodesTupleLifecycle, filtering != null,
outputStoreIndexLeftOutEntry, outputStoreIndexRightOutEntry);
this.filtering = filtering;
this.outputStoreSize = outputStoreSize;
}
@Override
protected BiTuple<A, B> createOutTuple(UniTuple<A> leftTuple, UniTuple<B> rightTuple) {
return new BiTuple<>(leftTuple.factA, rightTuple.factA, outputStoreSize);
}
@Override
protected void setOutTupleLeftFacts(BiTuple<A, B> outTuple, UniTuple<A> leftTuple) {
outTuple.factA = leftTuple.factA;
}
@Override
protected void setOutTupleRightFact(BiTuple<A, B> outTuple, UniTuple<B> rightTuple) {
outTuple.factB = rightTuple.factA;
}
@Override
protected boolean testFiltering(UniTuple<A> leftTuple, UniTuple<B> rightTuple) {
return filtering.test(leftTuple.factA, rightTuple.factA);
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/joiner/BiJoinerComber.java | package ai.timefold.solver.core.impl.bavet.bi.joiner;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiPredicate;
import ai.timefold.solver.core.api.score.stream.bi.BiJoiner;
/**
* Combs an array of {@link BiJoiner} instances into a mergedJoiner and a mergedFiltering.
*
* @param <A>
* @param <B>
*/
public final class BiJoinerComber<A, B> {
public static <A, B> BiJoinerComber<A, B> comb(BiJoiner<A, B>[] joiners) {
List<DefaultBiJoiner<A, B>> defaultJoinerList = new ArrayList<>(joiners.length);
List<BiPredicate<A, B>> filteringList = new ArrayList<>(joiners.length);
int indexOfFirstFilter = -1;
// Make sure all indexing joiners, if any, come before filtering joiners. This is necessary for performance.
for (int i = 0; i < joiners.length; i++) {
BiJoiner<A, B> joiner = joiners[i];
if (joiner instanceof FilteringBiJoiner) {
// From now on, only allow filtering joiners.
indexOfFirstFilter = i;
filteringList.add(((FilteringBiJoiner<A, B>) joiner).getFilter());
} else if (joiner instanceof DefaultBiJoiner) {
if (indexOfFirstFilter >= 0) {
throw new IllegalStateException("Indexing joiner (" + joiner + ") must not follow " +
"a filtering joiner (" + joiners[indexOfFirstFilter] + ").\n" +
"Maybe reorder the joiners such that filtering() joiners are later in the parameter list.");
}
defaultJoinerList.add((DefaultBiJoiner<A, B>) joiner);
} else {
throw new IllegalArgumentException("The joiner class (" + joiner.getClass() + ") is not supported.");
}
}
DefaultBiJoiner<A, B> mergedJoiner = DefaultBiJoiner.merge(defaultJoinerList);
BiPredicate<A, B> mergedFiltering = mergeFiltering(filteringList);
return new BiJoinerComber<>(mergedJoiner, mergedFiltering);
}
private static <A, B> BiPredicate<A, B> mergeFiltering(List<BiPredicate<A, B>> filteringList) {
if (filteringList.isEmpty()) {
return null;
}
switch (filteringList.size()) {
case 1:
return filteringList.get(0);
case 2:
return filteringList.get(0).and(filteringList.get(1));
default:
// Avoid predicate.and() when more than 2 predicates for debugging and potentially performance
return (A a, B b) -> {
for (BiPredicate<A, B> predicate : filteringList) {
if (!predicate.test(a, b)) {
return false;
}
}
return true;
};
}
}
private DefaultBiJoiner<A, B> mergedJoiner;
private final BiPredicate<A, B> mergedFiltering;
public BiJoinerComber(DefaultBiJoiner<A, B> mergedJoiner, BiPredicate<A, B> mergedFiltering) {
this.mergedJoiner = mergedJoiner;
this.mergedFiltering = mergedFiltering;
}
/**
* @return never null
*/
public DefaultBiJoiner<A, B> getMergedJoiner() {
return mergedJoiner;
}
/**
* @return null if not applicable
*/
public BiPredicate<A, B> getMergedFiltering() {
return mergedFiltering;
}
public void addJoiner(DefaultBiJoiner<A, B> extraJoiner) {
mergedJoiner = mergedJoiner.and(extraJoiner);
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/joiner/DefaultBiJoiner.java | package ai.timefold.solver.core.impl.bavet.bi.joiner;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import ai.timefold.solver.core.api.score.stream.bi.BiJoiner;
import ai.timefold.solver.core.impl.bavet.common.joiner.AbstractJoiner;
import ai.timefold.solver.core.impl.bavet.common.joiner.JoinerType;
import org.jspecify.annotations.NonNull;
public final class DefaultBiJoiner<A, B> extends AbstractJoiner<B> implements BiJoiner<A, B> {
private static final DefaultBiJoiner NONE = new DefaultBiJoiner(new Function[0], new JoinerType[0], new Function[0]);
private final Function<A, ?>[] leftMappings;
public <Property_> DefaultBiJoiner(Function<A, Property_> leftMapping, JoinerType joinerType,
Function<B, Property_> rightMapping) {
super(rightMapping, joinerType);
this.leftMappings = new Function[] { leftMapping };
}
public <Property_> DefaultBiJoiner(Function<A, Property_>[] leftMappings, JoinerType[] joinerTypes,
Function<B, Property_>[] rightMappings) {
super(rightMappings, joinerTypes);
this.leftMappings = leftMappings;
}
public static <A, B> DefaultBiJoiner<A, B> merge(List<DefaultBiJoiner<A, B>> joinerList) {
if (joinerList.size() == 1) {
return joinerList.get(0);
}
return joinerList.stream().reduce(NONE, DefaultBiJoiner::and);
}
@Override
public @NonNull DefaultBiJoiner<A, B> and(@NonNull BiJoiner<A, B> otherJoiner) {
DefaultBiJoiner<A, B> castJoiner = (DefaultBiJoiner<A, B>) otherJoiner;
int joinerCount = getJoinerCount();
int castJoinerCount = castJoiner.getJoinerCount();
int newJoinerCount = joinerCount + castJoinerCount;
JoinerType[] newJoinerTypes = Arrays.copyOf(this.joinerTypes, newJoinerCount);
Function[] newLeftMappings = Arrays.copyOf(this.leftMappings, newJoinerCount);
Function[] newRightMappings = Arrays.copyOf(this.rightMappings, newJoinerCount);
for (int i = 0; i < castJoinerCount; i++) {
int newJoinerIndex = i + joinerCount;
newJoinerTypes[newJoinerIndex] = castJoiner.getJoinerType(i);
newLeftMappings[newJoinerIndex] = castJoiner.getLeftMapping(i);
newRightMappings[newJoinerIndex] = castJoiner.getRightMapping(i);
}
return new DefaultBiJoiner<>(newLeftMappings, newJoinerTypes, newRightMappings);
}
public Function<A, Object> getLeftMapping(int index) {
return (Function<A, Object>) leftMappings[index];
}
public boolean matches(A a, B b) {
int joinerCount = getJoinerCount();
for (int i = 0; i < joinerCount; i++) {
JoinerType joinerType = getJoinerType(i);
Object leftMapping = getLeftMapping(i).apply(a);
Object rightMapping = getRightMapping(i).apply(b);
if (!joinerType.matches(leftMapping, rightMapping)) {
return false;
}
}
return true;
}
@Override
public boolean equals(Object o) {
if (o instanceof DefaultBiJoiner<?, ?> other) {
return Arrays.equals(joinerTypes, other.joinerTypes)
&& Arrays.equals(leftMappings, other.leftMappings)
&& Arrays.equals(rightMappings, other.rightMappings);
}
return false;
}
@Override
public int hashCode() {
return Objects.hash(Arrays.hashCode(joinerTypes), Arrays.hashCode(leftMappings), Arrays.hashCode(rightMappings));
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/bi/joiner/FilteringBiJoiner.java | package ai.timefold.solver.core.impl.bavet.bi.joiner;
import java.util.Objects;
import java.util.function.BiPredicate;
import ai.timefold.solver.core.api.score.stream.bi.BiJoiner;
import org.jspecify.annotations.NonNull;
public final class FilteringBiJoiner<A, B> implements BiJoiner<A, B> {
private final BiPredicate<A, B> filter;
public FilteringBiJoiner(BiPredicate<A, B> filter) {
this.filter = filter;
}
@Override
public @NonNull FilteringBiJoiner<A, B> and(@NonNull BiJoiner<A, B> otherJoiner) {
FilteringBiJoiner<A, B> castJoiner = (FilteringBiJoiner<A, B>) otherJoiner;
return new FilteringBiJoiner<>(filter.and(castJoiner.getFilter()));
}
public BiPredicate<A, B> getFilter() {
return filter;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof FilteringBiJoiner)) {
return false;
}
FilteringBiJoiner<?, ?> other = (FilteringBiJoiner<?, ?>) o;
return Objects.equals(filter, other.filter);
}
@Override
public int hashCode() {
return Objects.hash(filter);
}
}
|
0 | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet | java-sources/ai/timefold/solver/timefold-solver-core/1.26.1/ai/timefold/solver/core/impl/bavet/common/AbstractConcatNode.java | package ai.timefold.solver.core.impl.bavet.common;
import ai.timefold.solver.core.impl.bavet.common.tuple.AbstractTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleState;
/**
* Implements the concat operation. Concat cannot be implemented as a pass-through operation because of two caveats:
*
* <ul>
* <li>It is possible to have the same {@link TupleSource} for both parent streams,
* in which case the exact same tuple can be inserted twice. Such a tuple
* should be counted twice downstream, and thus need to be cloned.
* </li>
*
* <li>Because concat has two parent nodes, it must be a {@link TupleSource} (since
* all nodes have exactly one {@link TupleSource}, and the source tuple can come from
* either parent). {@link TupleSource} must produce new tuples and not reuse them, since
* if tuples are reused, the stores inside them get corrupted.
* </li>
* </ul>
*
* The {@link AbstractConcatNode} works by creating a copy of the source tuple and putting it into
* the tuple's store. If the same tuple is inserted twice (i.e. when the left and right parent
* have the same {@link TupleSource}), it creates another clone.
*/
public abstract class AbstractConcatNode<LeftTuple_ extends AbstractTuple, RightTuple_ extends AbstractTuple, OutTuple_ extends AbstractTuple>
extends AbstractTwoInputNode<LeftTuple_, RightTuple_> {
private final int leftSourceTupleCloneStoreIndex;
private final int rightSourceTupleCloneStoreIndex;
protected final int outputStoreSize;
private final StaticPropagationQueue<OutTuple_> propagationQueue;
protected AbstractConcatNode(TupleLifecycle<OutTuple_> nextNodesTupleLifecycle,
int leftSourceTupleCloneStoreIndex,
int rightSourceTupleCloneStoreIndex,
int outputStoreSize) {
this.propagationQueue = new StaticPropagationQueue<>(nextNodesTupleLifecycle);
this.leftSourceTupleCloneStoreIndex = leftSourceTupleCloneStoreIndex;
this.rightSourceTupleCloneStoreIndex = rightSourceTupleCloneStoreIndex;
this.outputStoreSize = outputStoreSize;
}
protected abstract OutTuple_ getOutTupleFromLeft(LeftTuple_ leftTuple);
protected abstract OutTuple_ getOutTupleFromRight(RightTuple_ rightTuple);
protected abstract void updateOutTupleFromLeft(LeftTuple_ leftTuple, OutTuple_ outTuple);
protected abstract void updateOutTupleFromRight(RightTuple_ rightTuple, OutTuple_ outTuple);
@Override
public final void insertLeft(LeftTuple_ tuple) {
OutTuple_ outTuple = getOutTupleFromLeft(tuple);
tuple.setStore(leftSourceTupleCloneStoreIndex, outTuple);
propagationQueue.insert(outTuple);
}
@Override
public final void updateLeft(LeftTuple_ tuple) {
OutTuple_ outTuple = tuple.getStore(leftSourceTupleCloneStoreIndex);
if (outTuple == null) {
// No fail fast if null because we don't track which tuples made it through the filter predicate(s)
insertLeft(tuple);
return;
}
updateOutTupleFromLeft(tuple, outTuple);
// Even if the facts of tuple do not change, an update MUST be done so
// downstream nodes get notified of updates in planning variables.
TupleState previousState = outTuple.state;
if (previousState == TupleState.CREATING || previousState == TupleState.UPDATING) {
return;
}
propagationQueue.update(outTuple);
}
@Override
public final void retractLeft(LeftTuple_ tuple) {
OutTuple_ outTuple = tuple.getStore(leftSourceTupleCloneStoreIndex);
if (outTuple == null) {
// No fail fast if null because we don't track which tuples made it through the filter predicate(s)
return;
}
TupleState state = outTuple.state;
if (!state.isActive()) {
// No fail fast for inactive tuples, since the same tuple can be
// passed twice if they are from the same source;
// @see BavetRegressionTest#concatSameTupleDeadAndAlive for an example.
return;
}
propagationQueue.retract(outTuple, state == TupleState.CREATING ? TupleState.ABORTING : TupleState.DYING);
}
@Override
public final void insertRight(RightTuple_ tuple) {
OutTuple_ outTuple = getOutTupleFromRight(tuple);
tuple.setStore(rightSourceTupleCloneStoreIndex, outTuple);
propagationQueue.insert(outTuple);
}
@Override
public final void updateRight(RightTuple_ tuple) {
OutTuple_ outTuple = tuple.getStore(rightSourceTupleCloneStoreIndex);
if (outTuple == null) {
// No fail fast if null because we don't track which tuples made it through the filter predicate(s)
insertRight(tuple);
return;
}
updateOutTupleFromRight(tuple, outTuple);
// Even if the facts of tuple do not change, an update MUST be done so
// downstream nodes get notified of updates in planning variables.
TupleState previousState = outTuple.state;
if (previousState == TupleState.CREATING || previousState == TupleState.UPDATING) {
return;
}
propagationQueue.update(outTuple);
}
@Override
public final void retractRight(RightTuple_ tuple) {
OutTuple_ outTuple = tuple.getStore(rightSourceTupleCloneStoreIndex);
if (outTuple == null) {
// No fail fast if null because we don't track which tuples made it through the filter predicate(s)
return;
}
TupleState state = outTuple.state;
if (!state.isActive()) {
// No fail fast for inactive tuples, since the same tuple can be
// passed twice if they are from the same source;
// @see BavetRegressionTest#concatSameTupleDeadAndAlive for an example.
return;
}
propagationQueue.retract(outTuple, state == TupleState.CREATING ? TupleState.ABORTING : TupleState.DYING);
}
@Override
public Propagator getPropagator() {
return propagationQueue;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.