Exemplo n.º 1
0
    def startAt(self,r):
        """
        Define the initial position of the agent and wipe its memory.

        Parameters:
        ----------
        position : list, the initial solution to start at
        """
        self.r = r
        self.car = carObjective.normCarVector_to_car(r)
        self.memory = [Solution(r=self.r,score=self.f(),agent_class=type(self))]
Exemplo n.º 2
0
    def moveTo(self,r):
        """
        Change the agent's current solution to r and update it's score.

        Also add the new solution to the agent's memory and increment the
        agent's move countself.

        Parameters:
        ----------
        r : list, shape = [nDims]
            the new solution to move to
        """

        self.r = r
        self.car = carObjective.normCarVector_to_car(r)
        self.score = self.f()
        self.memory.append(Solution(self.r,self.score,type(self)))
        self.nmoves += 1
Exemplo n.º 3
0
 def constrain(self,r,p):
     self.car = carObjective.normCarVector_to_car(r)
     carConstrained = carObjective.constrain(self.car)
     rConstrained = carObjective.normalizedCarVector(carConstrained)
     return rConstrained #[-1 for i in range(len(x))]
Exemplo n.º 4
0
 def fr(self,new_r):
     newCar = carObjective.normCarVector_to_car(new_r)
     return carObjective.objective(newCar)
Exemplo n.º 5
0
 def f(self): #evaluate objective function for this agent's current solution
     self.car = carObjective.normCarVector_to_car(self.r)
     return carObjective.objective(self.car)
Exemplo n.º 6
0
 def fr(self,new_r):
     newCar = carObjective.normCarVector_to_car(new_r)
     return carObjective.objective(newCar,weights=self.obj_weights)