Loading src/main/java/fr/greyc/mad/framework/model/AbstractScheduler.java +11 −9 Original line number Diff line number Diff line Loading @@ -7,30 +7,32 @@ import java.util.MissingResourceException; import java.util.Set; import java.util.concurrent.TimeoutException; import fr.greyc.mad.framework.engine.agents.AgentMind; public abstract class AbstractScheduler implements IScheduler { private Map<AgentMind, AgentBody> embodiment; private Map<AgentMindID, AgentBodyID> embodiment; private Environment environment; private IDirectoryAdapter adapter; @Override public List<Action> getActions(AgentMind mind) { public List<Action> getActions(AgentMindID mind) { List<Action> retour = environment.getEnvironmentActions(); retour.addAll(embodiment.get(mind).getActions()); AgentBodyID bodyID = embodiment.get(mind); List<Action> bodyActions = adapter.getActions(bodyID); retour.addAll(bodyActions); return retour; } @Override public List<Observation<?>> getObservations(AgentMind mind) { public List<Observation<?>> getObservations(AgentMindID mind) { List<Observation<?>> retour = environment.getEnvironmentObservations(); retour.addAll(embodiment.get(mind).getObservations()); AgentBodyID bodyID = embodiment.get(mind); List<Observation<?>> bodyActions = adapter.getObservations(bodyID); retour.addAll(bodyActions); return retour; } @Override public void setAdapter(IDirectoryAdapter myDirectoryAdapter) { // TODO Auto-generated method stub adapter = myDirectoryAdapter; } @Override Loading src/main/java/fr/greyc/mad/framework/model/Environment.java +2 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ package fr.greyc.mad.framework.model; import java.util.List; public abstract class Environment { private List<AgentBody> bodies; public Environment() { } Loading src/main/java/fr/greyc/mad/framework/model/IDirectoryAdapter.java +6 −1 Original line number Diff line number Diff line package fr.greyc.mad.framework.model; public interface IDirectoryAdapter {}; import java.util.List; public interface IDirectoryAdapter { List<Action> getActions(AgentBodyID bodyID); List<Observation<?>> getObservations(AgentBodyID bodyID); }; src/main/java/fr/greyc/mad/framework/model/IScheduler.java +4 −7 Original line number Diff line number Diff line Loading @@ -9,15 +9,12 @@ package fr.greyc.mad.framework.model; import java.lang.SecurityException; import java.util.HashMap; import java.util.List; import java.util.MissingResourceException; import java.util.Set; import java.util.concurrent.TimeoutException; import fr.greyc.mad.framework.engine.agents.AgentMind; public interface IScheduler { /** Loading Loading @@ -126,7 +123,7 @@ public interface IScheduler { * @param HashMap<String, Action> Associates an AgentBody ID with a given action. * @throws MissingResourceException If the Environment does not exist. */ public void executeJointAction(HashMap<String, Action> myJointAction) throws MissingResourceException; public void executeJointAction(HashMap<AgentBodyID, Action> myJointAction) throws MissingResourceException; /** * Return a set of observation for each AgentBody. This method can be used Loading @@ -135,7 +132,7 @@ public interface IScheduler { * @return HashMap<String, Set<Observation>> Associates an AgentBody ID with a given Set of Observations. * @throws MissingResourceException If the Environment does not exist. */ public HashMap<String, Set<Observation>> getObservations() throws MissingResourceException; public HashMap<AgentBodyID, Set<Observation>> getObservations() throws MissingResourceException; /** * Communicate to each registered AgentMind the Observation provided by the AgentBody Loading @@ -143,7 +140,7 @@ public interface IScheduler { * * @param myObservations An association between AgentBody and Set of Observation. */ public void distributeObservations(HashMap<String, Set<Observation>> myObservations); public void distributeObservations(HashMap<AgentBodyID, Set<Observation>> myObservations); /** * Return the reward for each AgentBody. Loading @@ -151,7 +148,7 @@ public interface IScheduler { * @return HashMap<String, Reward> Associates an AgentBody ID with a given reward. * @throws MissingResourceException If the Environment does not exist. */ public HashMap<String, Reward> getRewards() throws MissingResourceException; public HashMap<AgentBodyID, Reward> getRewards() throws MissingResourceException; /** * Request the environment to execute the specific action issued by a given Loading Loading
src/main/java/fr/greyc/mad/framework/model/AbstractScheduler.java +11 −9 Original line number Diff line number Diff line Loading @@ -7,30 +7,32 @@ import java.util.MissingResourceException; import java.util.Set; import java.util.concurrent.TimeoutException; import fr.greyc.mad.framework.engine.agents.AgentMind; public abstract class AbstractScheduler implements IScheduler { private Map<AgentMind, AgentBody> embodiment; private Map<AgentMindID, AgentBodyID> embodiment; private Environment environment; private IDirectoryAdapter adapter; @Override public List<Action> getActions(AgentMind mind) { public List<Action> getActions(AgentMindID mind) { List<Action> retour = environment.getEnvironmentActions(); retour.addAll(embodiment.get(mind).getActions()); AgentBodyID bodyID = embodiment.get(mind); List<Action> bodyActions = adapter.getActions(bodyID); retour.addAll(bodyActions); return retour; } @Override public List<Observation<?>> getObservations(AgentMind mind) { public List<Observation<?>> getObservations(AgentMindID mind) { List<Observation<?>> retour = environment.getEnvironmentObservations(); retour.addAll(embodiment.get(mind).getObservations()); AgentBodyID bodyID = embodiment.get(mind); List<Observation<?>> bodyActions = adapter.getObservations(bodyID); retour.addAll(bodyActions); return retour; } @Override public void setAdapter(IDirectoryAdapter myDirectoryAdapter) { // TODO Auto-generated method stub adapter = myDirectoryAdapter; } @Override Loading
src/main/java/fr/greyc/mad/framework/model/Environment.java +2 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ package fr.greyc.mad.framework.model; import java.util.List; public abstract class Environment { private List<AgentBody> bodies; public Environment() { } Loading
src/main/java/fr/greyc/mad/framework/model/IDirectoryAdapter.java +6 −1 Original line number Diff line number Diff line package fr.greyc.mad.framework.model; public interface IDirectoryAdapter {}; import java.util.List; public interface IDirectoryAdapter { List<Action> getActions(AgentBodyID bodyID); List<Observation<?>> getObservations(AgentBodyID bodyID); };
src/main/java/fr/greyc/mad/framework/model/IScheduler.java +4 −7 Original line number Diff line number Diff line Loading @@ -9,15 +9,12 @@ package fr.greyc.mad.framework.model; import java.lang.SecurityException; import java.util.HashMap; import java.util.List; import java.util.MissingResourceException; import java.util.Set; import java.util.concurrent.TimeoutException; import fr.greyc.mad.framework.engine.agents.AgentMind; public interface IScheduler { /** Loading Loading @@ -126,7 +123,7 @@ public interface IScheduler { * @param HashMap<String, Action> Associates an AgentBody ID with a given action. * @throws MissingResourceException If the Environment does not exist. */ public void executeJointAction(HashMap<String, Action> myJointAction) throws MissingResourceException; public void executeJointAction(HashMap<AgentBodyID, Action> myJointAction) throws MissingResourceException; /** * Return a set of observation for each AgentBody. This method can be used Loading @@ -135,7 +132,7 @@ public interface IScheduler { * @return HashMap<String, Set<Observation>> Associates an AgentBody ID with a given Set of Observations. * @throws MissingResourceException If the Environment does not exist. */ public HashMap<String, Set<Observation>> getObservations() throws MissingResourceException; public HashMap<AgentBodyID, Set<Observation>> getObservations() throws MissingResourceException; /** * Communicate to each registered AgentMind the Observation provided by the AgentBody Loading @@ -143,7 +140,7 @@ public interface IScheduler { * * @param myObservations An association between AgentBody and Set of Observation. */ public void distributeObservations(HashMap<String, Set<Observation>> myObservations); public void distributeObservations(HashMap<AgentBodyID, Set<Observation>> myObservations); /** * Return the reward for each AgentBody. Loading @@ -151,7 +148,7 @@ public interface IScheduler { * @return HashMap<String, Reward> Associates an AgentBody ID with a given reward. * @throws MissingResourceException If the Environment does not exist. */ public HashMap<String, Reward> getRewards() throws MissingResourceException; public HashMap<AgentBodyID, Reward> getRewards() throws MissingResourceException; /** * Request the environment to execute the specific action issued by a given Loading