Changeset 9 for profile/src/main/java
- Timestamp:
- 11/28/19 14:40:48 (5 years ago)
- Location:
- profile/src/main/java/geniusweb/profile
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
profile/src/main/java/geniusweb/profile/Profile.java
r2 r9 7 7 import geniusweb.issuevalue.Domain; 8 8 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace; 9 import geniusweb.profile.utilityspace.SumOfGroupsUtilitySpace; 9 10 10 11 /** … … 17 18 @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT) 18 19 @JsonSubTypes({ @JsonSubTypes.Type(value = LinearAdditiveUtilitySpace.class), 19 @JsonSubTypes.Type(value = DefaultPartialOrdering.class) }) 20 @JsonSubTypes.Type(value = DefaultPartialOrdering.class), 21 @JsonSubTypes.Type(value = SumOfGroupsUtilitySpace.class) }) 20 22 public interface Profile { 21 23 … … 33 35 /** 34 36 * 35 * @return a (hypothetical) bid that is the best alternative to a non-agreement. 36 * Only bids that are {@link #isPreferredOrEqual(Bid, Bid)} should be 37 * accepted. If a negotiation does not reach an agreement, the party can 38 * get this offer somewhere else. This replaces the older notion of a 37 * @return a (hypothetical) bid that is the best alternative to a 38 * non-agreement. Only bids that are 39 * {@link #isPreferredOrEqual(Bid, Bid)} should be accepted. If a 40 * negotiation does not reach an agreement, the party can get this 41 * offer somewhere else. This replaces the older notion of a 39 42 * "reservation value" and is more general. If null, there is no 40 43 * reservation bid and any agreement is better than no agreement. -
profile/src/main/java/geniusweb/profile/utilityspace/DiscreteValueSetUtilities.java
r1 r9 8 8 import com.fasterxml.jackson.annotation.JsonAutoDetect; 9 9 import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; 10 import com.fasterxml.jackson.annotation.JsonTypeName; 10 11 11 12 import geniusweb.issuevalue.DiscreteValue; … … 13 14 import geniusweb.issuevalue.Value; 14 15 import geniusweb.issuevalue.ValueSet; 15 16 import com.fasterxml.jackson.annotation.JsonTypeName;17 16 18 17 /** … … 37 36 * create new object based on the given mapping from values to utilities. 38 37 * 39 * @param valueUtils map with key {@link DiscreteValue}s and value a Double in40 * the range [0,1].38 * @param valueUtils map with key {@link DiscreteValue}s and value a Double 39 * in the range [0,1]. 41 40 * @throws NullPointerException if one of the args is null 42 41 * @throws IllegalArgumentException if values are not in range [0,1]. 43 42 */ 44 public DiscreteValueSetUtilities(Map<DiscreteValue, BigDecimal> valueUtils) { 43 public DiscreteValueSetUtilities( 44 Map<DiscreteValue, BigDecimal> valueUtils) { 45 45 if (valueUtils == null) { 46 46 throw new NullPointerException("valueUtils==null"); 47 47 } 48 48 if (valueUtils.keySet().contains(null)) { 49 throw new NullPointerException("one of the keys in valueUtils is null"); 49 throw new NullPointerException( 50 "one of the keys in valueUtils is null"); 50 51 } 51 52 if (valueUtils.values().stream() 52 .anyMatch(v -> v == null || v.compareTo(BigDecimal.ZERO) < 0 || v.compareTo(BigDecimal.ONE) > 0)) { 53 throw new IllegalArgumentException("Weights in valueUtils must all be in [0,1]"); 53 .anyMatch(v -> v == null || v.compareTo(BigDecimal.ZERO) < 0 54 || v.compareTo(BigDecimal.ONE) > 0)) { 55 throw new IllegalArgumentException( 56 "Weights in valueUtils must all be in [0,1]"); 54 57 } 55 58 this.valueUtilities.putAll(valueUtils); … … 68 71 public String isFitting(ValueSet valueset) { 69 72 if (!(valueset instanceof DiscreteValueSet)) { 70 return "The utilities are for a discrete valueset but the given values are " + valueset; 73 return "The utilities are for a discrete valueset but the given values are " 74 + valueset; 71 75 } 72 76 DiscreteValueSet discvalueset = (DiscreteValueSet) valueset; 73 if (!valueUtilities.keySet().equals(new HashSet<>(discvalueset.getValues()))) 74 return "The values in the set " + valueset + " do not match the values mapped to utilities " 77 if (!valueUtilities.keySet() 78 .equals(new HashSet<>(discvalueset.getValues()))) 79 return "The values in the set " + valueset 80 + " do not match the values mapped to utilities " 75 81 + valueUtilities.keySet(); 76 82 return null; … … 79 85 @Override 80 86 public String toString() { 81 return " ValueSetUtilities" + valueUtilities;87 return "DiscreteValueSetUtilities" + valueUtilities; 82 88 } 83 89 … … 86 92 final int prime = 31; 87 93 int result = 1; 88 result = prime * result + ((valueUtilities == null) ? 0 : valueUtilities.hashCode()); 94 result = prime * result 95 + ((valueUtilities == null) ? 0 : valueUtilities.hashCode()); 89 96 return result; 90 97 } -
profile/src/main/java/geniusweb/profile/utilityspace/NumberValueSetUtilities.java
r4 r9 139 139 @Override 140 140 public String toString() { 141 return "NumberVal Utility(" + lowValue + "->" + lowUtility + ","141 return "NumberValueSetUtilities(" + lowValue + "->" + lowUtility + "," 142 142 + highValue + "->" + highUtility + ")"; 143 143 }
Note:
See TracChangeset
for help on using the changeset viewer.