1 package it.unical.mat.embasp.languages.asp;
3 import java.util.ArrayList;
4 import java.util.Collections;
7 import it.unical.mat.embasp.base.Output;
8 import it.unical.mat.parsers.asp.ASPDataCollection;
20 public AnswerSets(
final String out,
final String err) {
25 public Object clone() throws CloneNotSupportedException {
29 public List<AnswerSet> getAnswersets() {
35 return Collections.unmodifiableList(
answersets);
38 public List<AnswerSet> getOptimalAnswerSets() {
40 List <AnswerSet> answerSets = getAnswersets(), optimalAnswerSets =
new ArrayList <> ();
42 for(
final AnswerSet answerSet : answerSets) {
43 final int maxLevel = Collections.max(answerSet.getWeights().keySet());
49 for(; level >= 1; level--) {
50 int minimumCost = Integer.MAX_VALUE;
52 for(
final AnswerSet answerSet : answerSets) {
53 final int cost = answerSet.getWeights().getOrDefault(level, 0);
55 if(cost < minimumCost) {
56 optimalAnswerSets.clear();
61 if(cost == minimumCost)
62 optimalAnswerSets.add(answerSet);
65 answerSets =
new ArrayList <> (optimalAnswerSets);
68 return optimalAnswerSets;
71 public String getAnswerSetsString() {
76 public void addAnswerSet() {
77 answersets.add(
new AnswerSet(
new ArrayList <String> ()));
81 public void storeAtom(
final String result) {
86 public void storeCost(
final int level,
final int weight) {