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 maxNumberInComps;
|
---|
21 |
|
---|
22 | private BooleanModel experimentalModel = new BooleanModel(true);
|
---|
23 | private BooleanModel confirmationModel = new BooleanModel(false);
|
---|
24 |
|
---|
25 | private UncertainPreferenceContainer uncertainPrefContainer = null;
|
---|
26 |
|
---|
27 | public PairwiseComparisonModel(ProfileRepItem profile){
|
---|
28 | this.profile = profile;
|
---|
29 | this.maxNumberInComps = calculateMaxNumberOfComparisons();
|
---|
30 | connect();
|
---|
31 | }
|
---|
32 | public int calculateMaxNumberOfComparisons() {
|
---|
33 | SortedOutcomeSpace realSortedOutcomeSpace = new SortedOutcomeSpace((AbstractUtilitySpace) profile.create());
|
---|
34 | int max = realSortedOutcomeSpace.getAllOutcomes().size() - 1;
|
---|
35 | return max;
|
---|
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().
|
---|
46 | getBidRanking().getBidOrder().size()-1;
|
---|
47 | double uncertaintyLevel = ((double) amountOfComps / (double) getMaxNumberInComps());
|
---|
48 | double errorRate = Double.parseDouble(getErrorModel().getText())*100;
|
---|
49 |
|
---|
50 | JOptionPane.showMessageDialog(null , "Pairwise Comparison User Model Created Successfully! \n\n"
|
---|
51 | + "Number of Outcomes In Comparison Set: " + 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 = Integer.parseInt((getUncertaintyModel().getText()));
|
---|
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 int getNumberOfComps(){
|
---|
82 | return (int)((1 - Double.parseDouble(getUncertaintyModel().getText())) * maxNumberInComps);
|
---|
83 | }
|
---|
84 |
|
---|
85 |
|
---|
86 | public TextModel getErrorModel() {
|
---|
87 | return errorModel;
|
---|
88 | }
|
---|
89 | public int getMaxNumberInComps() {
|
---|
90 | return maxNumberInComps;
|
---|
91 | }
|
---|
92 | public BooleanModel getConfirmationModel() {
|
---|
93 | return confirmationModel;
|
---|
94 | }
|
---|
95 | public UncertainPreferenceContainer getUncertainPrefContainer() {
|
---|
96 | return uncertainPrefContainer;
|
---|
97 | }
|
---|
98 | public BooleanModel getExperimentalModel() {
|
---|
99 | return experimentalModel;
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|