Heuristic Optimization Practical Work: Simulated Annealing Department of Architecture and Technology Universidad Politécnica de Madrid Athens 2005 Simulated Annealing Based on liquids freeze Local Search problems Propensity to deliver solutions which are only local optima Solutions depend on the initial solution Reduce the chance of getting stuck in a local optimum by allowing moves to inferior solutions Simulated Annealing If a move from one solution xbest to another neighbouring but inferior solution xnow results in a change in value f 0 , the move to xnow is still accepted if e f T R T (temperature) – control parameter R [0,1] – uniform random number Simulated Annealing Simulated Annealing current = problem.initialSate for t=1 to T = schedule(t) if T=0 then return xbest xnow = a random neighbour ofxbest f f ( xnext ) f ( xnow) if f 0 then xbest xnow f T else xbest xnow with probability e Cooling Schedule Practical Work 3 2 f ( x ) x 60 x 900 x 100 Maximize x coded as a 5-bit binary integer in [0,31] maximum (01010) f=4100 Practical Work Initial temperature Final temperature Number of iterations Cooling schedule IMPORTANT: Fitness function Practical Work (II) Map Coloring Assign color to each country Minimun number of used colors No country may touch another country of the same color Practical Work (II) Suggestions The Four Color Theorem Transform to Graphs Matrix representation PARAGUAY BOLIVIA CHILE URUGUAY ARGENTINA Practical Work (II) adyacentes[0][0]=0 adyacentes[0][1]=0 adyacentes[0][2]=1 adyacentes[0][3]=1 adyacentes[0][4]=0 adyacentes[0][5]=0 adyacentes[0][6]=1 adyacentes[0][7]=0 adyacentes[0][8]=0 adyacentes[0][9]=1 adyacentes[0][10]=0 adyacentes[0][11]=1 adyacentes[0][12]=0 adyacentes[0][13]=1 adyacentes[0][14]=0 adyacentes[0][15]=0 adyacentes[0][16]=0 adyacentes[1][0]=0 … color[0]=… color[1]=… color[2]=… color[3]=… color[4]=… color[5]=… color[6]=… color[7]=… color[8]=… color[9]=… color[10]=… color[11]=… color[12]=… color[13]=… color[14]=… color[15]=… color[16]=… Practical Work (II) adyacentes[id_1][id_2] = 1 si son adyacentes, 0 eoc. Color[id_1]=color [1:4] Fitness: for (i=0;i<NPAISES;i++) for (j=i+1;j<NPAISES;j++) if (adyacentes[i][j] && color[i]==color[j]) Fitness ++;
© Copyright 2026 Paperzz