[127] | 1 | package negotiator.boaframework.agent;
|
---|
| 2 |
|
---|
| 3 | import genius.core.boaframework.BOAagentBilateral;
|
---|
| 4 | import genius.core.boaframework.BOAagentInfo;
|
---|
| 5 | import genius.core.boaframework.repository.BOAagentRepository;
|
---|
| 6 |
|
---|
| 7 | /**
|
---|
| 8 | * This class is used to convert a BOA agent created using the GUI to a real
|
---|
| 9 | * agent. The parseStrategyParameters loads the information object, the
|
---|
| 10 | * agentSetup uses the information object to load the agent using reflection.
|
---|
| 11 | *
|
---|
| 12 | * For more information, see: Baarslag T., Hindriks K.V., Hendrikx M.,
|
---|
| 13 | * Dirkzwager A., Jonker C.M. Decoupling Negotiating Agents to Explore the Space
|
---|
| 14 | * of Negotiation Strategies. Proceedings of The Fifth International Workshop on
|
---|
| 15 | * Agent-based Complex Automated Negotiations (ACAN 2012), 2012.
|
---|
| 16 | * http://mmi.tudelft.nl/sites/default/files/boa.pdf
|
---|
| 17 | *
|
---|
| 18 | * @author Tim Baarslag, Alex Dirkzwager, Mark Hendrikx
|
---|
| 19 | */
|
---|
| 20 | public class TheBOAagent extends BOAagentBilateral {
|
---|
| 21 |
|
---|
| 22 | /** Name of the agent */
|
---|
| 23 | private String name = "";
|
---|
| 24 | /** Information object that stores the decoupled agent description */
|
---|
| 25 | private BOAagentInfo dagent;
|
---|
| 26 |
|
---|
| 27 | /**
|
---|
| 28 | * Loads and initializes the decoupled components of the agent.
|
---|
| 29 | */
|
---|
| 30 | @Override
|
---|
| 31 | public void agentSetup() {
|
---|
| 32 |
|
---|
| 33 | // load the class names of each object
|
---|
| 34 | String os = dagent.getOfferingStrategy().getClassname();
|
---|
| 35 | String as = dagent.getAcceptanceStrategy().getClassname();
|
---|
| 36 | String om = dagent.getOpponentModel().getClassname();
|
---|
| 37 | String oms = dagent.getOMStrategy().getClassname();
|
---|
| 38 |
|
---|
| 39 | // createFrom the actual objects using reflexion
|
---|
| 40 |
|
---|
| 41 | offeringStrategy = BOAagentRepository.getInstance().getOfferingStrategy(os);
|
---|
| 42 | acceptConditions = BOAagentRepository.getInstance().getAcceptanceStrategy(as);
|
---|
| 43 | opponentModel = BOAagentRepository.getInstance().getOpponentModel(om);
|
---|
| 44 | omStrategy = BOAagentRepository.getInstance().getOMStrategy(oms);
|
---|
| 45 |
|
---|
| 46 | // init the components.
|
---|
| 47 | try {
|
---|
| 48 | opponentModel.init(negotiationSession, dagent.getOpponentModel().getParameters());
|
---|
| 49 | opponentModel.setOpponentUtilitySpace(fNegotiation);
|
---|
| 50 | omStrategy.init(negotiationSession, opponentModel, dagent.getOMStrategy().getParameters());
|
---|
| 51 | offeringStrategy.init(negotiationSession, opponentModel, omStrategy,
|
---|
| 52 | dagent.getOfferingStrategy().getParameters());
|
---|
| 53 | acceptConditions.init(negotiationSession, offeringStrategy, opponentModel,
|
---|
| 54 | dagent.getAcceptanceStrategy().getParameters());
|
---|
| 55 | acceptConditions.setOpponentUtilitySpace(fNegotiation);
|
---|
| 56 | } catch (Exception e) {
|
---|
| 57 | e.printStackTrace();
|
---|
| 58 | }
|
---|
| 59 | // remove the reference to the information object such that the garbage
|
---|
| 60 | // collector can remove it.
|
---|
| 61 | dagent = null;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | /**
|
---|
| 65 | * Returns the name of the agent.
|
---|
| 66 | */
|
---|
| 67 | @Override
|
---|
| 68 | public String getName() {
|
---|
| 69 | return name;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | /**
|
---|
| 73 | * Removes the references to all components such that the garbage collector
|
---|
| 74 | * can remove them.
|
---|
| 75 | */
|
---|
| 76 | @Override
|
---|
| 77 | public void cleanUp() {
|
---|
| 78 | offeringStrategy = null;
|
---|
| 79 | acceptConditions = null;
|
---|
| 80 | opponentModel = null;
|
---|
| 81 | negotiationSession = null;
|
---|
| 82 | utilitySpace = null;
|
---|
| 83 | dagent = null;
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | /**
|
---|
| 87 | * Loads the BOA agent information object created by using the GUI. The
|
---|
| 88 | * {@link #agentSetup()} method uses this information to load the necessary
|
---|
| 89 | * components by using reflection.
|
---|
| 90 | */
|
---|
| 91 | @Override
|
---|
| 92 | public void parseStrategyParameters(String variables) throws Exception {
|
---|
| 93 | Serializer<BOAagentInfo> serializer = new Serializer<BOAagentInfo>("");
|
---|
| 94 | dagent = serializer.readStringToObject(variables);
|
---|
| 95 | name = dagent.getName();
|
---|
| 96 | }
|
---|
[1] | 97 | } |
---|