Skip to content

Commit 78458bf

Browse files
committed
chore: address more comments
1 parent 3a178d5 commit 78458bf

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

core/src/main/java/ai/timefold/solver/core/impl/domain/variable/descriptor/ShadowVariableDescriptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public boolean hasVariableListener() {
6565
}
6666

6767
/**
68-
* return true if the source variable is a basic variable; otherwise, return false.
68+
* return true if the source variable is a list variable; otherwise, return false.
6969
*/
7070
public abstract boolean isListVariableSource();
7171

core/src/test/java/ai/timefold/solver/core/impl/constructionheuristic/DefaultConstructionHeuristicPhaseTest.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,9 @@ void solvePinnedAndUnassignedWithListAndBasicVariables() {
490490
.withTerminationConfig(new TerminationConfig().withStepCountLimit(16)))
491491
.withEasyScoreCalculatorClass(TestdataUnassignedListMultiVarEasyScoreCalculator.class);
492492

493+
// Pin the entire first entity
493494
var problem = TestdataUnassignedListMultiVarSolution.generateUninitializedSolution(2, 2, 2);
494-
// Pin the first entity
495495
problem.getEntityList().get(0).setPinned(true);
496-
problem.getEntityList().get(0).setPinnedIndex(0);
497496
problem.getEntityList().get(0).setBasicValue(problem.getOtherValueList().get(0));
498497
problem.getEntityList().get(0).setSecondBasicValue(problem.getOtherValueList().get(0));
499498
problem.getEntityList().get(0).setValueList(List.of(problem.getValueList().get(0)));
@@ -510,6 +509,29 @@ void solvePinnedAndUnassignedWithListAndBasicVariables() {
510509
assertThat(solution.getEntityList().get(1).getBasicValue()).isNull();
511510
assertThat(solution.getEntityList().get(1).getSecondBasicValue()).isNotNull();
512511
assertThat(solution.getEntityList().get(1).getValueList()).isEmpty();
512+
513+
// Pin partially the first entity list
514+
problem = TestdataUnassignedListMultiVarSolution.generateUninitializedSolution(2, 3, 2);
515+
problem.getEntityList().get(0).setPinnedIndex(2);
516+
problem.getEntityList().get(0).setBasicValue(problem.getOtherValueList().get(0));
517+
problem.getEntityList().get(0).setSecondBasicValue(problem.getOtherValueList().get(0));
518+
problem.getEntityList().get(0).setValueList(problem.getValueList().subList(1, 3));
519+
// Block values and make the basic variable unassigned
520+
problem.getOtherValueList().get(0).setBlocked(true);
521+
problem.getOtherValueList().get(1).setBlocked(true);
522+
solution = PlannerTestUtils.solve(solverConfig, problem);
523+
// The basic value is set to null because the entire entity is not fixed.
524+
assertThat(solution.getEntityList().get(0).getBasicValue()).isNull();
525+
assertThat(solution.getEntityList().get(0).getSecondBasicValue()).isNotNull();
526+
assertThat(solution.getEntityList().get(0).getValueList()).hasSize(3);
527+
// The pinning index fixed the values 1 and 2. The only remaining option is value 0.
528+
assertThat(solution.getEntityList().get(0).getValueList())
529+
.hasSameElementsAs(
530+
List.of(problem.getValueList().get(1), problem.getValueList().get(2), problem.getValueList().get(0)));
531+
assertThat(solution.getEntityList().get(1).getBasicValue()).isNull();
532+
assertThat(solution.getEntityList().get(1).getSecondBasicValue()).isNotNull();
533+
assertThat(solution.getEntityList().get(1).getValueList()).isEmpty();
534+
513535
}
514536

515537
@Test

0 commit comments

Comments
 (0)