- Timestamp:
- 01/28/20 10:19:54 (5 years ago)
- Location:
- bidspace/src
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
bidspace/src/main/java/geniusweb/bidspace/BidsWithUtility.java
r8 r10 12 12 import geniusweb.issuevalue.Domain; 13 13 import geniusweb.issuevalue.Value; 14 import geniusweb.profile.utilityspace.LinearAdditive UtilitySpace;14 import geniusweb.profile.utilityspace.LinearAdditive; 15 15 import tudelft.utilities.immutablelist.AbstractImmutableList; 16 16 import tudelft.utilities.immutablelist.FixedList; … … 22 22 /** 23 23 * Tool class containing functions dealing with utilities of all bids in a given 24 * {@link LinearAdditive UtilitySpace}. This class caches previously computed25 * values to accelerate the calls and subsequent calls. Re-use the object to26 * keep/reusethe cache.24 * {@link LinearAdditive}. This class caches previously computed values to 25 * accelerate the calls and subsequent calls. Re-use the object to keep/reuse 26 * the cache. 27 27 * <h1>Rounding</h1> Internally, utilities of bids are rounded to the given 28 28 * precision. This may cause inclusion/exclusion of some bids in the results. 29 * See {@link #BidsWithUtility(LinearAdditiveUtilitySpace, int)} for more 30 * details 29 * See {@link #BidsWithUtility(LinearAdditive, int)} for more details 31 30 */ 32 31 public class BidsWithUtility { … … 44 43 * Default constructor, uses default precision 6. This value seems practical 45 44 * for the common range of issues, utilities and weights. See 46 * {@link #BidsWithUtil(LinearAdditive UtilitySpace, int)} for more details47 * on theprecision.48 * 49 * @param space the {@link LinearAdditive UtilitySpace} to analyze50 */ 51 public BidsWithUtility(LinearAdditive UtilitySpacespace) {45 * {@link #BidsWithUtil(LinearAdditive, int)} for more details on the 46 * precision. 47 * 48 * @param space the {@link LinearAdditive} to analyze 49 */ 50 public BidsWithUtility(LinearAdditive space) { 52 51 this(space, 6); 53 52 } … … 55 54 /** 56 55 * 57 * @param space the {@link LinearAdditive UtilitySpace} to analyze56 * @param space the {@link LinearAdditive} to analyze 58 57 * @param precision the number of digits to use for computations. In 59 58 * practice, 6 seems a good default value. … … 77 76 * 78 77 */ 79 public BidsWithUtility(LinearAdditive UtilitySpacespace, int precision) {78 public BidsWithUtility(LinearAdditive space, int precision) { 80 79 this(getInfo(space, precision), precision); 81 80 } … … 119 118 public List<IssueInfo> getInfo() { 120 119 return Collections.unmodifiableList(issueInfo); 120 } 121 122 /** 123 * 124 * @param isMax the extreme bid required 125 * @return the extreme bid, either the minimum if isMax=false or maximum if 126 * isMax=true 127 */ 128 public Bid getExtremeBid(boolean isMax) { 129 Map<String, Value> map = new HashMap<>(); 130 for (IssueInfo info : issueInfo) { 131 map.put(info.getName(), info.getExtreme(isMax)); 132 } 133 return new Bid(map); 121 134 } 122 135 … … 154 167 } 155 168 156 private static List<IssueInfo> getInfo(LinearAdditive UtilitySpacespace2,169 private static List<IssueInfo> getInfo(LinearAdditive space2, 157 170 int precision) { 158 171 Domain dom = space2.getDomain(); -
bidspace/src/main/java/geniusweb/bidspace/Interval.java
r4 r10 137 137 if (other.max != null) 138 138 return false; 139 } else if (!max.equals(other.max)) 139 140 } else if (max.compareTo(other.max) != 0) 141 // THIS WAS FIXED MANUALLY TO USE COMPARETO 140 142 return false; 141 143 if (min == null) { 142 144 if (other.min != null) 143 145 return false; 144 } else if (!min.equals(other.min)) 146 } else if (min.compareTo(other.min) != 0) 147 // THIS WAS FIXED MANUALLY TO USE COMPARETO 145 148 return false; 146 149 return true; -
bidspace/src/main/java/geniusweb/bidspace/IssueInfo.java
r4 r10 49 49 public Interval getInterval() { 50 50 return interval; 51 } 52 53 /** 54 * 55 * @param isMax 56 * @return the extreme value, either the minimum if isMax=false or maximum 57 * if isMax=true 58 */ 59 public Value getExtreme(boolean isMax) { 60 BigDecimal extremeutil = null; 61 Value extremeval = null; 62 for (Value val : values) { 63 BigDecimal util = weightedUtils.get(val); 64 if (extremeval == null) { 65 extremeutil = weightedUtils.get(val); 66 extremeval = val; 67 } else { 68 if (isMax) { 69 if (util.compareTo(extremeutil) > 0) { 70 extremeutil = util; 71 extremeval = val; 72 } 73 } else { 74 if (util.compareTo(extremeutil) < 0) { 75 extremeutil = util; 76 extremeval = val; 77 } 78 79 } 80 } 81 } 82 return extremeval; 51 83 } 52 84 -
bidspace/src/main/java/geniusweb/bidspace/pareto/ParetoLinearAdditive.java
r1 r10 10 10 import geniusweb.issuevalue.Domain; 11 11 import geniusweb.profile.Profile; 12 import geniusweb.profile.utilityspace.LinearAdditive UtilitySpace;12 import geniusweb.profile.utilityspace.LinearAdditive; 13 13 14 14 /** 15 * pareto frontier implementation for {@link LinearAdditive UtilitySpace}.16 * Simplisticimplementation that iterates over all bids.15 * pareto frontier implementation for {@link LinearAdditive}. Simplistic 16 * implementation that iterates over all bids. 17 17 */ 18 18 public class ParetoLinearAdditive implements ParetoFrontier { 19 19 20 private final List<LinearAdditive UtilitySpace> utilSpaces;20 private final List<LinearAdditive> utilSpaces; 21 21 private Set<Bid> points = null; 22 22 // all issues in a deterministic order … … 24 24 /** 25 25 * 26 * @param utilSpaces. Must contain at least two 27 * {@link LinearAdditiveUtilitySpace}s and all must be 28 * defined on the same donain. 26 * @param utilSpaces. Must contain at least two {@link LinearAdditive}s and 27 * all must be defined on the same donain. 29 28 */ 30 public ParetoLinearAdditive(List<LinearAdditive UtilitySpace> utilSpaces) {29 public ParetoLinearAdditive(List<LinearAdditive> utilSpaces) { 31 30 if (utilSpaces == null || utilSpaces.size() < 2) { 32 31 throw new IllegalArgumentException( … … 34 33 } 35 34 Domain domain = utilSpaces.get(0).getDomain(); 36 for (LinearAdditive UtilitySpacespace : utilSpaces) {35 for (LinearAdditive space : utilSpaces) { 37 36 if (!space.getDomain().equals(domain)) { 38 37 throw new IllegalArgumentException( -
bidspace/src/main/java/geniusweb/bidspace/pareto/ParetoPoint.java
r1 r10 10 10 import geniusweb.issuevalue.Bid; 11 11 import geniusweb.issuevalue.Value; 12 import geniusweb.profile.utilityspace.LinearAdditive UtilitySpace;12 import geniusweb.profile.utilityspace.LinearAdditive; 13 13 14 14 /** … … 26 26 * 27 27 * @param bid a (possibly partial) {@link Bid} 28 * @param spaces the {@link LinearAdditive UtilitySpace}s to consider28 * @param spaces the {@link LinearAdditive}s to consider 29 29 */ 30 public ParetoPoint(Bid bid, List<LinearAdditive UtilitySpace> spaces) {30 public ParetoPoint(Bid bid, List<LinearAdditive> spaces) { 31 31 this.bid = bid; 32 32 utilities = new ArrayList<>(); 33 for (LinearAdditive UtilitySpacespace : spaces) {33 for (LinearAdditive space : spaces) { 34 34 utilities.add(space.getUtility(bid)); 35 35 } -
bidspace/src/main/java/geniusweb/bidspace/pareto/PartialPareto.java
r1 r10 8 8 import geniusweb.issuevalue.Bid; 9 9 import geniusweb.issuevalue.Value; 10 import geniusweb.profile.utilityspace.LinearAdditive UtilitySpace;10 import geniusweb.profile.utilityspace.LinearAdditive; 11 11 12 12 /** … … 28 28 * implemented recursively (O(log(#issues))). 29 29 * 30 * @param utilSpaces the {@link LinearAdditive UtilitySpace}s30 * @param utilSpaces the {@link LinearAdditive}s 31 31 * @param issues the issues (subset of all issues in the space) to be 32 32 * used for this pareto … … 34 34 * given issues. 35 35 */ 36 public static PartialPareto create( 37 List< LinearAdditiveUtilitySpace> utilSpaces, List<String> issues) {36 public static PartialPareto create(List<LinearAdditive> utilSpaces, 37 List<String> issues) { 38 38 39 39 if (issues.size() == 1) { -
bidspace/src/test/java/geniusweb/bidspace/pareto/ParetoE2Etest.java
r1 r10 19 19 import com.fasterxml.jackson.databind.ObjectMapper; 20 20 21 import geniusweb.bidspace.pareto.GenericPareto;22 import geniusweb.bidspace.pareto.ParetoFrontier;23 import geniusweb.bidspace.pareto.ParetoLinearAdditive;24 21 import geniusweb.profile.Profile; 22 import geniusweb.profile.utilityspace.LinearAdditive; 25 23 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace; 26 24 … … 61 59 .readValue(file2, Profile.class); 62 60 63 List<LinearAdditive UtilitySpace> profiles = new LinkedList<>();61 List<LinearAdditive> profiles = new LinkedList<>(); 64 62 profiles.add(profile1); 65 63 profiles.add(profile2); -
bidspace/src/test/java/geniusweb/bidspace/pareto/ParetoPointTest.java
r1 r10 15 15 import org.junit.Test; 16 16 17 import geniusweb.bidspace.pareto.ParetoPoint;18 17 import geniusweb.issuevalue.Bid; 19 18 import geniusweb.issuevalue.Value; 20 import geniusweb.profile.utilityspace.LinearAdditive UtilitySpace;19 import geniusweb.profile.utilityspace.LinearAdditive; 21 20 22 21 public class ParetoPointTest { … … 26 25 private static final BigDecimal D0_4 = BigDecimal.valueOf(0.4); 27 26 private static final BigDecimal D0_5 = BigDecimal.valueOf(0.5); 28 private final LinearAdditiveUtilitySpace space1 = mock( 29 LinearAdditiveUtilitySpace.class), 30 space2 = mock(LinearAdditiveUtilitySpace.class); 27 private final LinearAdditive space1 = mock(LinearAdditive.class), 28 space2 = mock(LinearAdditive.class); 31 29 private final Bid bid11 = mock(Bid.class), bid12 = mock(Bid.class), 32 30 bid21 = mock(Bid.class), bid22 = mock(Bid.class); -
bidspace/src/test/java/geniusweb/bidspace/pareto/PartialParetoTest.java
r1 r10 16 16 import org.junit.Test; 17 17 18 import geniusweb.bidspace.pareto.PartialPareto;19 18 import geniusweb.issuevalue.Bid; 20 19 import geniusweb.issuevalue.Domain; 21 20 import geniusweb.issuevalue.Value; 22 21 import geniusweb.issuevalue.ValueSet; 23 import geniusweb.profile.utilityspace.LinearAdditive UtilitySpace;22 import geniusweb.profile.utilityspace.LinearAdditive; 24 23 25 24 public class PartialParetoTest { … … 31 30 private static final BigDecimal D0_5 = BigDecimal.valueOf(0.5); 32 31 33 private final LinearAdditiveUtilitySpace space1 = mock( 34 LinearAdditiveUtilitySpace.class), 35 space2 = mock(LinearAdditiveUtilitySpace.class); 32 private final LinearAdditive space1 = mock(LinearAdditive.class), 33 space2 = mock(LinearAdditive.class); 36 34 37 35 private Domain domain = mock(Domain.class);
Note:
See TracChangeset
for help on using the changeset viewer.