@Test public void testGetMultiEnumScore() { EnumExclusiveScorerExclusive s = new EnumExclusiveScorerExclusive(1, 1); assertEquals(1f, s.getMultiEnumScore(2, 2), 0.001f); assertEquals(0.5f, s.getMultiEnumScore(1, 2), 0.001f); assertEquals(0.75f, s.getMultiEnumScore(3, 4), 0.001f); s.setWeight(0.5f); }
float getMultiEnumScore(int numMatches, int matchesForTopScore) { if (numMatches == 0) return minScore; if (numMatches >= matchesForTopScore) return maxScore; float interval = (maxScore - minScore) / matchesForTopScore; float result = minScore + numMatches * interval; return result; }
EnumExclusiveScorerExclusive extends TwoAttrScorer { float getMultiEnumScore(int numMatches, int matchesForTopScore) { if (numMatches == 0) return minScore; if (numMatches >= matchesForTopScore) return maxScore; float interval = (maxScore - minScore) / matchesForTopScore; float result = minScore + numMatches * interval; return result; } }
EnumExclusiveScorerExclusive extends TwoAttrScorer { float getMultiEnumScore(int numMatches, int matchesForTopScore) { if (numMatches == 0) return minScore; if (numMatches >= matchesForTopScore) return maxScore; float interval = (maxScore - minScore) / matchesForTopScore; float result = minScore + numMatches * interval; return result; } @SuppressWarnings("unused") private  EnumExclusiveScorerExclusive();  EnumExclusiveScorerExclusive(int attrId, int otherAttrId);  EnumExclusiveScorerExclusive(int attrId, int otherAttrId, Integer maxMatches); }
EnumExclusiveScorerExclusive extends TwoAttrScorer { float getMultiEnumScore(int numMatches, int matchesForTopScore) { if (numMatches == 0) return minScore; if (numMatches >= matchesForTopScore) return maxScore; float interval = (maxScore - minScore) / matchesForTopScore; float result = minScore + numMatches * interval; return result; } @SuppressWarnings("unused") private  EnumExclusiveScorerExclusive();  EnumExclusiveScorerExclusive(int attrId, int otherAttrId);  EnumExclusiveScorerExclusive(int attrId, int otherAttrId, Integer maxMatches); @Override void scoreSearchToNode(Score score, Score.Direction d, IConstraintMap c, IAttributeMap<? extends IAttribute> scoreAttrs); @Override void scoreNodeToSearch(Score score, Score.Direction d, IAttributeMap<IAttributeConstraint> c, IAttributeMap<IAttribute> searchAttrs); @Override void scoreItemToItem(Score score, Score.Direction d, IAttributeMap<IAttribute> c, IAttributeMap<IAttribute> scoreAttrs); }
EnumExclusiveScorerExclusive extends TwoAttrScorer { float getMultiEnumScore(int numMatches, int matchesForTopScore) { if (numMatches == 0) return minScore; if (numMatches >= matchesForTopScore) return maxScore; float interval = (maxScore - minScore) / matchesForTopScore; float result = minScore + numMatches * interval; return result; } @SuppressWarnings("unused") private  EnumExclusiveScorerExclusive();  EnumExclusiveScorerExclusive(int attrId, int otherAttrId);  EnumExclusiveScorerExclusive(int attrId, int otherAttrId, Integer maxMatches); @Override void scoreSearchToNode(Score score, Score.Direction d, IConstraintMap c, IAttributeMap<? extends IAttribute> scoreAttrs); @Override void scoreNodeToSearch(Score score, Score.Direction d, IAttributeMap<IAttributeConstraint> c, IAttributeMap<IAttribute> searchAttrs); @Override void scoreItemToItem(Score score, Score.Direction d, IAttributeMap<IAttribute> c, IAttributeMap<IAttribute> scoreAttrs);  }