Changeset 10 for profile/src/main
- Timestamp:
- 01/28/20 10:19:54 (5 years ago)
- Location:
- profile/src/main/java/geniusweb/profile
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
profile/src/main/java/geniusweb/profile/DefaultPartialOrdering.java
r2 r10 26 26 * limited anyway. 27 27 */ 28 public class DefaultPartialOrdering extends DefaultProfile implements PartialOrdering { 28 public class DefaultPartialOrdering extends DefaultProfile 29 implements PartialOrdering { 29 30 30 31 /** … … 40 41 * @param reservationbid 41 42 * @param bids 42 * @param isbetterList a list of tuples [bid1index, bid2index]. It indicates 43 * that bids[bid1index] isbetterthan bids[bid2index]. 43 * @param isbetterList a list of tuples [bid1index, bid2index]. It 44 * indicates that bids[bid1index] isbetterthan 45 * bids[bid2index]. 44 46 */ 45 47 @JsonCreator 46 public DefaultPartialOrdering(@JsonProperty("name") String name, @JsonProperty("domain") Domain domain, 47 @JsonProperty("reservationBid") Bid reservationbid, @JsonProperty("bids") List<Bid> bids, 48 public DefaultPartialOrdering(@JsonProperty("name") String name, 49 @JsonProperty("domain") Domain domain, 50 @JsonProperty("reservationBid") Bid reservationbid, 51 @JsonProperty("bids") List<Bid> bids, 48 52 @JsonProperty("better") List<List<Integer>> isbetterList) { 49 53 this(name, domain, reservationbid, makeBidMap(bids, isbetterList)); … … 54 58 * @param domain the {@link Domain} description 55 59 * @param reservationbid the reservation {@link Bid} 56 * @param isBetterMap a map with keys = a better bid and value=a less good57 * bid.60 * @param isBetterMap a map with keys = a better bid and value=a less 61 * good bid. 58 62 */ 59 public DefaultPartialOrdering(String name, Domain domain, Bid reservationbid, Map<Bid, Set<Bid>> isBetterMap) { 63 public DefaultPartialOrdering(String name, Domain domain, 64 Bid reservationbid, Map<Bid, Set<Bid>> isBetterMap) { 60 65 super(name, domain, reservationbid); 61 66 this.isBetter = isBetterMap; … … 71 76 /** 72 77 * 73 * @return a list with all the bids 78 * @return a list with all the bids that are referred to, either as better 79 * or as worse than another bid 74 80 */ 75 81 @JsonGetter … … 97 103 if (isBetter.containsKey(bid)) { 98 104 for (Bid worsebid : isBetter.get(bid)) { 99 betterlist.add(Arrays.asList(bidslist.indexOf(bid), bidslist.indexOf(worsebid))); 105 betterlist.add(Arrays.asList(bidslist.indexOf(bid), 106 bidslist.indexOf(worsebid))); 100 107 } 101 108 } … … 107 114 @Override 108 115 public String toString() { 109 return "DefaultPartialOrdering[" + getValuesString() + "," + isBetter + "]"; 116 return "DefaultPartialOrdering[" + getValuesString() + "," + isBetter 117 + "]"; 110 118 } 111 119 112 private static Map<Bid, Set<Bid>> makeBidMap(List<Bid> bids, List<List<Integer>> isBetterList) { 120 private static Map<Bid, Set<Bid>> makeBidMap(List<Bid> bids, 121 List<List<Integer>> isBetterList) { 113 122 Map<Bid, Set<Bid>> betterMap = new HashMap<>(); 114 123 115 124 for (List<Integer> tuple : isBetterList) { 116 125 if (tuple.size() != 2) { 117 throw new IllegalArgumentException("Expected tuple but found " + tuple + "in " + isBetterList); 126 throw new IllegalArgumentException("Expected tuple but found " 127 + tuple + "in " + isBetterList); 118 128 } 119 129 Bid betterbid = bids.get(tuple.get(0)); … … 133 143 final int prime = 31; 134 144 int result = super.hashCode(); 135 result = prime * result + ((isBetter == null) ? 0 : isBetter.hashCode()); 145 result = prime * result 146 + ((isBetter == null) ? 0 : isBetter.hashCode()); 136 147 return result; 137 148 } -
profile/src/main/java/geniusweb/profile/utilityspace/DiscreteValueSetUtilities.java
r9 r10 2 2 3 3 import java.math.BigDecimal; 4 import java.util.Collections; 4 5 import java.util.HashMap; 5 6 import java.util.HashSet; … … 68 69 } 69 70 71 /** 72 * @return copy of the value-utility pair map. 73 */ 74 public Map<DiscreteValue, BigDecimal> getUtilities() { 75 return Collections.unmodifiableMap(valueUtilities); 76 } 77 70 78 @Override 71 79 public String isFitting(ValueSet valueset) { -
profile/src/main/java/geniusweb/profile/utilityspace/LinearAdditiveUtilitySpace.java
r7 r10 25 25 */ 26 26 @JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE) 27 public class LinearAdditiveUtilitySpace implements UtilitySpace {27 public class LinearAdditiveUtilitySpace implements LinearAdditive { 28 28 29 29 private final String name; … … 131 131 } 132 132 133 /** 134 * 135 * @param issue the issue to get weighted util for 136 * @param value the issue value to use (typically coming from a bid) 137 * @return weighted util of just the issue value: 138 * issueUtilities[issue].utility(value) * issueWeights[issue) 139 */ 140 private BigDecimal util(String issue, Value value) { 141 return issueWeights.get(issue) 142 .multiply(issueUtilities.get(issue).getUtility(value)); 143 } 144 133 @Override 145 134 public BigDecimal getWeight(String issue) { 146 135 return issueWeights.get(issue); … … 220 209 } 221 210 222 /** 223 * @return the map from issue names to valuesetutilities (un-weighted) 224 */ 211 @Override 225 212 public Map<String, ValueSetUtilities> getUtilities() { 226 213 return Collections.unmodifiableMap(issueUtilities); 227 214 } 228 215 229 /** 230 * 231 * @return the map from issue names to weights. weights sum to 1. 232 */ 216 @Override 233 217 public Map<String, BigDecimal> getWeights() { 234 218 return Collections.unmodifiableMap(issueWeights); 235 219 } 236 220 221 /** 222 * 223 * @param issue the issue to get weighted util for 224 * @param value the issue value to use (typically coming from a bid) 225 * @return weighted util of just the issue value: 226 * issueUtilities[issue].utility(value) * issueWeights[issue) 227 */ 228 private BigDecimal util(String issue, Value value) { 229 return issueWeights.get(issue) 230 .multiply(issueUtilities.get(issue).getUtility(value)); 231 } 232 237 233 } -
profile/src/main/java/geniusweb/profile/utilityspace/SumOfGroupsUtilitySpace.java
r9 r10 84 84 * grouping. 85 85 * 86 * @param las the {@link LinearAdditive UtilitySpace} to be converted/copied.87 * 88 */ 89 public SumOfGroupsUtilitySpace(LinearAdditive UtilitySpacelas) {86 * @param las the {@link LinearAdditive} to be converted/copied. 87 * 88 */ 89 public SumOfGroupsUtilitySpace(LinearAdditive las) { 90 90 this(las.getDomain(), las.getName(), las2parts(las), 91 91 las.getReservationBid()); … … 212 212 /** 213 213 * 214 * @param las a {@link LinearAdditive UtilitySpace}214 * @param las a {@link LinearAdditive} 215 215 * @return a Map with partname-PartsUtilities. The partnames are identical 216 216 * to the issues in the given las. 217 217 */ 218 218 private static HashMap<String, PartsUtilities> las2parts( 219 LinearAdditive UtilitySpacelas) {219 LinearAdditive las) { 220 220 221 221 HashMap<String, PartsUtilities> map = new HashMap<>();
Note:
See TracChangeset
for help on using the changeset viewer.