public class AdaptiveStepper implements Script { public void run() { int tick = Engine.get().getTicks(); Log.log("Tick: " + tick); StatsManager.get().update(); AdaptiveCycleApp.environment.run(); Layer layer = LayerManager.get().getObjects().get(0); ArrayList agents = layer.getAgents(); ArrayList agentList = new ArrayList(); for (int i = 0; i < agents.size(); i++) { AdaptiveAgent a = (AdaptiveAgent)agents.get(i); a.update(); agentList.add(a); } while (!agentList.isEmpty()) { AdaptiveAgent agent = (AdaptiveAgent)RandomValue.get().getRandomObjectFromArray(agentList); agent.step(); if(agent.getActions() == 0) { agentList.remove(agent); } } } } public class AdaptiveAgent extends AbstractHost { private double x; private double y; private BeliefManager beliefManager; private MemoryManager partnerMemory; private MemoryManager actionMemory; private BehaviourManager behaviourManager; private ArrayList initiatedPartners = new ArrayList(); private double actions; private Belief criticalBelief; private GroupCollector groupCollector; private double orientation; private double stressThreshold; private Belief initialBelief; private ArrayList partners; public AdaptiveAgent() { super("AdaptiveAgent"); actions = LayerManager.get().getObject("Agents").getAgency("Adaptive").getVariable("ACTIONS_PER_TURN").getValue(); x = Maths.round(RandomValue.get().nextDouble(), 5); y = Maths.round(RandomValue.get().nextDouble(), 5); beliefManager = new BeliefManager(this); initialBelief = beliefManager.addNewBelief(); partnerMemory = new MemoryManager(this); actionMemory = new MemoryManager(this); behaviourManager = new BehaviourManager(this); groupCollector = null; updateBeliefState(); orientation = RandomValue.get().nextDouble(true); double deviation = Maths.round(AdaptiveAgency.getValue("STRESS_VARIABILITY") * orientation, 5); stressThreshold = Maths.round(AdaptiveAgency.getValue("STRESS_THRESHOLD") + deviation, 5); partners = new ArrayList(); } public void init() { double radius = LayerManager.get().getObject("Agents").getAgency("Adaptive").getVariable("GROUP_SIZE").getValue(); for(AdaptiveAgent a : new ContactCollector(this, x, y, radius).getContacts()) { partnerMemory.add(a, 1.0); addBelief(a.getInitialBelief().getName()); } } public void update() { actions = AdaptiveAgency.getValue("ACTIONS_PER_TURN"); updateAgentState(); behaviourManager.update(); partnerMemory.update(); actionMemory.update(); initiatedPartners.clear(); behaviourManager.getCurrentBehaviour().init(); partners.clear(); } public void updateBeliefState() { criticalBelief = null; double maxValue = -Double.MAX_VALUE; for (Belief belief : beliefManager.getBelief().values()) { if (belief.getValue() > maxValue) { criticalBelief = belief; maxValue = belief.getValue(); } } if(criticalBelief == null) { criticalBelief = beliefManager.addNewBelief(); } } public void updateAgentState() { beliefManager.update(); updateBeliefState(); } @Override public void step() { if (actions > 0) { behaviourManager.getCurrentBehaviour().initiate(); } } public boolean acceptAction(Action action) { Behaviours currentBehaviour = behaviourManager.getCurrentBehaviour(); return currentBehaviour.acceptAction(action); } public void addActionResult(Action action, double value) { actionMemory.add(action, value); partnerMemory.add(action.getPartner(), value); addPartner(action.getPartner()); } public boolean isCompatible(Action action) { return beliefManager.hasBelief(action.getExchange().getBelief()); } public Belief getBelief(String beliefName) { return beliefManager.getBelief(beliefName); } public double getStress() { return beliefManager.getLastStressValue(); } public void addBeliefValue(String beliefName, double value) { beliefManager.addValue(beliefName, value); updateBeliefState(); } public boolean canInitiateWith(AdaptiveAgent partner) { return !hasInitiatedWith(partner) & partner.getActions() > 0; } public boolean hasInitiatedWith(AdaptiveAgent agent) { return initiatedPartners.contains(agent); } public ArrayList getInitiatedPartners() { return initiatedPartners; } public double getActions() { return actions; } public void incrementActions() { actions++; } public void decrementActions() { actions--; } public boolean hasBelief(String beliefName) { return beliefManager.hasBelief(beliefName); } public void addBelief(String beliefName) { beliefManager.addBelief(beliefName); updateBeliefState(); } public void removeBelief(String beliefName) { beliefManager.removeBelief(beliefName); updateBeliefState(); } public Belief getCriticalBelief() { return criticalBelief; } public BeliefManager getBeliefManager() { return beliefManager; } public BehaviourManager getBehaviourManager() { return behaviourManager; } // This method is required by the library interface and doesn't have any functionality @Override public Window getAgentWindow() { return null; } public double getX() { return x; } public double getY() { return y; } public MemoryManager getActionMemory() { return actionMemory; } public MemoryManager getPartnerMemory() { return partnerMemory; } public Belief[] getBeliefs() { int size = beliefManager.getBelief().values().size(); return beliefManager.getBelief().values().toArray(new Belief[size]); } public boolean isFriend(AdaptiveAgent contact) { return partnerMemory.getValue(contact) > 0; } public Belief getBestBelief() { double minValue = Double.MAX_VALUE; Belief bestBelief = null; for(Belief s : getBeliefs()) { double value = s.getLastValue(); if(value < minValue & value < 0) { minValue = value; bestBelief = s; } } return bestBelief; } public Action getBestAction(String beliefName) { double maxValue = -Double.MIN_VALUE; Action bestAction = null; for(Action a : actionMemory.getItems()) { if(a.hasBelief(beliefName)) { if(isCompatible(a) & canInitiateWith(a.getPartner())) { double value = actionMemory.getValue(a); if(value > maxValue) { maxValue = value; bestAction = a; } } } } return bestAction; } public AdaptiveAgent getBestPartner(String beliefName) { double maxValue = Double.MIN_VALUE; AdaptiveAgent bestPartner = null; for(AdaptiveAgent a : partnerMemory.getItems()) { if(a.hasBelief(beliefName) & canInitiateWith(a)) { double value = partnerMemory.getValue(a); if(value > maxValue) { maxValue = value; bestPartner = a; } } } return bestPartner; } public AdaptiveAgent getBestPartner() { double maxValue = Double.MIN_VALUE; AdaptiveAgent bestPartner = null; for(AdaptiveAgent a : partnerMemory.getItems()) { if(canInitiateWith(a)) { double value = partnerMemory.getValue(a); if(value > maxValue) { maxValue = value; bestPartner = a; } } } return bestPartner; } public HashMap getGroupMembers() { return groupCollector.getGroupMembers(); } public GroupCollector getGroupCollector() { return groupCollector; } public HashMap collectGroupMembers() { groupCollector = new GroupCollector(this); return groupCollector.getGroupMembers(); } public double getCurrentStress() { return beliefManager.getCurrentStress(); } public double getStressThreshold() { return stressThreshold; } public Belief getInitialBelief() { return initialBelief; } public void addPartner(AdaptiveAgent partner) { partners.add(partner); } public boolean hasRemovedBelief(String beliefName) { return beliefManager.hasRemovedBelief(beliefName); } public Belief getRemovedBelief(String beliefName) { return beliefManager.getRemovedBelief(beliefName); } } public class ContactCollector { private ArrayList contacts; public ArrayList getContacts() { return contacts; } public ContactCollector(AdaptiveAgent agent, double x, double y, double radius) { contacts = new ArrayList(); int attempts = 0; while (contacts.isEmpty() & attempts < 100) { for(Agents a : LayerManager.get().getObject("Agents").getAgents()) { AdaptiveAgent aa = (AdaptiveAgent)a; if (aa == agent) { continue; } double aX = aa.getX(); double aY = aa.getY(); aX = Maths.round(Math.abs(x - aX), 5); aY = Maths.round(Math.abs(y - aY), 5); double distance = Math.sqrt((aX * aX) + (aY * aY)); distance = Maths.round(distance, 5); if (distance < radius) { contacts.add(aa); } } if (contacts.isEmpty()) { x = Maths.round(RandomValue.get().nextDouble(), 5); y = Maths.round(RandomValue.get().nextDouble(), 5); } attempts++; } } } public class Belief extends Name { private double change; private double value; private double lastValue; public Belief(String name, double quantity, double change) { super(name); value = -quantity; this.change = change; lastValue = value; } public double update() { lastValue = value; value = change; value = Maths.round(value, 5); return value; } public double reduce(double amount) { value = Maths.subtract(value, amount); return value; } public double increase(double amount) { value = Maths.add(value, amount); return value; } public double getChange() { return change; } public void setChange(double change) { this.change = change; } public void increaseChange(double amount) { change += amount; change = Maths.round(change, 5); } public void decreaseChange(double amount) { change -= amount; change = Maths.round(change, 5); } public double getValue() { return value; } public void setValue(double value) { this.value = value; } public double getLastValue() { return lastValue; } } public class BeliefManager extends Manager { private HashMap beliefs; private HashMap removedBeliefs; private double stress; private double lastStressValue; public BeliefManager(AdaptiveAgent agent) { super(agent); beliefs = new HashMap(); stress = 0; lastStressValue = 0; removedBeliefs = new HashMap(); } @Override public void update() { lastStressValue = stress; for(Belief belief : getBelief().values()) { belief.update(); } updateValues(); } private void updateValues() { stress = 0; for(Belief belief : beliefs.values()) { stress += belief.getValue(); } stress = Maths.round(stress, 5); } public Belief getBelief(String beliefName) { return beliefs.get(beliefName); } public Belief addBelief(String beliefName) { Belief belief = null; if(removedBeliefs.containsKey(beliefName)) { belief = removedBeliefs.remove(beliefName); } else { belief = getNewBeliefInstance(beliefName); } beliefs.put(beliefName, belief); updateValues(); return beliefs.get(beliefName); } public Belief addNewBelief() { Belief belief = createNewBelief(); beliefs.put(belief.getName(), belief); updateValues(); return beliefs.get(belief.getName()); } public void removeBelief(String beliefName) { Belief s = beliefs.remove(beliefName); if(!removedBeliefs.containsKey(beliefName)) { removedBeliefs.put(beliefName, s); } updateValues(); } public void addValue(String beliefName, double value) { beliefs.get(beliefName).reduce(value); updateValues(); } private Belief createNewBelief() { double change = RandomValue.get().nextDouble(); while (change == 0) { change = RandomValue.get().nextDouble(); } return new Belief(NameGenerator.nextName(), 1.0, change); } private Belief getNewBeliefInstance(String beliefName) { double change = RandomValue.get().nextDouble(); while (change == 0) { change = RandomValue.get().nextDouble(); } return new Belief(beliefName, 1.0, change); } public double getCurrentStress() { return stress; } public HashMap getBelief() { return beliefs; } public boolean hasBelief(String beliefName) { return beliefs.containsKey(beliefName); } public double getLastStressValue() { return lastStressValue; } public boolean hasRemovedBelief(String beliefName) { return removedBeliefs.containsKey(beliefName); } public Belief getRemovedBelief(String beliefName) { return removedBeliefs.get(beliefName); } } public class Memory { private HashMap> items; private double initialDecay; private double threshold; public Memory() { items = new HashMap>(); initialDecay = AdaptiveAgency.getValue("MEMORY_DECAY"); threshold = AdaptiveAgency.getValue("MEMORY_THRESHOLD"); } public ArrayList getItemNames() { ArrayList itemNames = new ArrayList(); for(String item : items.keySet()) { itemNames.add(item); } return itemNames; } public void update() { ArrayList> forgotten = new ArrayList>(); for (MemoryItem item : items.values()) { item.decay(); if (item.getActivation() < threshold) { forgotten.add(item); } } for (MemoryItem item : forgotten) { items.remove(item.getObject().getName()); } } public void addItem(T item) { if (items.containsKey(item.getName())) { items.get(item.getName()).refresh(); } else { items.put(item.getName(), new MemoryItem(item, initialDecay)); } } public void addItem(T item, double value) { if (items.containsKey(item.getName())) { items.get(item.getName()).refresh(); } else { items.put(item.getName(), new MemoryItem(item, initialDecay, value)); } items.get(item.getName()).addValue(value); } public double getActivation(String itemName) { Double value = null; if (items.containsKey(itemName)) { value = items.get(itemName).getActivation(); } return value; } public double getActivation(T item) { return getActivation(item.getName()); } public double getValue(String itemName) { Double value = null; if (items.containsKey(itemName)) { value = items.get(itemName).getValue(); } return value; } public double getStrength(String itemName) { Double value = null; if (items.containsKey(itemName)) { value = items.get(itemName).getStrength(); } return value; } public double getValue(T item) { return getValue(item.getName()); } public T getItem(String itemName) { if (hasItem(itemName)) { return items.get(itemName).getObject(); } return null; } public ArrayList getItems() { ArrayList returnedItems = new ArrayList(); for (MemoryItem i : items.values()) { returnedItems.add(i.getObject()); } return returnedItems; } public boolean hasItem(String itemName) { return items.containsKey(itemName); } public boolean hasItem(T item) { return items.containsKey(item.getName()); } public boolean hasItems() { return items.size() > 0; } public int size() { return items.size(); } public void remove(T item) { if(items.containsKey(item.getName())) { items.remove(item.getName()); } } } public class MemoryItem { private T obj; private double initialStrength; private double strength; private double n; private double activation; private MovingAverage value; public MemoryItem(T obj, double initialDecay) { this.obj = obj; this.initialStrength = Maths.round(1 - initialDecay, 2); strength = this.initialStrength; n = 1; activation = 1; value = new MovingAverage(5); } public MemoryItem(T obj, double initialDecay, double value) { this.obj = obj; this.initialStrength = Maths.round(1 - initialDecay, 2); strength = this.initialStrength; n = 1; activation = 1; this.value = new MovingAverage(5); this.value.addValue(value); } public double decay() { activation *= strength; return activation; } public double refresh() { double denominator = Math.pow(2, n); // Note: This check is here due to limitations related to Java. if(n < 1023) { n++; } strength += Maths.divide(initialStrength, denominator, 5); activation = 1; return activation; } public T getObject() { return obj; } public double addValue(double value) { this.value.addValue(value); return this.value.getValue(); } public double getActivation() { return activation; } public void setActivation(double activation) { this.activation = activation; } public double getValue() { return value.getValue(); } public double getStrength() { return strength; } } public class BehaviourManager extends Manager { private Behaviours currentBehaviour; public BehaviourManager(AdaptiveAgent agent) { super(agent); currentBehaviour = BehaviourLibrary.getBehaviour("LOCAL", agent); } @Override public void update() { currentBehaviour = BehaviourLibrary.getBehaviour("LOCAL", agent); if(Engine.get().getTicks() > 9 & agent.getStress() < agent.getStressThreshold()) { currentBehaviour = BehaviourLibrary.getBehaviour("GLOBAL", agent); } } public Behaviours getCurrentBehaviour() { return currentBehaviour; } } public class Global extends Behaviour { public Global(AdaptiveAgent agent) { super("GLOBAL", agent); } public void init() { } public boolean initiate() { boolean hasActed = false; Belief belief = agent.getCriticalBelief(); Action action = null; action = agent.getBestAction(belief.getName()); if(action != null) { if(agent.getActionMemory().getValue(action) < RandomValue.get().nextDouble()) { AdaptiveAgent partner = agent.getBestPartner(belief.getName()); if(partner != null) { action = new Action(agent, partner, new Exchange(agent, partner, belief.getName())); } } } else { AdaptiveAgent partner = agent.getBestPartner(); if(partner != null) { action = new Action(agent, partner, new Exchange(agent, partner, belief.getName())); } else { double minValue = agent.getStress(); for(AdaptiveAgent p : agent.getPartnerMemory().getItems()) { if(p.getStress() < minValue) { minValue = p.getStress(); } } AdaptiveAgent randomAgent = getRandomUnknownAgent(); if(randomAgent != null) { if(randomAgent.getStress() < minValue) { belief = randomAgent.getBestBelief(); if(belief != null) { agent.addBelief(belief.getName()); action = new Action(agent, randomAgent, new Exchange(agent, randomAgent, belief.getName())); } } } } } if(action != null) { if(action.getPartner().acceptAction(action)) { action.act(); hasActed = true; } else { agent.addActionResult(action, 0); } } agent.decrementActions(); return hasActed; } @Override public boolean acceptAction(Action action) { boolean accept = true; if(agent.hasRemovedBelief(action.getBelief())) { accept = agent.getRemovedBelief(action.getBelief()).getLastValue() < agent.getStressThreshold(); } if(accept) { if(!agent.hasBelief(action.getBelief())) { agent.addBelief(action.getBelief()); } } return accept; } private AdaptiveAgent getRandomUnknownAgent() { ArrayList agents = LayerManager.get().getObjects().get(0).getAgents(); agents.remove(agent); AdaptiveAgent returnedAgent = null; while (returnedAgent == null & !agents.isEmpty()) { AdaptiveAgent randomAgent = (AdaptiveAgent)RandomValue.get().getRandomObjectFromArray(agents); agents.remove(randomAgent); if (agent.canInitiateWith(randomAgent) & ! agent.getPartnerMemory().has(randomAgent)) { returnedAgent = randomAgent; } } return returnedAgent; } } public class Local extends Behaviour { HashMap groupMembers; public Local(AdaptiveAgent agent) { super("LOCAL", agent); } public void init() { groupMembers = agent.collectGroupMembers(); for(AdaptiveAgent a : agent.getPartnerMemory().getItems()) { if(!groupMembers.containsKey(a)) { agent.getPartnerMemory().add(a, 0); } } for(Belief s : agent.getBeliefs()) { boolean hasBelief = false; for(AdaptiveAgent a : groupMembers.keySet()) { if(a.hasBelief(s.getName())) { hasBelief = true; } } if(!hasBelief) { agent.removeBelief(s.getName()); } } } public boolean initiate() { HashMap groupMembers = agent.getGroupMembers(); boolean hasActed = false; Action action = null; Belief belief = agent.getCriticalBelief(); AdaptiveAgent partner = null; double maxValue = -Double.MIN_VALUE; for(AdaptiveAgent p : groupMembers.keySet()) { if(agent.canInitiateWith(p)) { double value = groupMembers.get(p); if(value > maxValue) { maxValue = value; partner = p; } } } if(partner != null) { maxValue = Double.MIN_VALUE; for(Action a : agent.getActionMemory().getItems()) { if(a.getPartner() == partner) { if(a.hasBelief(belief.getName())) { if(agent.isCompatible(a)) { double value = agent.getActionMemory().getValue(a); if(value > maxValue) { maxValue = value; action = a; } } } } } if(action == null) { action = new Action(agent, partner, new Exchange(agent, partner, belief.getName())); } } if(action != null) { if(action.getPartner().acceptAction(action)) { action.act(); hasActed = true; } else { agent.addActionResult(action, 0); } } agent.decrementActions(); if(!hasActed) { agent.removeBelief(belief.getName()); } return hasActed; } public boolean acceptAction(Action action) { boolean accept = false; if(groupMembers.containsKey(action.getAgent())) { if(!agent.hasRemovedBelief(action.getBelief())) { accept = true; if(!agent.hasBelief(action.getBelief())) { agent.addBelief(action.getBelief()); } } } return accept; } } public class Global extends Behaviour { public Global(AdaptiveAgent agent) { super("GLOBAL", agent); } public void init() { } public boolean initiate() { boolean hasActed = false; Belief belief = agent.getCriticalBelief(); Action action = null; action = agent.getBestAction(belief.getName()); if(action != null) { if(agent.getActionMemory().getValue(action) < RandomValue.get().nextDouble()) { AdaptiveAgent partner = agent.getBestPartner(belief.getName()); if(partner != null) { action = new Action(agent, partner, new Exchange(agent, partner, belief.getName())); } } } else { AdaptiveAgent partner = agent.getBestPartner(); if(partner != null) { action = new Action(agent, partner, new Exchange(agent, partner, belief.getName())); } else { double minValue = agent.getStress(); for(AdaptiveAgent p : agent.getPartnerMemory().getItems()) { if(p.getStress() < minValue) { minValue = p.getStress(); } } AdaptiveAgent randomAgent = getRandomUnknownAgent(); if(randomAgent != null) { if(randomAgent.getStress() < minValue) { belief = randomAgent.getBestBelief(); if(belief != null) { agent.addBelief(belief.getName()); action = new Action(agent, randomAgent, new Exchange(agent, randomAgent, belief.getName())); } } } } } if(action != null) { if(action.getPartner().acceptAction(action)) { action.act(); hasActed = true; } else { agent.addActionResult(action, 0); } } agent.decrementActions(); return hasActed; } @Override public boolean acceptAction(Action action) { boolean accept = true; if(agent.hasRemovedBelief(action.getBelief())) { accept = agent.getRemovedBelief(action.getBelief()).getLastValue() < agent.getStressThreshold(); } if(accept) { if(!agent.hasBelief(action.getBelief())) { agent.addBelief(action.getBelief()); } } return accept; } private AdaptiveAgent getRandomUnknownAgent() { ArrayList agents = LayerManager.get().getObjects().get(0).getAgents(); agents.remove(agent); AdaptiveAgent returnedAgent = null; while (returnedAgent == null & !agents.isEmpty()) { AdaptiveAgent randomAgent = (AdaptiveAgent)RandomValue.get().getRandomObjectFromArray(agents); agents.remove(randomAgent); if (agent.canInitiateWith(randomAgent) & ! agent.getPartnerMemory().has(randomAgent)) { returnedAgent = randomAgent; } } return returnedAgent; } } public class GroupCollector { private AdaptiveAgent agent; protected HashMap commonPartners = null; protected HashMap groupMembers = null; public GroupCollector(AdaptiveAgent agent) { this.agent = agent; } public HashMap collectGroupMembers() { groupMembers = new HashMap(); if(commonPartners == null) { collectCommonPartners(); } for(AdaptiveAgent a1 : commonPartners.keySet()) { if(commonPartners.get(a1) > 0) { int value = commonPartners.get(a1); groupMembers.put(a1, value); } } return groupMembers; } public HashMap getGroupMembers() { if(groupMembers == null) { collectGroupMembers(); } return groupMembers; } public HashMap collectCommonPartners() { if(commonPartners == null) { commonPartners = new HashMap(); for(AdaptiveAgent a1 : agent.getPartnerMemory().getItems()) { if(agent.isFriend(a1)) { Integer cp = 0; for (AdaptiveAgent tr : a1.getPartnerMemory().getItems()) { for(AdaptiveAgent r2 : agent.getPartnerMemory().getItems()) { if(tr.getName().equals(r2.getName())) { cp++; } } } commonPartners.put(a1, cp); } } } return commonPartners; } } public class Action extends Name { private Exchange exchange; private AdaptiveAgent agent; private AdaptiveAgent partner; public Action(AdaptiveAgent agent, AdaptiveAgent partner, Exchange exchange) { super(NameGenerator.nextName()); this.agent = agent; this.partner = partner; this.exchange = exchange; } private Action(String name, AdaptiveAgent agent, AdaptiveAgent partner, Exchange exchange) { super(name); this.agent = agent; this.partner = partner; this.exchange = exchange; } public void act() { double agentStressBefore = agent.getCurrentStress(); double partnerStressBefore = partner.getCurrentStress(); exchange.exchange(); double agentValue = Maths.round(agentStressBefore - agent.getCurrentStress(), 5); double partnerValue = Maths.round(partnerStressBefore - partner.getCurrentStress(), 5); agent.addActionResult(this, agentValue); partner.addActionResult(getInverse(), partnerValue); agent.getInitiatedPartners().add(partner); StatsManager.get().addNetworkLink(agent, partner); } public Action getInverse() { return new Action(name, partner, agent, exchange.getInverse()); } public boolean hasBelief(String beliefName) { return exchange.getBelief().equals(beliefName); } public Exchange getExchange() { return exchange; } public AdaptiveAgent getAgent() { return agent; } public AdaptiveAgent getPartner() { return partner; } public String getBelief() { return exchange.getBelief(); } } public class Exchange extends Name { private double agentValue; private double partnerValue; private String belief; private AdaptiveAgent agent; private AdaptiveAgent partner; public Exchange(AdaptiveAgent agent, AdaptiveAgent partner, String belief) { super(NameGenerator.nextName()); this.agent = agent; this.partner = partner; this.belief = belief; this.agentValue = RandomValue.get().nextDouble(); this.partnerValue = RandomValue.get().nextDouble(); } private Exchange(String name, AdaptiveAgent agent, AdaptiveAgent partner, String belief, double agentValue, double partnerValue) { super(name); this.agent = agent; this.partner = partner; this.belief = belief; this.agentValue = agentValue; this.partnerValue = partnerValue; } public void exchange() { agent.addBeliefValue(belief, agentValue); partner.addBeliefValue(belief, partnerValue); } public double getAgentValue() { return agentValue; } public double getPartnerValue() { return partnerValue; } public String getBelief() { return belief; } public AdaptiveAgent getAgent() { return agent; } public AdaptiveAgent getPartner() { return partner; } public Exchange getInverse() { return new Exchange(name, partner, agent, belief, partnerValue, agentValue); } }