[1] | 1 | package genius.gui.uncertainty;
|
---|
| 2 |
|
---|
[66] | 3 | import java.util.stream.IntStream;
|
---|
| 4 |
|
---|
[1] | 5 | import javax.swing.JOptionPane;
|
---|
| 6 |
|
---|
| 7 | import genius.core.boaframework.SortedOutcomeSpace;
|
---|
| 8 | import genius.core.listener.Listener;
|
---|
| 9 | import genius.core.repository.ProfileRepItem;
|
---|
| 10 | import genius.core.uncertainty.UNCERTAINTYTYPE;
|
---|
| 11 | import genius.core.uncertainty.UncertainPreferenceContainer;
|
---|
| 12 | import genius.core.utility.AbstractUtilitySpace;
|
---|
[78] | 13 | import genius.core.utility.UncertainAdditiveUtilitySpace;
|
---|
[1] | 14 | import genius.gui.panels.BooleanModel;
|
---|
| 15 | import genius.gui.panels.TextModel;
|
---|
| 16 |
|
---|
[78] | 17 | public class PairwiseComparisonModel {
|
---|
[1] | 18 |
|
---|
[66] | 19 | private ProfileRepItem profile;
|
---|
[1] | 20 |
|
---|
[66] | 21 | private TextModel errorModel = new TextModel("0.0");
|
---|
[1] | 22 |
|
---|
[66] | 23 | private int numberOfComparisons;
|
---|
| 24 | private final int maxNumberOfComparisons;
|
---|
| 25 |
|
---|
| 26 | private BooleanModel experimentalModel = new BooleanModel(true);
|
---|
| 27 | private BooleanModel confirmationModel = new BooleanModel(false);
|
---|
| 28 |
|
---|
| 29 | private UncertainPreferenceContainer uncertainPrefContainer = null;
|
---|
| 30 |
|
---|
[78] | 31 | public PairwiseComparisonModel(ProfileRepItem profile) {
|
---|
[1] | 32 | this.profile = profile;
|
---|
[65] | 33 | this.maxNumberOfComparisons = calculateMaxNumberOfComparisons();
|
---|
[1] | 34 | connect();
|
---|
| 35 | }
|
---|
[66] | 36 |
|
---|
[78] | 37 | private int calculateMaxNumberOfComparisons() {
|
---|
| 38 | SortedOutcomeSpace realSortedOutcomeSpace = new SortedOutcomeSpace(
|
---|
| 39 | (AbstractUtilitySpace) profile.create());
|
---|
[66] | 40 | return realSortedOutcomeSpace.getAllOutcomes().size() - 1;
|
---|
[1] | 41 | }
|
---|
[78] | 42 |
|
---|
[66] | 43 | /**
|
---|
| 44 | * All possible values the "number of comparisons" slider can take.
|
---|
| 45 | */
|
---|
[78] | 46 | public Integer[] getPossibleValues() {
|
---|
[66] | 47 | if (maxNumberOfComparisons <= 10)
|
---|
[78] | 48 | return (Integer[]) IntStream.rangeClosed(1, maxNumberOfComparisons)
|
---|
| 49 | .boxed().toArray();
|
---|
[66] | 50 | else if (maxNumberOfComparisons <= 100)
|
---|
[78] | 51 | return new Integer[] { 1, 5, 10, maxNumberOfComparisons };
|
---|
[66] | 52 | else
|
---|
[78] | 53 | return new Integer[] { 1, 5, 10, 50, 100, maxNumberOfComparisons };
|
---|
[66] | 54 | }
|
---|
| 55 |
|
---|
[1] | 56 | public void connect() {
|
---|
[66] | 57 |
|
---|
[78] | 58 | confirmationModel.addListener(new Listener<Boolean>() {
|
---|
[1] | 59 | @Override
|
---|
| 60 | public void notifyChange(Boolean data) {
|
---|
| 61 | if (confirmationModel.getValue() == true) {
|
---|
| 62 | uncertainPrefContainer = createContainer();
|
---|
[78] | 63 | int amountOfComps = uncertainPrefContainer
|
---|
| 64 | .getPairwiseCompUserModel().getBidRanking()
|
---|
| 65 | .getBidOrder().size() - 1;
|
---|
| 66 | double certaintyLevel = ((double) amountOfComps
|
---|
| 67 | / (double) getMaxNumberInComps());
|
---|
| 68 | double errorRate = Double
|
---|
| 69 | .parseDouble(getErrorModel().getText()) * 100;
|
---|
[66] | 70 |
|
---|
[78] | 71 | JOptionPane.showMessageDialog(null,
|
---|
| 72 | "Pairwise Comparison User Model Created Successfully! \n\n"
|
---|
| 73 | + "Number of Comparisons: " + amountOfComps
|
---|
| 74 | + "\n" + "Level Of certainty: "
|
---|
| 75 | + (Math.round((certaintyLevel) * 100)
|
---|
| 76 | / 100D) * 100
|
---|
| 77 | + "%\n" + "Error Rate: "
|
---|
| 78 | + (Math.round((errorRate) * 100) / 100D)
|
---|
| 79 | + "%");
|
---|
[1] | 80 | }
|
---|
| 81 | }
|
---|
[78] | 82 | });
|
---|
| 83 | }
|
---|
[66] | 84 |
|
---|
[1] | 85 | public ProfileRepItem getProfile() {
|
---|
| 86 | return profile;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
[78] | 89 | public UncertainPreferenceContainer createContainer() {
|
---|
| 90 | UncertainPreferenceContainer container;
|
---|
| 91 | container = new UncertainPreferenceContainer(
|
---|
| 92 | (UncertainAdditiveUtilitySpace) profile.create(),
|
---|
| 93 | UNCERTAINTYTYPE.PAIRWISECOMP);
|
---|
[1] | 94 | return container;
|
---|
| 95 | }
|
---|
[66] | 96 |
|
---|
[1] | 97 | public TextModel getErrorModel() {
|
---|
| 98 | return errorModel;
|
---|
| 99 | }
|
---|
[78] | 100 |
|
---|
[43] | 101 | public int getMaxNumberInComps() {
|
---|
[65] | 102 | return maxNumberOfComparisons;
|
---|
[1] | 103 | }
|
---|
[78] | 104 |
|
---|
[1] | 105 | public BooleanModel getConfirmationModel() {
|
---|
| 106 | return confirmationModel;
|
---|
| 107 | }
|
---|
[78] | 108 |
|
---|
[1] | 109 | public UncertainPreferenceContainer getUncertainPrefContainer() {
|
---|
| 110 | return uncertainPrefContainer;
|
---|
| 111 | }
|
---|
[78] | 112 |
|
---|
[1] | 113 | public BooleanModel getExperimentalModel() {
|
---|
| 114 | return experimentalModel;
|
---|
| 115 | }
|
---|
[66] | 116 |
|
---|
| 117 | public int getNumberOfComparisons() {
|
---|
| 118 | return numberOfComparisons;
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | public void setNumberOfComparisons(int numberOfCOmparisons) {
|
---|
| 122 | this.numberOfComparisons = numberOfCOmparisons;
|
---|
| 123 | }
|
---|
[78] | 124 |
|
---|
[1] | 125 | }
|
---|