Ejemplo n.º 1
0
def is_an_agent_can_be_there_faster(agent,target):
	"""
		si un autre agent peut atteindre avant la cellule visée
	"""	
	pop = get_population(agent)
	agents = p.get_agents(pop)
	i=0
	already_found = False
	while i < len(agents) and not already_found:
		if agents[i] != agent and target in accecible_positions(agents[i]):
			already_found = (u.eucl_dist(get_pos(agents[i]),target) < u.eucl_dist(get_pos(agent),target)) 
		i+=1
	return already_found
Ejemplo n.º 2
0
def is_an_agent_can_be_there_faster(agent, target):
    """
		si un autre agent peut atteindre avant la cellule visée
	"""
    pop = get_population(agent)
    agents = p.get_agents(pop)
    i = 0
    already_found = False
    while i < len(agents) and not already_found:
        if agents[i] != agent and target in accecible_positions(agents[i]):
            already_found = (u.eucl_dist(get_pos(agents[i]), target) <
                             u.eucl_dist(get_pos(agent), target))
        i += 1
    return already_found
Ejemplo n.º 3
0
def add_capacity_gaussian(env, max_capacity_factor, center, disp):
    """
        Add capacity to a given set of cells of the environment.
        The distribution of capacity follows the shape of a multi-
        variate (bi-dimensional) normal probability distribution 
        function (gaussian PDF) with a given center and dispersion.
        The max_capacity_factor represents the maximum level of the
        added capacity (at the center of the distribution) and is 
        a multiplicative factor of the maximum capacity property of
        the environment.
    """
    # Set the max capacity to a given factor (e.g. "1.0" for 100%
    # of the maximum capacity defined for the environment)
    max_capacity = get_max_capacity(env) * max_capacity_factor
    (cx, cy) = center
    # Compute the minimum capacity to assign to a cell.
    min_capacity = max_capacity * 1e-3
    # Compute the cell distance from the center at which to add
    # capacity.
    max_dist = math.ceil(disp * math.sqrt(-2 * math.log(min_capacity)))
    for x in range(cx - max_dist, cx + max_dist):
        for y in range(cx - max_dist, cx + max_dist):
            capacity = max_capacity * math.exp(-0.5 * (u.eucl_dist((x, y), center) / disp) ** 2)
            cell = get_cell(env, (x, y))
            c.add_capacity(cell, capacity)
Ejemplo n.º 4
0
def add_capacity_gaussian(env, max_capacity_factor, center, disp):
    """
        Add capacity to a given set of cells of the environment.
        The distribution of capacity follows the shape of a multi-
        variate (bi-dimensional) normal probability distribution 
        function (gaussian PDF) with a given center and dispersion.
        The max_capacity_factor represents the maximum level of the
        added capacity (at the center of the distribution) and is 
        a multiplicative factor of the maximum capacity property of
        the environment.
    """
    # Set the max capacity to a given factor (e.g. "1.0" for 100%
    # of the maximum capacity defined for the environment)
    max_capacity = get_max_capacity(env) * max_capacity_factor
    (cx, cy) = center
    # Compute the minimum capacity to assign to a cell.
    min_capacity = max_capacity * 1E-3
    # Compute the cell distance from the center at which to add
    # capacity.
    max_dist = math.ceil(disp * math.sqrt(-2 * math.log(min_capacity)))
    for x in range(cx - max_dist, cx + max_dist):
        for y in range(cx - max_dist, cx + max_dist):
            capacity = max_capacity * math.exp(-0.5 * (u.eucl_dist(
                (x, y), center) / disp)**2)
            cell = get_cell(env, (x, y))
            c.add_capacity(cell, capacity)