| Total Complexity | 4 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | package it.cnr.istc.pst.platinum.ai.deliberative.heuristic; |
||
| 16 | public class CompleteFlawSelectionHeuristic extends FlawSelectionHeuristic |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * |
||
| 20 | */ |
||
| 21 | protected CompleteFlawSelectionHeuristic() { |
||
| 22 | super("RandomFlawSelectionHeuristic"); |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * |
||
| 27 | */ |
||
| 28 | @Override |
||
| 29 | public Set<Flaw> choose() |
||
| 30 | throws UnsolvableFlawException, NoFlawFoundException { |
||
| 31 | |||
| 32 | // detect flaws |
||
| 33 | List<Flaw> flaws = this.pdb.detectFlaws(); |
||
| 34 | // check flaws found |
||
| 35 | if (flaws.isEmpty()) { |
||
| 36 | // throw exception |
||
| 37 | throw new NoFlawFoundException("No flaw has been found in the current plan"); |
||
| 38 | } |
||
| 39 | |||
| 40 | // consider all flaws for plan refinement |
||
| 41 | return new HashSet<>(flaws); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * |
||
| 46 | */ |
||
| 47 | @Override |
||
| 48 | public Set<Flaw> check() { |
||
| 49 | // check flaws |
||
| 50 | return new HashSet<>(this.pdb.checkFlaws()); |
||
| 51 | } |
||
| 55 |