Example #1
0
def iso_map_static(all_values):
    """
    all_values in list of list format [[VM1cpu,Vm1 mem, vm2cpu, vm2mem],[],..]
    """

    print len(all_values)
   # file =open("VM.classes", 'rb')
   # label = np.array(ast.literal_eval(file.readline()))

    X = numpy.array(all_values)
    print "Actual Values: ",X

    #For all the dimensions normalise the value range between 0 and 1
    #use ceiling function to remove small noise
    X = util.scale(X)

    for i in xrange(12,len(all_values)):

        print len(X[0])

        print X[:i]
        n_neighbors = 10
        #Y = manifold.Isomap(n_neighbors, 2, max_iter= 4000).fit_transform(X)
        Y = manifold.MDS().fit_transform(X[:i])

        #Y = manifold.LocallyLinearEmbedding().fit_transform(X)
        old_values = Y[:-1]
        new_value = Y[-1:]
        plot.animated_plot(old_values, new_value)
Example #2
0
def iso_map_dynamic(current_value_list, label, transition, closest_monitor_range, action_status):

    dynamic_all_values.append(current_value_list)

    write_as_template(dynamic_all_values, violation_position)

    if(len(dynamic_all_values) > 12):

        X = numpy.array(dynamic_all_values)
       # print "Actual Values: ",X

        #For all the dimensions normalise the value range between 0 and 1
        #use ceiling function to remove small noise
        X = util.scale(X)

        util.compute_utilization(util.scale_list(current_value_list))

        #n_neighbors = 10
        #Y = manifold.Isomap(n_neighbors, 2, max_iter= 4000).fit_transform(X)
        Y = manifold.MDS().fit_transform(X)

        #Y = manifold.LocallyLinearEmbedding().fit_transform(X)
        old_values = Y[:-1]
        new_value = Y[-1:]


        plot.animated_plot(old_values, new_value, violation_position, action_status)

    if closest_monitor_range:
        closest_range_position.append(len(dynamic_all_values) -1)

    # If transition, remove all the values until the closest_range_position
    # remove matching violation_position. It is important to do this before violation position is included inorder to feed in the updated (correct)
    # position of dynamic_values to violation_position.
    if transition:
       # print "!!!!!!!!!!Transition detected!!!!!!!!!! "
       # print "Closest Range positions (before): " ,closest_range_position
       # print "Violation positions (before) ", violation_position
       # print "Length All Values (before): ", len(dynamic_all_values)

        # reversed is important. Remove elements at the end first to avoid messing up index in subsequent deletions.
        if len(closest_range_position) >1:
            for position in reversed(xrange(closest_range_position[-2]+1, closest_range_position[-1])):
                print "Deleting element in position: ", position
                del dynamic_all_values[position]
                if position in violation_position:
                    violation_position.remove(position)

            #closest_Range_position[-1] does not anymore hold the right position. update the position by number of elements deleted.
            closest_range_position[-1] = closest_range_position[-1] - abs(closest_range_position[-2]+1 - closest_range_position[-1])

       # print "Length All Values (after): ", len(dynamic_all_values)
       # print "Violation positions (after) ", violation_position
       # print "Closest Range positions (after): " ,closest_range_position

    # Append the position of the violation only after plotting
    # inorder to plot the current value as current point instead of a violation
    if label:
        violation_position.append(len(dynamic_all_values)-1)