Skip to content

Python üzerinde tavlama benzetimi tekniğinin incelenmesi

License

Notifications You must be signed in to change notification settings

fatiiates/simulated-annealing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Tavlama Benzetimi(Simulated Annealing, SA)

[EN]

What is the Simulated Annealing ?

  SA is the meta-heuristic method used to stochastically estimate the global optimum of a given function.

How SA Works ?

  Annealing comes from a technique in which the structure of metal is strengthened by heating the metal to a certain level and cooling it in a controlled, which is one of the frequently used processes in metallurgy. We can create the algorithm of the same technique, we can apply this algorithm to functions and obtain global minimum values of the functions.

  • Step 1: The initial solution and initial temperature are determined.
  • Step 2: New neighboring x, y values are generated randomly against existing x, y values.
  • Step 3: The current solution is compared with the new neighboring values and the calculated solution.
  • Step 4: If new solution > existing solution; The Boltzmann distribution is calculated.
    • Step 4.1: A random value is calculated and the values are updated if the calculated value is > Boltzmann distribution.
  • Step 5: If new solution <= existing solution; the values are updated
  • Step 6: Temperature is lowered depending on fraction value.
  • Step 7: If the iteration is to continue, continue from Step 2.
  • Step 8: If the iteration is completed, the values ​​are displayed and the program is terminated.

Results

  The SA algorithm has been tested on four different metaphor-based functions and the results are as follows. The following parameters are used for the 'simulatedAnnealing' function in all tests.

  • startedLocation=[0.5, -0.5]
  • numberOfIterations=[50, 500]
  • temperatureValues=700
  • fraction=.88
  • functionToOptimize=[RELATED_FUNCTION]
  • functionRange=[RELATED_FUNCTION_RANGE]

Ackley Function

  • Function: \Large x=f(x,%20y)={-20exp[-0.2\sqrt{0.5(x^2%20+%20y^2)}]-exp[0.5(cos2{\pi}x%20+%20cos2{\pi}y)]%20+%20e%20+%20{20}}
  • Global minimum: \Large x=f(0,%200)={0}
  • Search domain: \Large x=-5%20\leq%20x,y%20\leq%205

The obtained values

  • For the best solution, x and y: -0.0017175650567326506, -0.001767226084160134
  • The result for best x and y: 0.007132000788232062
  • Graphs obtained as a result of 50 iterations;

ackley

Beale Function

  • Function: \Large x=f(x,%20y)={(1.5%20-%20x%20+%20xy)^2%20+%20(2.25%20-%20x%20+%20xy^2)^2%20+%20(2.625%20-%20x%20+%20xy^3)^2}
  • Global minimum: \Large x=f(3,%200.5)={0}
  • Search domain: \Large x=-4.5%20\leq%20x,y%20\leq%204.5

The obtained values

  • For the best solution, x and y: 3.0756646925140005, 0.5286730640983099
  • The result for best x and y: 0.003704091519416439
  • Graphs obtained as a result of 50 iterations;

beale

Goldstein-Price Function

  • Function: \Large x=f(x,%20y)={[1%20+%20(x%20+%20y%20+%201)^2(19%20-%2014x%20+%203x^2%20-%2014y%20+%206xy%20+%203y^2)][30%20+%20(2x%20-%203y)^2(18%20-%2032x%20+%2012x^2%20+%2048y%20-%2036xy%20+%2027y^2)]}
  • Global minimum: \Large x=f(0,%20-1)={3}
  • Search domain: \Large x=-2%20\leq%20x,y%20\leq%202

The obtained values

  • For the best solution, x and y: -0.003973639126817308, -1.0052460061942456
  • The result for best x and y: 3.011428548092107
  • Graphs obtained as a result of 50 iterations;

gsp

Lévi Function

  • Function: \Large x=f(x,%20y)={sin^23{\pi}x%20+%20(x%20-%201)^2(1%20+%20sin^23{\pi}y)%20+%20(y%20-%201)^2(1%20+%20sin^22{\pi}y)}
  • Global minimum: \Large x=f(1,%201)={0}
  • Search domain: \Large x=-10%20\leq%20x,y%20\leq%2010

The obtained values

  • For the best solution, x and y: 0.9921885050472286, 1.0427844298879307
  • The result for best x and y: 0.007440404165127328
  • Graphs obtained as a result of 50 iterations;

levi

[TR]

Tavlama Benzetimi Nedir ?

  TB belirli bir fonksiyonun global optimum değerini stokastik olarak tahmin etmek için kullanılan meta-sezgisel yöntemdir.

Nasıl Çalışır ?

  Tavlama(Annealing), metalürjide sıkça kullanılan işlemlerden biri olan metali belirli bir seviyeye kadar ısıtıp kontrollü olarak soğutarak yapısının sağlamlaştırıldığı bir teknikten gelmektedir. Aynı tekniği algoritmaya döküp fonksiyonlara uygulayarak fonksiyonların global minimum değerlerini elde edebiliriz.

  • Adım 1: Başlangıç çözümü, başlangıç sıcaklığı, başlangıç çözümü belirlenir.
  • Adım 2: Mevcut x,y değerlerine karşın rassal olarak yeni komşu x,y değerleri üretilir.
  • Adım 3: Mevcut çözüm ile yeni komşu değerler ile hesaplanan çözüm karşılaştırılır.
  • Adım 4: Eğer yeni çözüm > mevcut çözüm ise; Boltzmann dağılımı hesaplanır.
    • Adım 4.1: Rastgele bir değer hesaplanır ve hesaplanan değer > Boltzmann dağılımı ise değerler güncellenir.
  • Adım 5: Eğer yeni çözüm <= mevcut çözüm ise değerler güncellenir.
  • Adım 6: Sıcaklık fraksiyona bağlı olarak düşürülür.
  • Adım 7: Eğer iterasyona devam edilecekse Adım 2'den devam edilir.
  • Adım 8: İterasyon sonlandıysa değerler ekrana verilir ve program sonlanır.

Sonuçlar

  TB algoritması metafor bazlı dört farklı fonksiyon üzerinde test edilmiş ve sonuçları aşağıdaki gibidir. Tüm testlerde 'simulatedAnnealing' fonksiyonu için aşağıdaki parametreler kullanılmıştır.

  • startedLocation=[0.5, -0.5],
  • numberOfIterations=[50, 500],
  • temperatureValues=700,
  • fraction=.88,
  • functionToOptimize=[İLGİLİ_FONKSİYON],
  • functionRange=[İLGİLİ_FONKSİYON_ARALIĞI]

Ackley Fonksiyonu

  • Fonksiyon: \Large x=f(x,%20y)={-20exp[-0.2\sqrt{0.5(x^2%20+%20y^2)}]-exp[0.5(cos2{\pi}x%20+%20cos2{\pi}y)]%20+%20e%20+%20{20}}
  • Global minimum: \Large x=f(0,%200)={0}
  • Değer aralığı: \Large x=-5%20\leq%20x,y%20\leq%205

Elde edilen değerler

  • En iyi çözüm için x ve y: -0.0017175650567326506, -0.001767226084160134
  • En iyi x ve y için sonuç: 0.007132000788232062
  • 50 iterasyon sonucunda elde edilen grafikler;

ackley

Beale Fonksiyonu

  • Fonksiyon: \Large x=f(x,%20y)={(1.5%20-%20x%20+%20xy)^2%20+%20(2.25%20-%20x%20+%20xy^2)^2%20+%20(2.625%20-%20x%20+%20xy^3)^2}
  • Global minimum: \Large x=f(3,%200.5)={0}
  • Değer aralığı: \Large x=-4.5%20\leq%20x,y%20\leq%204.5

Elde edilen değerler

  • En iyi çözüm için x ve y: 3.0756646925140005, 0.5286730640983099
  • En iyi x ve y için sonuç: 0.003704091519416439
  • 50 iterasyon sonucunda elde edilen grafikler;

beale

Goldstein-Price Fonksiyonu

  • Fonksiyon: \Large x=f(x,%20y)={[1%20+%20(x%20+%20y%20+%201)^2(19%20-%2014x%20+%203x^2%20-%2014y%20+%206xy%20+%203y^2)][30%20+%20(2x%20-%203y)^2(18%20-%2032x%20+%2012x^2%20+%2048y%20-%2036xy%20+%2027y^2)]}
  • Global minimum: \Large x=f(0,%20-1)={3}
  • Değer aralığı: \Large x=-2%20\leq%20x,y%20\leq%202

Elde edilen değerler

  • En iyi çözüm için x ve y: -0.003973639126817308, -1.0052460061942456
  • En iyi x ve y için sonuç: 3.011428548092107
  • 50 iterasyon sonucunda elde edilen grafikler;

gsp

Lévi Fonksiyonu

  • Fonksiyon: \Large x=f(x,%20y)={sin^23{\pi}x%20+%20(x%20-%201)^2(1%20+%20sin^23{\pi}y)%20+%20(y%20-%201)^2(1%20+%20sin^22{\pi}y)}
  • Global minimum: \Large x=f(1,%201)={0}
  • Değer aralığı: \Large x=-10%20\leq%20x,y%20\leq%2010

Elde edilen değerler

  • En iyi çözüm için x ve y: 0.9921885050472286, 1.0427844298879307
  • En iyi x ve y için sonuç: 0.007440404165127328
  • 50 iterasyon sonucunda elde edilen grafikler;

levi

About

Python üzerinde tavlama benzetimi tekniğinin incelenmesi

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages