# Hdu5017模拟退火

=。= 之前做过有关果蝇算法的东西，然后发现这俩个其实就是一个东西。。。当时都没想啊，其实想到都不一定能撸对。

```#include <cstdio>
#include <cstring>
#include <algorithm>
#include <climits>
#include <string>
#include <iostream>
#include <map>
#include <cstdlib>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include<math.h>
using namespace std;
#define eps 1e-9
double a, b, c, d, e, f, z1, z2;
const int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
const int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int solvez(double x,double y)
{
double A = c ,
B = e * x + d * y,
C = a * x * x + b * y * y + f * x * y - 1;
double dlt = B * B - 4 * A * C;
if (dlt < 0) return 0;
z1 = (-B + sqrt(dlt)) / 2 / A,
z2 = (-B - sqrt(dlt)) / 2 / A;
if(z1 * z1 > z2 * z2) swap(z1, z2);
return 1;
}

double dist(double x, double y, double z)
{
return sqrt(x * x + y * y + z * z) ;
}
void gao(double x,double y)
{
double Rand = 1.0;
int flag = solvez(x , y);
double Min = z1;
while(Rand > eps) {
double x1 = x ; double y1 = y;
for(int i = 0; i < 8; i++) {
double xx = x1 + dx[i] * Rand; double yy = y1 + dy[i] * Rand;
if(!solvez(xx , yy)) continue;
double dis = dist(xx, yy, z1);
if(dis < Min) Min = dis, x = xx, y = yy;
}
Rand *= 0.99;
}
printf("%f\n",Min);
}

int main()
{
while(cin >> a >> b >> c >> d >> e >> f){
gao(0, 0);
}
return 0;
}```

## POJ 3087 Shuffle&#39;m Up(模拟退火）

Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C chips. Each stack may contain chips of several

## 两种改进的模拟退火算法求解大值域约束满足问题1.0

0引言 约束满足问题(Constraint Satisfaction Problem,CSP)是人工智能研究领域中一个非常重要的分支,现已成为理论计算机科学.数学和统计物理学等交叉学科研究中的热点问题.人工智能.计算机科学和自动控制等领域中的许多问题都可以归结为约束满足问题.同时,约束满足问题在实际问题如模式识别.决策支持.物流调度及资源分配等领域也有着非常广泛的应用. CSP由一个变量集合和一个约束集合组成.每个变量都有一个非空的可能值域,每个约束描述了一个变量子集与子集内各变量的相容赋值,所

## 模拟退火求解TSP问题&lt;2变换法产生路径&gt;

<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">模拟退火解TSP</span> <span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"></span&g