source: src/main/java/parties/in4010/q12015/group17/AcceptStrategy.java@ 127

Last change on this file since 127 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.7 KB
Line 
1package parties.in4010.q12015.group17;
2
3import genius.core.Bid;
4import genius.core.timeline.TimeLineInfo;
5import genius.core.utility.AbstractUtilitySpace;
6
7/**
8 * This class is responsible for determining whether to accept a bid or not.
9 * Though it is currently only a single method, for the sake of future expansion
10 * as well as proper segregation it has been placed in its own class.
11 */
12public class AcceptStrategy {
13
14 private final AbstractUtilitySpace utilitySpace;
15 private final TimeLineInfo timeline;
16
17 public AcceptStrategy(AbstractUtilitySpace us, TimeLineInfo t) {
18 this.utilitySpace = us;
19 this.timeline = t;
20 }
21
22 /**
23 * Determines if the given bid is acceptable according to the current time.
24 *
25 * @param b
26 * The {@link Bid} to evaluate.
27 * @return {@code TRUE} if this {@link Bid} should be accepted, otherwise
28 * {@code FALSE}.
29 */
30 public boolean determineAcceptability(Bid b) {
31 try {
32 double utility = utilitySpace.getUtility(b);
33 double time = timeline.getTime();
34
35 // First part of concession. A sinoid decay from 1 to 0.8 utility
36 // over 0<t<0.8.
37 if (time <= 0.8)
38 return utility > 1 + (0.1 * ((Math.cos(time * Math.PI * 1.25) - 1)));
39 // Fourth part. A linear decay from 0.6 to 0.55 over 0.985 < t < 1.
40 else if (time > 0.985)
41 return utility > 0.6 - ((time - 0.985) / 0.015) * 0.05;
42 // Third part. A linear decay from 0.7 to 0.6 over 0.95<t<0.985.
43 else if (time > 0.95)
44 return utility > 0.7 - ((time - 0.95) / 0.035) * 0.1;
45 // Second part. A linear decay from 0.8 to 0.7 over 0.8<t<0.95.
46 else if (time > 0.8)
47 return utility > 0.8 - ((time - 0.8) / 0.15) * 0.1;
48 } catch (Exception e) {
49 e.printStackTrace();
50 }
51 return false;
52 }
53}
Note: See TracBrowser for help on using the repository browser.