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

Last change on this file since 337 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
RevLine 
[83]1package genius.gui.tree;
2
[95]3import genius.core.listener.Listener;
[84]4import genius.core.utility.UncertainAdditiveUtilitySpace;
5import genius.core.utility.UtilitySpace;
[83]6import genius.gui.panels.BooleanModel;
[227]7import genius.gui.panels.DoubleModel;
[91]8import genius.gui.panels.IntegerModel;
[83]9
10/**
[139]11 * Holds the uncertainty settings (while editing a profile). This MVC model
12 * contains listenable fields and coordinates changes
[83]13 */
14public class UncertaintySettingsModel {
[130]15 private final BooleanModel isEnabled;
16 private final IntegerModel comparisons;
17 private final IntegerModel errors;
[227]18 private final DoubleModel elicitationCost;
[155]19 private final BooleanModel isFixedSeed;
[130]20 private final BooleanModel isExperimental;
21 private final long totalBids;
[83]22
23 /**
[95]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.
[83]29 */
[95]30 public UncertaintySettingsModel(UtilitySpace space) {
[130]31 final UncertainAdditiveUtilitySpace uspace = space instanceof UncertainAdditiveUtilitySpace
32 ? (UncertainAdditiveUtilitySpace) space
33 : null;
34
35 isEnabled = new BooleanModel(uspace != null);
36
[84]37 totalBids = space.getDomain().getNumberOfPossibleBids();
[130]38
[155]39 isFixedSeed = new BooleanModel(
40 (uspace != null) ? uspace.isFixedSeed() : true);
41
[130]42 isExperimental = new BooleanModel(
43 uspace != null ? uspace.isExperimental() : false);
44
[91]45 comparisons = new IntegerModel(
[232]46 uspace != null ? uspace.getComparisons() : 2, 2, (int) totalBids, 1);
[130]47
[91]48 errors = new IntegerModel(uspace != null ? uspace.getErrors() : 0, 0,
[88]49 (int) totalBids, 1);
[227]50
51 elicitationCost = new DoubleModel(uspace != null ? uspace.getElicitationCost() : 0);
[95]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());
[83]61 }
62
[91]63 public IntegerModel getComparisons() {
[83]64 return comparisons;
65 }
66
[91]67 public IntegerModel getErrors() {
[83]68 return errors;
69 }
[227]70
71 public DoubleModel getElicitationCost() {
72 return elicitationCost;
73 }
[83]74
75 public BooleanModel getIsExperimental() {
76 return isExperimental;
77 }
78
79 public BooleanModel getIsEnabled() {
80 return isEnabled;
[155]81 }
82
83 public BooleanModel getIsFixedSeed() {
84 return isFixedSeed;
[83]85 }
86
87 public long getTotalBids() {
88 return totalBids;
89 }
90
[95]91 private void updateEnabledness(boolean lock) {
92 comparisons.setLock(lock);
93 errors.setLock(lock);
[227]94 elicitationCost.setLock(lock);
[155]95 isFixedSeed.setLock(lock);
[95]96 isExperimental.setLock(lock);
97 }
98
[83]99}
Note: See TracBrowser for help on using the repository browser.