-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
918 additions
and
18 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
core/src/main/java/ai/timefold/solver/core/api/move/BiMoveConstructor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package ai.timefold.solver.core.api.move; | ||
|
||
@FunctionalInterface | ||
public non-sealed interface BiMoveConstructor<Solution_, A, B> | ||
extends MoveConstructor<Solution_> { | ||
|
||
Move<Solution_> apply(A a, B b); | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
core/src/main/java/ai/timefold/solver/core/api/move/Dataset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package ai.timefold.solver.core.api.move; | ||
|
||
public interface Dataset<Solution_, A> { | ||
} |
38 changes: 38 additions & 0 deletions
38
core/src/main/java/ai/timefold/solver/core/api/move/Datasets.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package ai.timefold.solver.core.api.move; | ||
|
||
import java.util.Collection; | ||
|
||
import org.jspecify.annotations.NonNull; | ||
|
||
public interface Datasets<Solution_> { | ||
|
||
/** | ||
* Create a cached stream of all possible values of a class. | ||
* Read from the planning solution. | ||
* | ||
* @param clz | ||
* @return | ||
* @param <A> | ||
*/ | ||
<A> @NonNull Dataset<Solution_, A> enumerate(@NonNull Class<A> clz); | ||
|
||
/** | ||
* Create a cached stream of arbitrary values. | ||
* Read from the planning solution. | ||
* | ||
* @param extractor | ||
* @param <A> | ||
* @return | ||
*/ | ||
<A> @NonNull Dataset<Solution_, A> enumerate(@NonNull SolutionExtractor<Solution_, A> extractor); | ||
|
||
/** | ||
* Create a cached stream of arbitrary values. | ||
* | ||
* @param collection | ||
* @param <A> | ||
* @return | ||
*/ | ||
<A> @NonNull Dataset<Solution_, A> enumerate(@NonNull Collection<A> collection); | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
core/src/main/java/ai/timefold/solver/core/api/move/MoveConstructor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package ai.timefold.solver.core.api.move; | ||
|
||
public sealed interface MoveConstructor<Solution_> permits BiMoveConstructor { | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
core/src/main/java/ai/timefold/solver/core/api/move/MoveProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package ai.timefold.solver.core.api.move; | ||
|
||
import java.util.function.BiFunction; | ||
|
||
@FunctionalInterface | ||
public interface MoveProvider<Solution_> | ||
extends BiFunction<Datasets<Solution_>, Picker<Solution_>, MoveConstructor<Solution_>> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
core/src/main/java/ai/timefold/solver/core/api/move/Picker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package ai.timefold.solver.core.api.move; | ||
|
||
public interface Picker<Solution_> { | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
core/src/main/java/ai/timefold/solver/core/api/move/SolutionExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package ai.timefold.solver.core.api.move; | ||
|
||
import java.util.Collection; | ||
import java.util.function.BiFunction; | ||
|
||
@FunctionalInterface | ||
public interface SolutionExtractor<Solution_, A> | ||
extends BiFunction<SolutionView<Solution_>, Solution_, Collection<A>> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
core/src/main/java/ai/timefold/solver/core/impl/move/dataset/InnerUniDataset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package ai.timefold.solver.core.impl.move.dataset; | ||
|
||
import java.util.List; | ||
|
||
import ai.timefold.solver.core.api.move.Dataset; | ||
import ai.timefold.solver.core.api.move.SolutionView; | ||
|
||
public interface InnerUniDataset<Solution_, A> | ||
extends Dataset<Solution_, A> { | ||
|
||
void resetWorkingSolution(SolutionView<Solution_> solutionView, Solution_ workingSolution); | ||
|
||
void add(A value); | ||
|
||
void remove(A value); | ||
|
||
void update(A value); | ||
|
||
void fix(); | ||
|
||
List<A> values(); | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
.../src/main/java/ai/timefold/solver/core/impl/move/dataset/UniSolutionBasedDatasetImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package ai.timefold.solver.core.impl.move.dataset; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import ai.timefold.solver.core.api.move.SolutionExtractor; | ||
import ai.timefold.solver.core.api.move.SolutionView; | ||
|
||
public final class UniSolutionBasedDatasetImpl<Solution_, A> implements InnerUniDataset<Solution_, A> { | ||
|
||
private final SolutionExtractor<Solution_, A> extractor; | ||
private List<A> values = Collections.emptyList(); | ||
|
||
public UniSolutionBasedDatasetImpl(SolutionExtractor<Solution_, A> extractor) { | ||
this.extractor = Objects.requireNonNull(extractor); | ||
} | ||
|
||
@Override | ||
public void resetWorkingSolution(SolutionView<Solution_> solutionView, Solution_ workingSolution) { | ||
this.values = extractor.apply(solutionView, workingSolution) | ||
.stream() | ||
.distinct() | ||
.toList(); | ||
} | ||
|
||
@Override | ||
public void add(A value) { | ||
// Do nothing. | ||
} | ||
|
||
@Override | ||
public void remove(A value) { | ||
// Do nothing. | ||
} | ||
|
||
@Override | ||
public void update(A value) { | ||
// Do nothing. | ||
} | ||
|
||
@Override | ||
public void fix() { | ||
// Do nothing. | ||
} | ||
|
||
@Override | ||
public List<A> values() { | ||
return values; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
core/src/main/java/ai/timefold/solver/core/impl/move/dataset/UniStaticDatasetImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package ai.timefold.solver.core.impl.move.dataset; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import ai.timefold.solver.core.api.move.SolutionView; | ||
|
||
public final class UniStaticDatasetImpl<Solution_, A> implements InnerUniDataset<Solution_, A> { | ||
|
||
private final List<A> values; | ||
|
||
public UniStaticDatasetImpl(Collection<A> values) { | ||
this.values = Objects.requireNonNull(values) | ||
.stream() | ||
.distinct() | ||
.toList(); | ||
} | ||
|
||
@Override | ||
public void resetWorkingSolution(SolutionView<Solution_> solutionView, Solution_ workingSolution) { | ||
// Do nothing. | ||
} | ||
|
||
@Override | ||
public void add(A value) { | ||
// Do nothing. | ||
} | ||
|
||
@Override | ||
public void remove(A value) { | ||
// Do nothing. | ||
} | ||
|
||
@Override | ||
public void update(A value) { | ||
// Do nothing. | ||
} | ||
|
||
@Override | ||
public void fix() { | ||
// Do nothing. | ||
} | ||
|
||
@Override | ||
public List<A> values() { | ||
return values; | ||
} | ||
} |
Oops, something went wrong.