[1] | 1 | /*
|
---|
| 2 | * Author: Max W. Y. Lam (Aug 1 2015)
|
---|
| 3 | * Version: Milestone 1
|
---|
| 4 | *
|
---|
| 5 | * */
|
---|
| 6 |
|
---|
| 7 | package agents.anac.y2016.maxoops;
|
---|
| 8 |
|
---|
| 9 | import genius.core.Bid;
|
---|
| 10 | import genius.core.actions.Accept;
|
---|
| 11 | import genius.core.actions.Offer;
|
---|
| 12 | import genius.core.timeline.TimeLineInfo;
|
---|
| 13 | import genius.core.utility.AbstractUtilitySpace;
|
---|
| 14 | import genius.core.utility.AdditiveUtilitySpace;
|
---|
| 15 |
|
---|
| 16 | public class DMComponent {
|
---|
| 17 |
|
---|
| 18 | MaxOops agent;
|
---|
| 19 | TimeLineInfo timeline;
|
---|
| 20 | AbstractUtilitySpace utilitySpace;
|
---|
| 21 |
|
---|
| 22 | public OPTComponent bidsOpt;
|
---|
| 23 |
|
---|
| 24 | public DMComponent(MaxOops agent, AbstractUtilitySpace utilitySpace,
|
---|
| 25 | TimeLineInfo timeline) {
|
---|
| 26 | this.agent = agent;
|
---|
| 27 | this.utilitySpace = utilitySpace;
|
---|
| 28 | this.timeline = timeline;
|
---|
| 29 | this.bidsOpt = new OPTComponent(agent,
|
---|
| 30 | (AdditiveUtilitySpace) utilitySpace);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | public boolean termination() {
|
---|
| 34 | double time = timeline.getTime();
|
---|
| 35 | double lastBidUtil = utilitySpace.getUtility(agent.lastBid);
|
---|
| 36 | if (agent.delta == 1)
|
---|
| 37 | return false;
|
---|
| 38 | if (time >= 0.9985 + agent.delta * 0.0008 && lastBidUtil <= agent.theta) {
|
---|
| 39 | return true;
|
---|
| 40 | }
|
---|
| 41 | if (agent.TFC.lf_slope < agent.theta
|
---|
| 42 | / Math.pow(agent.delta, timeline.getTime() * agent.theta)) {
|
---|
| 43 | return true;
|
---|
| 44 | }
|
---|
| 45 | return false;
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | public boolean acceptance() {
|
---|
| 49 | double time = timeline.getTime();
|
---|
| 50 | double f_thre = agent.TFC.thresholdFunc();
|
---|
| 51 | if (time >= 0.9985 + agent.delta * 0.0008)
|
---|
| 52 | return true;
|
---|
| 53 | int conflict = (agent.opponentsMaxNumDistinctBids - agent.opponentsMinNumDistinctBids)
|
---|
| 54 | + (agent.opponentsMaxNumDistinctAccepts - agent.opponentsMinNumDistinctAccepts);
|
---|
| 55 | if (conflict < agent.numParties
|
---|
| 56 | && agent.prevLastAction instanceof Offer) {
|
---|
| 57 | return false;
|
---|
| 58 | }
|
---|
| 59 | if (time > 0.5 && agent.myLastAction instanceof Accept) {
|
---|
| 60 | return false;
|
---|
| 61 | } else {
|
---|
| 62 | double lastBidUtil = utilitySpace.getUtility(agent.lastBid);
|
---|
| 63 | if (agent.prevLastAction instanceof Accept) {
|
---|
| 64 | lastBidUtil /= Math.pow(agent.delta * 0.95, agent.delta * time);
|
---|
| 65 | }
|
---|
| 66 | if (time < agent.delta * 0.9) {
|
---|
| 67 | if (Math.min(f_thre * Math.pow(agent.delta, time / 5.),
|
---|
| 68 | agent.uqUtil + agent.stdUtil) <= lastBidUtil) {
|
---|
| 69 | return true;
|
---|
| 70 | }
|
---|
| 71 | return false;
|
---|
| 72 | }
|
---|
| 73 | if (f_thre * Math.pow(agent.delta, time / 3.) <= lastBidUtil) {
|
---|
| 74 | return true;
|
---|
| 75 | }
|
---|
| 76 | return false;
|
---|
| 77 | }
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | public Bid bidProposal() {
|
---|
| 81 | Bid bid = null;
|
---|
| 82 | double f_thre = agent.TFC.thresholdFunc();
|
---|
| 83 | try {
|
---|
| 84 | bid = bidsOpt.getOptimalBidByThredhold(f_thre + (1.5 - agent.delta)
|
---|
| 85 | * agent.stdUtil);
|
---|
| 86 | } catch (Exception e) {
|
---|
| 87 | System.out.println((new StringBuilder(
|
---|
| 88 | "getOptimalBidByThredhold failed!!\n")));
|
---|
| 89 | e.printStackTrace(System.out);
|
---|
| 90 | e.printStackTrace();
|
---|
| 91 | return null;
|
---|
| 92 | }
|
---|
| 93 | return bid;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | }
|
---|