Commit cbb60b3b authored by Chanelle Lee's avatar Chanelle Lee
Browse files

Changed logging behaviour so we have cts record of agent beliefs

parent 8e60ae27
......@@ -22,18 +22,21 @@ def main(numSims=10):
time.sleep(5)
simNum = 0
paramNum = 0
for noise, distrust in ((0.18, 0.25), (0.35, 0.37), (0.53, 0.411),
(0.7, 0.43)):
paramNum += 1
params = {1: (0.18, 0.25), 2: (0.35, 0.37), 3: (0.53, 0.411),
4: (0.7, 0.43)}
for key, values in params.items():
paramNum = key
logger.info('Param num: {}'.format(paramNum))
for i in range(0, numSims):
simNum += 1
logger.info('Sim num: {}'.format(simNum))
sretCode = vrep.simxStartSimulation(clientID,
vrep.simx_opmode_oneshot)
if sretCode > 1:
logger.critical('Simulation not started! {}'.format(sretCode))
sys.exit('Could not start simulation {}'.format(sretCode))
time.sleep(5)
controllerJobs = start(paramNum, simNum, noise, distrust)
controllerJobs = start(paramNum, simNum, *values)
try:
while any([p.isAlive() for p in controllerJobs]):
time.sleep(1)
......
......@@ -56,7 +56,7 @@ class EPuckSim(object):
self._msgReceived = None
self.msgToSend = None
self._bThread = None
self._timestep = 0
self._iteration = 0
# State based attributes
self._researchState = 0
......@@ -139,13 +139,14 @@ class EPuckSim(object):
###############################################################################
# Logging Functions
###############################################################################
def logBelief(self, timestep, belief):
for j, b in enumerate(belief):
belief_logger.info('{0}, {1}, {2}, {3}, {4}, {5}'
def logBelief(self, timestep):
for j, b in enumerate(self._belief):
belief_logger.info('{0}, {1}, {2}, {3}, {4}, {5}, {6}'
''.format(self.paramNum,
self.simNum,
self.i,
timestep,
self.i,
self._iteration,
j,
b))
......@@ -508,7 +509,6 @@ class EPuckSim(object):
newBelief /= newBelief.sum()
self._belief = newBelief
self.logBelief(self._timestep, self._belief)
logger.debug('New belief is now {0}'.format(self._belief))
###############################################################################
......@@ -526,7 +526,7 @@ class EPuckSim(object):
if opinions:
self.aggregate(opinions)
self.finishAggregation()
self._timestep += 1
self._iteration += 1
self._state -= 1
logger.info('Exiting: Aggregation')
else:
......
......@@ -47,10 +47,14 @@ class ControllerThread(threading.Thread):
def run(self):
logger.debug('ControllerThread is starting.')
retFlag = False
timestep = 0
try:
while not self.stopped() and retFlag is False:
retFlag = self.ePuck.controller()
self.ePuck.move()
if timestep & 10 == 0:
self.ePuck.logBelief(timestep)
timestep += 1
time.sleep(5)
self.ePuck.cleanUp()
logger.debug('ControllerThread has stopped')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment