Ejemplo n.º 1
0
 public boolean isMoveDoable(ScoreDirector scoreDirector) {
   Object leftValue = variableDescriptor.getValue(leftEntity);
   Object rightEntity = inverseVariableSupply.getInverseSingleton(rightValue);
   if (ObjectUtils.equals(leftValue, rightValue)
       || ObjectUtils.equals(leftEntity, rightValue)
       || ObjectUtils.equals(rightEntity, leftValue)) {
     return false;
   }
   if (rightEntity == null) {
     Object leftAnchor = anchorVariableSupply.getAnchor(leftEntity);
     Object rightAnchor = determineRightAnchor();
     // TODO Currently unsupported because we fail to create a valid undoMove... even though doMove
     // supports it
     if (leftAnchor == rightAnchor) {
       return false;
     }
   }
   if (!variableDescriptor.isValueRangeEntityIndependent()) {
     ValueRangeDescriptor valueRangeDescriptor = variableDescriptor.getValueRangeDescriptor();
     Solution workingSolution = scoreDirector.getWorkingSolution();
     if (rightEntity != null) {
       ValueRange rightValueRange =
           valueRangeDescriptor.extractValueRange(workingSolution, rightEntity);
       if (!rightValueRange.contains(leftValue)) {
         return false;
       }
     }
     ValueRange leftValueRange =
         valueRangeDescriptor.extractValueRange(workingSolution, leftEntity);
     if (!leftValueRange.contains(rightValue)) {
       return false;
     }
   }
   return true;
 }
Ejemplo n.º 2
0
 public Iterator<?> iterator(Object entity) {
   if (cachedPlanningValues != null) {
     return cachedPlanningValues.iterator();
   } else {
     CountableValueRange<?> valueRange =
         (CountableValueRange<?>)
             valueRangeDescriptor.extractValueRange(scoreDirector.getWorkingSolution(), entity);
     List<?> values = Lists.newArrayList(valueRange.createOriginalIterator());
     return values.iterator();
   }
 }
Ejemplo n.º 3
0
 private void initSelectedPlanningValueList(AbstractSolverPhaseScope phaseScope) {
   if (valueRangeDescriptor.isEntityIndependent()) {
     CountableValueRange<?> valueRange =
         (CountableValueRange<?>)
             ((EntityIndependentValueRangeDescriptor) valueRangeDescriptor)
                 .extractValueRange(phaseScope.getWorkingSolution());
     cachedPlanningValues = Lists.newArrayList(valueRange.createOriginalIterator());
   } else {
     cachedPlanningValues = null;
   }
 }