Esempio n. 1
0
from numpy import PINF
from math import fabs
from scipy.stats import uniform
from spatiotemporal.temporal_events.trapezium import RelationFormulaTrapezium

__author__ = 'keyvan'

epsilon = 0.0000001
binary_steps = 20

formula = RelationFormulaTrapezium()


def find_dist_on_right(dist_left, dist_right_start_point, same_value):
    dist_left_start_point, dist_left_length = dist_left.args
    return uniform(dist_right_start_point, (dist_left_start_point + dist_left_length
                                            - dist_right_start_point) ** 2 / same_value ** 2 / dist_left_length)


def find_dist_on_right_both(dist_left_1, dist_left_2, same_1, same_2):
    interval = [dist_left_1.args[0], dist_left_1.args[0] + dist_left_1.args[1]]
    alternative_interval = interval
    delta = PINF
    previous_delta = PINF
    for k in xrange(binary_steps):
        dist_right_start_point = (interval[0] + interval[1]) / 2.0
        dist_right = find_dist_on_right(dist_left_1, dist_right_start_point, same_1)
        same_heuristic = formula.compare(dist_left_2, dist_right)[1]
        delta = same_heuristic - same_2
        if fabs(delta) < epsilon:
            return dist_right, delta
Esempio n. 2
0
from math import fabs
from scipy.stats import uniform
from spatiotemporal.temporal_events import RelationFormulaGeometricMean
from spatiotemporal.temporal_events.trapezium import RelationFormulaTrapezium

__author__ = 'keyvan'

b_beg = uniform(10, 3)
b_end = uniform(1001, 3)
c_actual = uniform(11, 991)

f = RelationFormulaTrapezium()
same_beg = f.compare(b_beg, c_actual)[1]
same_end = f.compare(b_end, c_actual)[1]

interval = [10, 13.0]
x = []

for i in xrange(40):
    c_start_point = (interval[0] + interval[1]) / 2
    length = ((13.0 - c_start_point) / same_beg)**2 / 3.0
    c_heuristic = uniform(c_start_point, length)
    same_heuristic = f.compare(b_end, c_heuristic)[1]
    same_heuristic_beg = f.compare(b_beg, c_heuristic)[1]
    delta = same_end - same_heuristic
    x.append(delta)
    if fabs(delta) < 0.000000001:
        print same_beg
        print same_heuristic_beg
        print same_end
        print same_heuristic
Esempio n. 3
0
from numpy import PINF
from math import fabs
from scipy.stats import uniform
from spatiotemporal.temporal_events.trapezium import RelationFormulaTrapezium

__author__ = 'keyvan'

epsilon = 0.0000001
binary_steps = 20

formula = RelationFormulaTrapezium()


def find_dist_on_right(dist_left, dist_right_start_point, same_value):
    dist_left_start_point, dist_left_length = dist_left.args
    return uniform(
        dist_right_start_point,
        (dist_left_start_point + dist_left_length - dist_right_start_point)**2
        / same_value**2 / dist_left_length)


def find_dist_on_right_both(dist_left_1, dist_left_2, same_1, same_2):
    interval = [dist_left_1.args[0], dist_left_1.args[0] + dist_left_1.args[1]]
    alternative_interval = interval
    delta = PINF
    previous_delta = PINF
    for k in xrange(binary_steps):
        dist_right_start_point = (interval[0] + interval[1]) / 2.0
        dist_right = find_dist_on_right(dist_left_1, dist_right_start_point,
                                        same_1)
        same_heuristic = formula.compare(dist_left_2, dist_right)[1]