source: src/main/java/genius/gui/tree/UncertaintySettingsModel.java@ 345

Last change on this file since 345 was 232, checked in by Adel Magra, 5 years ago

Created a User class that implements an elicit functionality.

Created a Top_3 Agent with the BOA framework to showcase this functionality.

File size: 2.7 KB
Line 
1package genius.gui.tree;
2
3import genius.core.listener.Listener;
4import genius.core.utility.UncertainAdditiveUtilitySpace;
5import genius.core.utility.UtilitySpace;
6import genius.gui.panels.BooleanModel;
7import genius.gui.panels.DoubleModel;
8import genius.gui.panels.IntegerModel;
9
10/**
11 * Holds the uncertainty settings (while editing a profile). This MVC model
12 * contains listenable fields and coordinates changes
13 */
14public class UncertaintySettingsModel {
15 private final BooleanModel isEnabled;
16 private final IntegerModel comparisons;
17 private final IntegerModel errors;
18 private final DoubleModel elicitationCost;
19 private final BooleanModel isFixedSeed;
20 private final BooleanModel isExperimental;
21 private final long totalBids;
22
23 /**
24 * @oaran space the {@link UtilitySpace} we're working with. This panel is
25 * enabled by default iff the space is an
26 * {@link UncertainAdditiveUtilitySpace}. If the space is
27 * {@link UncertainAdditiveUtilitySpace} we also copy the default
28 * values from there. Otherwise all default values are set to 0.
29 */
30 public UncertaintySettingsModel(UtilitySpace space) {
31 final UncertainAdditiveUtilitySpace uspace = space instanceof UncertainAdditiveUtilitySpace
32 ? (UncertainAdditiveUtilitySpace) space
33 : null;
34
35 isEnabled = new BooleanModel(uspace != null);
36
37 totalBids = space.getDomain().getNumberOfPossibleBids();
38
39 isFixedSeed = new BooleanModel(
40 (uspace != null) ? uspace.isFixedSeed() : true);
41
42 isExperimental = new BooleanModel(
43 uspace != null ? uspace.isExperimental() : false);
44
45 comparisons = new IntegerModel(
46 uspace != null ? uspace.getComparisons() : 2, 2, (int) totalBids, 1);
47
48 errors = new IntegerModel(uspace != null ? uspace.getErrors() : 0, 0,
49 (int) totalBids, 1);
50
51 elicitationCost = new DoubleModel(uspace != null ? uspace.getElicitationCost() : 0);
52
53 // copy enabledness -> lockedness of other components
54 isEnabled.addListener(new Listener<Boolean>() {
55 @Override
56 public void notifyChange(Boolean enabled) {
57 updateEnabledness(!enabled);
58 }
59 });
60 updateEnabledness(!isEnabled.getValue());
61 }
62
63 public IntegerModel getComparisons() {
64 return comparisons;
65 }
66
67 public IntegerModel getErrors() {
68 return errors;
69 }
70
71 public DoubleModel getElicitationCost() {
72 return elicitationCost;
73 }
74
75 public BooleanModel getIsExperimental() {
76 return isExperimental;
77 }
78
79 public BooleanModel getIsEnabled() {
80 return isEnabled;
81 }
82
83 public BooleanModel getIsFixedSeed() {
84 return isFixedSeed;
85 }
86
87 public long getTotalBids() {
88 return totalBids;
89 }
90
91 private void updateEnabledness(boolean lock) {
92 comparisons.setLock(lock);
93 errors.setLock(lock);
94 elicitationCost.setLock(lock);
95 isFixedSeed.setLock(lock);
96 isExperimental.setLock(lock);
97 }
98
99}
Note: See TracBrowser for help on using the repository browser.