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