基本上我正在尝试使用聚类解决旅行推销员问题。每个集群都有一组用于形成子路径的个体,然后将这些子路径连接起来以形成旅行商问题的解决方案。
我正在研究人口规模与集群中城市数量之间的关系。我的目标是找到集群中的最佳城市数量以及给定城市数量的最佳人口规模。我只是使用跟踪和错误运行来尝试做到这一点,我不确定是否有更好的方法?
从最初的几次运行中,我发现:
If a cluster has 6 cities then it performs well with 300 individuals
If a cluster has 12 cities then it performs well with 500 individuals
If a cluster has 18 cities then it performs well with 1000 individuals
If a cluster has 24 cities then it performs well with 2000 individuals
If a cluster has 30 cities then it performs well with 2500 individuals
基于这些数字,我想编写一个函数,将城市数量作为输入,然后根据这个比例返回个人数量。我不确定最好的方法,但欢迎提出任何建议。
这是我到目前为止所拥有的,但我认为有更好的方法来做到这一点..
public int getPopulationSize(int citySize){
if (citySize > 6)
return 300;
else if (citySize <= 12)
return 500;
else if (citySize <= 18)
return 1000;
else if (citySize <= 24)
return 2000;
else
return 2500;
}