File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
core/src/test/java/ai/timefold/solver/core/testdomain Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ package ai .timefold .solver .core .testdomain ;
2
+
3
+ import ai .timefold .solver .core .impl .heuristic .selector .common .nearby .NearbyDistanceMeter ;
4
+
5
+ public class TestdataObjectDistanceMeter <T extends TestdataObject > implements NearbyDistanceMeter <T , TestdataObject > {
6
+
7
+ @ Override
8
+ public double getNearbyDistance (T origin , TestdataObject destination ) {
9
+ return Math .abs (coordinate (destination ) - coordinate (origin ));
10
+ }
11
+
12
+ static int coordinate (TestdataObject o ) {
13
+ try {
14
+ return Integer .parseInt (o .getCode ());
15
+ } catch (NumberFormatException e ) {
16
+ return 0 ;
17
+ }
18
+ }
19
+ }
Original file line number Diff line number Diff line change 17
17
import ai .timefold .solver .core .impl .domain .entity .descriptor .EntityDescriptor ;
18
18
import ai .timefold .solver .core .impl .domain .solution .descriptor .SolutionDescriptor ;
19
19
import ai .timefold .solver .core .impl .domain .valuerange .descriptor .ValueRangeDescriptor ;
20
+ import ai .timefold .solver .core .impl .domain .variable .descriptor .BasicVariableDescriptor ;
20
21
import ai .timefold .solver .core .impl .domain .variable .descriptor .ListVariableDescriptor ;
21
22
import ai .timefold .solver .core .impl .heuristic .HeuristicConfigPolicy ;
22
23
import ai .timefold .solver .core .impl .heuristic .selector .SelectorTestUtils ;
@@ -252,6 +253,16 @@ public static <Solution_> ListVariableDescriptor<Solution_> getListVariableDescr
252
253
.getGenuineVariableDescriptor ("valueList" );
253
254
}
254
255
256
+ public static <Solution_ > BasicVariableDescriptor <Solution_ > getBasicVariableDescriptor (
257
+ InnerScoreDirector <Solution_ , ?> scoreDirector ) {
258
+ return (BasicVariableDescriptor <Solution_ >) scoreDirector
259
+ .getSolutionDescriptor ()
260
+ .getGenuineEntityDescriptors ()
261
+ .iterator ()
262
+ .next ()
263
+ .getGenuineVariableDescriptor ("value" );
264
+ }
265
+
255
266
public static <Solution_ > EntityDescriptor <Solution_ > getEntityDescriptor (
256
267
InnerScoreDirector <Solution_ , ?> scoreDirector ) {
257
268
return scoreDirector
You can’t perform that action at this time.
0 commit comments