Skip to content

Commit

Permalink
PLANNER-567 Improve error message by mentioning the user's variableLi…
Browse files Browse the repository at this point in the history
…stener class by name.
  • Loading branch information
ge0ffrey committed Apr 22, 2016
1 parent 210d7bf commit f584fcc
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 7 deletions.
Expand Up @@ -91,7 +91,6 @@ public void solve(DefaultSolverScope<Solution_> solverScope) {
}

private void doStep(ConstructionHeuristicStepScope<Solution_> stepScope) {
ConstructionHeuristicPhaseScope<Solution_> phaseScope = stepScope.getPhaseScope();
Move nextStep = stepScope.getStep();
nextStep.doMove(stepScope.getScoreDirector());
predictWorkingStepScore(stepScope, nextStep);
Expand Down
Expand Up @@ -51,7 +51,7 @@ public void processAnnotations(DescriptorPolicy descriptorPolicy) {
}

private void processPropertyAnnotations(DescriptorPolicy descriptorPolicy) {

// Do nothing
}

@Override
Expand Down Expand Up @@ -84,6 +84,11 @@ public List<VariableDescriptor<Solution_>> getSourceVariableDescriptorList() {
return Collections.singletonList(sourceVariableDescriptor);
}

@Override
public Class<? extends VariableListener> getVariableListenerClass() {
return AnchorVariableListener.class;
}

// ************************************************************************
// Worker methods
// ************************************************************************
Expand Down
Expand Up @@ -191,6 +191,11 @@ public List<VariableDescriptor<Solution_>> getSourceVariableDescriptorList() {
return sourceVariableDescriptorList;
}

@Override
public Class<? extends VariableListener> getVariableListenerClass() {
return variableListenerClass;
}

// ************************************************************************
// Worker methods
// ************************************************************************
Expand All @@ -206,7 +211,7 @@ public boolean hasVariableListener(InnerScoreDirector scoreDirector) {
}

@Override
public VariableListener buildVariableListener(InnerScoreDirector scoreDirector) {
public VariableListener<Solution_> buildVariableListener(InnerScoreDirector<Solution_> scoreDirector) {
if (refVariableDescriptor != null) {
throw new IllegalStateException("The shadowVariableDescriptor (" + this
+ ") references another shadowVariableDescriptor (" + refVariableDescriptor
Expand Down
Expand Up @@ -56,6 +56,8 @@ public void setGlobalShadowOrder(int globalShadowOrder) {
this.globalShadowOrder = globalShadowOrder;
}

public abstract Class<? extends VariableListener> getVariableListenerClass();

// ************************************************************************
// Worker methods
// ************************************************************************
Expand Down
Expand Up @@ -53,7 +53,7 @@ public void processAnnotations(DescriptorPolicy descriptorPolicy) {
}

private void processPropertyAnnotations(DescriptorPolicy descriptorPolicy) {

// Do nothing
}

@Override
Expand Down Expand Up @@ -145,6 +145,15 @@ public List<VariableDescriptor<Solution_>> getSourceVariableDescriptorList() {
return Collections.singletonList(sourceVariableDescriptor);
}

@Override
public Class<? extends VariableListener> getVariableListenerClass() {
if (singleton) {
return SingletonInverseVariableListener.class;
} else {
return CollectionInverseVariableListener.class;
}
}

// ************************************************************************
// Worker methods
// ************************************************************************
Expand Down
Expand Up @@ -88,7 +88,6 @@ public void solve(DefaultSolverScope<Solution_> solverScope) {
}

private void doStep(LocalSearchStepScope<Solution_> stepScope) {
LocalSearchPhaseScope<Solution_> phaseScope = stepScope.getPhaseScope();
Move nextStep = stepScope.getStep();
nextStep.doMove(stepScope.getScoreDirector());
predictWorkingStepScore(stepScope, nextStep);
Expand Down
Expand Up @@ -384,8 +384,9 @@ public void assertShadowVariablesAreNotStale(Score expectedWorkingScore, Object
+ ")'s shadow variable (" + shadowVariableDescriptor.getSimpleEntityAndVariableName()
+ ")'s corrupted value (" + originalValue + ") changed to uncorrupted value (" + newValue
+ ") after all " + VariableListener.class.getSimpleName() + "s were triggered without changes to the genuine variables.\n"
+ "Probably the " + VariableListener.class.getSimpleName()
+ " class for that shadow variable (" + shadowVariableDescriptor.getSimpleEntityAndVariableName()
+ "Probably the " + VariableListener.class.getSimpleName() + " class ("
+ shadowVariableDescriptor.getVariableListenerClass().getSimpleName()
+ ") for that shadow variable (" + shadowVariableDescriptor.getSimpleEntityAndVariableName()
+ ") forgot to update it when one of its sources changed"
+ " after completedAction (" + completedAction + ").");
}
Expand Down

0 comments on commit f584fcc

Please sign in to comment.