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 | |
---|
1 | package genius.core.utility;
|
---|
2 |
|
---|
3 | import java.util.HashMap;
|
---|
4 |
|
---|
5 | import genius.core.Bid;
|
---|
6 |
|
---|
7 | public class InclusiveZeroOutcomeConstraint implements ZeroOutcomeContraint {
|
---|
8 |
|
---|
9 | private HashMap<Integer, String> checkList;
|
---|
10 |
|
---|
11 | public InclusiveZeroOutcomeConstraint() {
|
---|
12 | this.checkList = new HashMap<>();
|
---|
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 | for (Integer issueIndex : this.checkList.keySet()) {
|
---|
24 |
|
---|
25 | if (checkList.get(issueIndex).contains("numeric")) {
|
---|
26 |
|
---|
27 | if ((checkList.get(issueIndex).contains("positive")) && (Integer
|
---|
28 | .valueOf(bid.getValue(issueIndex).toString()) < 0)) {
|
---|
29 | return false;
|
---|
30 | } else if ((checkList.get(issueIndex).contains("negative"))
|
---|
31 | && (Integer.valueOf(
|
---|
32 | bid.getValue(issueIndex).toString()) > 0)) {
|
---|
33 | return false;
|
---|
34 | }
|
---|
35 |
|
---|
36 | } else // check it involves "condition" keyword
|
---|
37 | {
|
---|
38 | if (!bid.getValue(issueIndex).toString()
|
---|
39 | .contains(this.checkList.get(issueIndex))) {
|
---|
40 | return false;
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|
44 |
|
---|
45 | }
|
---|
46 | return true;
|
---|
47 | }
|
---|
48 |
|
---|
49 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.