Last active
November 5, 2018 16:57
-
-
Save nvinayvarma189/8c0194090e39724aa5ede22181f98cdb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simulated Annealing for Clustering Problems | |
import math | |
import random | |
num_objects = 10 # numbers of objects to be clustered | |
num_cost_increases = 100 | |
avg_cost_increase = 200 | |
acc_ratio = 0.75 # acceptance ratio should e between 0 and 1 | |
prob_e = 0.00000000001 # probability factor | |
beta = 0.125 | |
max_iter = 4 * num_objects # maximum number of iterations | |
num_temp = 200 | |
k = 6 # number of labels | |
# SA accepts cost increse beta * avg_cost_increase at the probability of prob_e | |
initial_temperature = avg_cost_increase / math.log( num_cost_increases / ((num_cost_increases * acc_ratio) - (1-acc_ratio) * (max_iter - num_cost_increases))) | |
final_temperature = -beta * avg_cost_increase / math.log(prob_e) | |
alpha = math.pow(final_temperature / initial_temperature , 1 / num_temp) # decay rate for temperature | |
initial_state = {1:'A', 2: 'B', 3:'A', 4:'B', 5:'C', 6:'B', 7:'A', 8:'None', 9:'None', 10:'None' } | |
unused_labels = ['D', 'E', 'F'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment