[1] | 1 | package genius.gui.uncertainty;
|
---|
| 2 |
|
---|
| 3 | import javax.swing.JOptionPane;
|
---|
| 4 |
|
---|
| 5 | import genius.core.boaframework.SortedOutcomeSpace;
|
---|
| 6 | import genius.core.listener.Listener;
|
---|
| 7 | import genius.core.repository.ProfileRepItem;
|
---|
| 8 | import genius.core.uncertainty.ComparisonGenerator;
|
---|
| 9 | import genius.core.uncertainty.UNCERTAINTYTYPE;
|
---|
| 10 | import genius.core.uncertainty.UncertainPreferenceContainer;
|
---|
| 11 | import genius.core.utility.AbstractUtilitySpace;
|
---|
| 12 | import genius.gui.panels.BooleanModel;
|
---|
| 13 | import genius.gui.panels.TextModel;
|
---|
| 14 |
|
---|
| 15 | public class PairwiseComparisonModel {
|
---|
| 16 |
|
---|
| 17 | private ProfileRepItem profile;
|
---|
| 18 |
|
---|
| 19 | private TextModel uncertaintyModel = new TextModel("0.0");
|
---|
| 20 | private TextModel errorModel = new TextModel("0.0");
|
---|
| 21 | private int maxNumberOfComps;
|
---|
| 22 |
|
---|
| 23 | private BooleanModel experimentalModel = new BooleanModel(false);
|
---|
| 24 | private BooleanModel confirmationModel = new BooleanModel(false);
|
---|
| 25 |
|
---|
| 26 | private UncertainPreferenceContainer uncertainPrefContainer = null;
|
---|
| 27 |
|
---|
| 28 | PairwiseComparisonModel(ProfileRepItem profile){
|
---|
| 29 | this.profile = profile;
|
---|
| 30 | this.maxNumberOfComps = calculateMaxNumberOfComparisons();
|
---|
| 31 | connect();
|
---|
| 32 | }
|
---|
| 33 | public int calculateMaxNumberOfComparisons() {
|
---|
| 34 | SortedOutcomeSpace realSortedOutcomeSpace = new SortedOutcomeSpace((AbstractUtilitySpace) profile.create());
|
---|
| 35 | int comparisonsAmount = (new ComparisonGenerator(realSortedOutcomeSpace).generateAllOutcomeComparisons().size());
|
---|
| 36 | return comparisonsAmount;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | public void connect() {
|
---|
| 40 |
|
---|
| 41 | confirmationModel.addListener (new Listener<Boolean>() {
|
---|
| 42 | @Override
|
---|
| 43 | public void notifyChange(Boolean data) {
|
---|
| 44 | if (confirmationModel.getValue() == true) {
|
---|
| 45 | uncertainPrefContainer = createContainer();
|
---|
| 46 | int amountOfComps = uncertainPrefContainer.getPairwiseCompUserModel().getBidComparisons().size();
|
---|
| 47 | double uncertaintyLevel = ((double) amountOfComps / (double) getMaxNumberofComps());
|
---|
| 48 | double errorRate = Double.parseDouble(getErrorModel().getText())*100;
|
---|
| 49 |
|
---|
| 50 | JOptionPane.showMessageDialog(null , "Pairwise Comparison User Model Created Successfully! \n\n"
|
---|
| 51 | + "Number of Comparisons: " + amountOfComps +"\n"
|
---|
| 52 | + "Level Of Uncertainty: "
|
---|
| 53 | + (Math.round((1-uncertaintyLevel)*100)/100D)*100+"%\n"
|
---|
| 54 | + "Error Rate: " + (Math.round((errorRate)*100)/100D)+"%");
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 | });
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | public ProfileRepItem getProfile() {
|
---|
| 61 | return profile;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | public UncertainPreferenceContainer createContainer() {
|
---|
| 65 | int amountOfComps = (int)((1 - Double.parseDouble(getUncertaintyModel().getText())) * maxNumberOfComps);
|
---|
| 66 | UncertainPreferenceContainer container ;
|
---|
| 67 | if (experimentalModel.getValue() == true) {
|
---|
| 68 | container = new UncertainPreferenceContainer((AbstractUtilitySpace) profile.create() ,
|
---|
| 69 | UNCERTAINTYTYPE.PAIRWISECOMP, amountOfComps , Double.parseDouble(getErrorModel().getText()), true);
|
---|
| 70 | } else {
|
---|
| 71 | container = new UncertainPreferenceContainer((AbstractUtilitySpace) profile.create() ,
|
---|
| 72 | UNCERTAINTYTYPE.PAIRWISECOMP, amountOfComps , Double.parseDouble(getErrorModel().getText()), false);
|
---|
| 73 | }
|
---|
| 74 | return container;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | public TextModel getUncertaintyModel() {
|
---|
| 78 | return uncertaintyModel;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | public TextModel getErrorModel() {
|
---|
| 82 | return errorModel;
|
---|
| 83 | }
|
---|
| 84 | public int getMaxNumberofComps() {
|
---|
| 85 | return maxNumberOfComps;
|
---|
| 86 | }
|
---|
| 87 | public BooleanModel getConfirmationModel() {
|
---|
| 88 | return confirmationModel;
|
---|
| 89 | }
|
---|
| 90 | public UncertainPreferenceContainer getUncertainPrefContainer() {
|
---|
| 91 | return uncertainPrefContainer;
|
---|
| 92 | }
|
---|
| 93 | public BooleanModel getExperimentalModel() {
|
---|
| 94 | return experimentalModel;
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 |
|
---|
| 99 | }
|
---|
| 100 |
|
---|