@Override public ViolationFixes fixViolations(ISelection selection) { TemporalNetworkMember networkMember = TemporalNetworkMember.get(plan); if (networkMember.isConsistent()) { return getSolvedFixes(selection); } Logger.getLogger(ConstraintsPlanAdvisor.class) .debug("using simple fix violations when network is inconsistent."); return getSimpleFixes(selection); }
/* (non-Javadoc) * @see gov.nasa.ensemble.core.plan.constraints.advisor.IConstraintNetworkAdvisor#areViolationsFixable() */ @Override public boolean areViolationsFixable() { TemporalNetworkMember networkMember = TemporalNetworkMember.get(plan); return networkMember.isConsistent(); }
private List<Violation> findViolations(Collection<EPlanElement> elements) { if (!ConstraintsPreferences.isFindTemporalViolations()) { return Collections.emptyList(); } // collect things that could be violated Set<BinaryTemporalConstraint> relations = new LinkedHashSet<BinaryTemporalConstraint>(); List<PeriodicTemporalConstraint> bounds = new ArrayList<PeriodicTemporalConstraint>(); LinkedHashSet<TemporalChain> chains = TemporalChainUtils.getChains(elements, false); for (EPlanElement element : elements) { relations.addAll(ConstraintUtils.getBinaryConstraints(element, false)); bounds.addAll(ConstraintUtils.getPeriodicConstraints(element, false)); } // find the violations List<Violation> violations = new ArrayList<Violation>(); for (BinaryTemporalConstraint relation : relations) { if (relation.isViolated()) { violations.add(new TemporalDistanceViolation(this, this, relation)); } } for (PeriodicTemporalConstraint bound : bounds) { if (bound.isViolated()) { violations.add(new TemporalEndpointViolation(this, this, bound)); } } for (TemporalChain chain : chains) { EPlanElement lastPlanElement = null; TemporalExtent lastExtent = null; for (EPlanElement planElement : chain.getElements()) { if (planElement == null) { continue; } if (SpifePlanUtils.getScheduled(planElement) == TriState.FALSE) { continue; } TemporalExtent extent = planElement.getMember(TemporalMember.class).getExtent(); if (extent == null) { continue; } if (lastExtent != null) { if (TemporalChainLinkViolation.isViolated(lastExtent.getEnd(), extent.getStart())) { violations.add( new TemporalChainLinkViolation( this, this, lastPlanElement, lastExtent, planElement, extent)); } } lastPlanElement = planElement; lastExtent = extent; } } TemporalNetworkMember<?> networkMember = TemporalNetworkMember.get(plan); if (networkMember.isConsistent()) { this.nogoodParts = Collections.emptySet(); } else { Set<INogoodPart> parts = networkMember.getNogoodParts(); for (INogoodPart part : parts) { violations.add(new NogoodViolation(this, part)); } this.nogoodParts = parts; } return violations; }