def newPosition(self, whichVars=None):<EOL>
<EOL>globalBestPosition = None<EOL>if self._hsObj._speculativeParticles:<EOL><INDENT>genIdx = self.genIdx<EOL><DEDENT>else:<EOL><INDENT>genIdx = self.genIdx - <NUM_LIT:1><EOL><DEDENT>if genIdx >= <NUM_LIT:0>:<EOL><INDENT>(bestModelId, _) = self._resultsDB.bestModelIdAndErrScore(self.swarmId,<EOL>genIdx)<EOL>if bestModelId is not None:<EOL><INDENT>(particleState, _, _, _, _) = self._resultsDB.getParticleInfo(<EOL>bestModelId)<EOL>globalBestPosition = Particle.getPositionFromState(particleState)<EOL><DEDENT><DEDENT>for (varName, var) in self.permuteVars.iteritems():<EOL><INDENT>if whichVars is not None and varName not in whichVars:<EOL><INDENT>continue<EOL><DEDENT>if globalBestPosition is None:<EOL><INDENT>var.newPosition(None, self._rng)<EOL><DEDENT>else:<EOL><INDENT>var.newPosition(globalBestPosition[varName], self._rng)<EOL><DEDENT><DEDENT>position = self.getPosition()<EOL>if self.logger.getEffectiveLevel() <= logging.DEBUG:<EOL><INDENT>msg = StringIO.StringIO()<EOL>print >> msg, "<STR_LIT>" % (pprint.pformat(position,<EOL>indent=<NUM_LIT:4>))<EOL>print >> msg, "<STR_LIT>"<EOL>for (varName, var) in self.permuteVars.iteritems():<EOL><INDENT>print >> msg, "<STR_LIT>" % (varName, str(var))<EOL><DEDENT>self.logger.debug(msg.getvalue())<EOL>msg.close()<EOL><DEDENT>return position<EOL>
Choose a new position based on results obtained so far from all other
        particles.

        Parameters:
        --------------------------------------------------------------
        whichVars:       If not None, only move these variables
        retval:               new position