source: src/main/java/genius/core/utility/ConditionalZeroOutcomeConstraint.java

Last change on this file 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.2 KB
Line 
1package genius.core.utility;
2
3import java.util.HashMap;
4
5import genius.core.Bid;
6
7public class ConditionalZeroOutcomeConstraint implements ZeroOutcomeContraint {
8
9 private HashMap<Integer, String> checkList;
10
11 public ConditionalZeroOutcomeConstraint() {
12 this.checkList = new HashMap<Integer, String>();
13 }
14
15 @Override
16 public void addContraint(Integer issueIndex, String conditionToBeCheck) {
17 this.checkList.put(issueIndex, conditionToBeCheck);
18 }
19
20 @Override
21 public boolean willGetZeroOutcomeUtility(Bid bid) {
22
23 Integer[] indices = new Integer[2];
24 int count = 0;
25 for (Integer index : this.checkList.keySet()) {
26 indices[count++] = index;
27 }
28
29 if ((this.checkList.get(indices[0]).equals("numeric=positive"))
30 && (Integer.valueOf(bid.getValue(indices[0]).toString()) > 0)) {
31 if (!bid.getValue(indices[1]).toString()
32 .contains(this.checkList.get(indices[1])))
33 return true;
34 } else if ((this.checkList.get(indices[0]).equals("numeric=negative"))
35 && (Integer.valueOf(bid.getValue(indices[0]).toString()) < 0)) {
36
37 if (!bid.getValue(indices[1]).toString()
38 .contains(this.checkList.get(indices[1])))
39 return true;
40
41 }
42 return false;
43 }
44
45}
Note: See TracBrowser for help on using the repository browser.