Last change
on this file since 161 was 127, checked in by Wouter Pasman, 6 years ago |
#41 ROLL BACK of rev.126 . So this version is equal to rev. 125
|
File size:
1.3 KB
|
Rev | Line | |
---|
[127] | 1 | package agents.similarity;
|
---|
| 2 |
|
---|
| 3 | import java.util.HashMap;
|
---|
| 4 |
|
---|
| 5 | import genius.core.Bid;
|
---|
| 6 | import genius.core.issue.ValueDiscrete;
|
---|
| 7 | import genius.core.xml.SimpleElement;
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 | public class CriteriaDiscrete implements Criteria {
|
---|
| 12 | private int fIssueIndex;
|
---|
| 13 | private HashMap<ValueDiscrete, Double> fCriteriaValues;
|
---|
| 14 |
|
---|
| 15 | public CriteriaDiscrete(int pIssueIndex) {
|
---|
| 16 | fIssueIndex = pIssueIndex;
|
---|
| 17 | fCriteriaValues = new HashMap<ValueDiscrete, Double> ();
|
---|
| 18 | }
|
---|
| 19 | public double getValue(Bid pBid) {
|
---|
| 20 | ValueDiscrete lValue = null;
|
---|
| 21 | try {
|
---|
| 22 | lValue = (ValueDiscrete)(pBid.getValue(fIssueIndex));
|
---|
| 23 | } catch (Exception e) {
|
---|
| 24 | e.printStackTrace();
|
---|
| 25 | }
|
---|
| 26 | Double lTmp = fCriteriaValues.get(lValue);
|
---|
| 27 | if (lTmp!=null) {
|
---|
| 28 | return fCriteriaValues.get(lValue);
|
---|
| 29 | } else {
|
---|
| 30 | System.out.println("Can't find criteria value for " +lValue.toString() + "(issue index = " +String.valueOf(fIssueIndex)+")");
|
---|
| 31 | return -1;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | public void loadFromXML(SimpleElement pRoot) {
|
---|
| 37 |
|
---|
| 38 | Object[] xml_items = (pRoot).getChildByTagName("item");
|
---|
| 39 | int nrOfValues = xml_items.length;
|
---|
| 40 | ValueDiscrete value;
|
---|
| 41 | for(int j=0;j<nrOfValues;j++) {
|
---|
| 42 | value = new ValueDiscrete(((SimpleElement)xml_items[j]).getAttribute("value"));
|
---|
| 43 | this.fCriteriaValues.put(value, Double.valueOf(((SimpleElement)xml_items[j]).getAttribute("evaluation")));
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.