========================================================================
MICROSOFT FOUNDATION CLASS LIBRARY : AntClusting
========================================================================
3.5版把CalcuSimilar()函数,CalcuPickProb()函数,和CalcuDropProb()函数从CAnt类中移到
CAntClusteringAlogrithm类中,但还是将AntThreadProc函数做为全局函数,采用多线程来实现聚类
。
3.6版把CalcuSimilar()函数,CalcuPickProb()函数,和CalcuDropProb()函数从CAnt类中移到
CAntClusteringAlogrithm类中,而且将AntThreadProc函数也做为CAntClusteringAlgorithm中
一个成员函数,不采用多线程来实现聚类。不足之处是:只用了一个蚂蚁实现聚类,没有体现出
多个蚂蚁共用行为。对程序进行了进一步的改进,把similar变量从CAnt类中转到CAntClusteringAlogrithm类
中
4.0版继承自3.6版
与3.6版的主要改进在于,实现将任意数据文件读入数组中,并将数组的头指针传入蚂蚁聚类算法类中,可以进行聚类操作。
对各类内变量及成员函数进行了调整。
1 蚂蚁类
类中的成员包括:
数据对象的属性值数组头指针 float *m_pfAntPropArray、
蚂蚁坐标 float m_dAntX,m_dAntY;
蚂蚁是否有负载的标识 bool m_bIsLoad;
蚂蚁考察的数据对象在整个数据对象数据组中的序号 int m_nDataPosition;
数据对象的维度 int m_nAntPropNum;
除两个构造函数外,只有两成员函数:
蚂蚁移动函数,即赋给蚂蚁一对新的x、y坐标 void AntChangePosition(float newx,float newy);
设置蚂蚁函数,即把数据对象的属性赋给蚂蚁 void SetAnt(struct DataObject *data,int dataPosition);
取消了initant函数,将其改造成构造函数
2 蚂蚁聚类算法类
类中的成员包括:
double m_dAlpha; //相似度参数alpha
int m_nAntNumber; //蚂蚁数
double m_dPickK; //拾起概率
double m_dDropK; //放下概率
double m_dR; //蚂蚁考察半径
int m_nXSize; //二维平面x轴大小
int m_nYSize; //二维平面y轴大小
UINT m_nMaxCycNum; // 最大循环次数
int m_nACADataNum; //数据对象总数
int m_nACAPropNum; //数据对象维度
double m_dDist; //分类半径
double m_dSimilar; //相似度
私有成员函数包括:
double CalcuDropProb(double similar); //计算放下概率函数
double CalcuSimilar(CAnt * m_pAnt); //计算相似度函数
double CalcuPickProb(double similar); //计算拾起概率函数
共有成员函数包括:
UINT AntThreadProc(DataObject* _dataObj,double alpha,int antnum,double pickk,double dropk,
double r,UINT maxcycnum);
/////蚂蚁聚类算法实现函数
void InitDataObject(); //初始化数据对象
int ClassifyData(); //分类函数
将"计算放下概率函数"、"计算相似度函数"、"计算拾起概率函数"由CAnt类中移到聚类算法类CAntClusterAlogrithm中,将聚类计算放入一个类中实现。
3.视类CAntClustingView中主要在OnParameter()调用参数设置对话框,实现了参数传递。在OnDraw()中实现了聚类结果的可视化。
4.CArrayData为数据文件类,主要实现了将数据文件中的数据读入数组中的功能
其主要成员有:
float* m_pfData; //存储数据对象的数组指针
CString m_strPathName; //数据文件名
int m_nLine; //数据对象个数,一个占一行
int m_nRow; //数据对象属性数,一个占一列
int m_nTotal; //数据对象总数
CString m_strLastError;
其对外接口的成员函数主要有:
int GetPropNum(); //获取数据对象维数
int GetDataNum(void); //获取数据对象总数
float* GetData(); //获取存储数据对象的数组句柄
4.5继承自4.0版,对错误的分类算法进行了纠正,对最后显示分类效果的可视化OnDraw函数进行了改进,
使之能正常显示分类结果,实现了比较大的突破。
在分类算法中采用了"队列"和"链表"这两个新的数据结构
初始将所有元素放于链表中,从链表中取出头元素放入队列,并从表中删除该元素。
依次从队列中取出头元素,顺序计算该头元素与链表中剩余元素间的距离,若与链表
中某一元素间的距离小于指定的类间距,则将该元素从链表中取出放入队列,若遍历
完链表,则将队列头元素出列。重复该过程直至链表中无剩余元素。
新添加的类如下:
结合类:CLink //单个结点
链表类LList
template <class Elem> class LList {
private:
CLink<Elem>* head; // Pointer to list header
CLink<Elem>* tail; // Pointer to last Elem in list
CLink<Elem>* fence; // Last element on left side //链表内部指针,指向待考察元素的前一个元素
int leftcnt; // Size of left partition \\\链表内部指针fence左侧的元素个数
int rightcnt; // Size of right partition \\\链表内部指针fence右侧的元素个数
void init() ; //初始化
// Return link nodes to free store
void removeall() //删除链表
public:
void clear(); //清空链(删除链并新建一新链)
// Insert at front of right partition //当内部指针的右侧加入一新元素
bool insert(const Elem&) ;
// Append Elem to end of the list //链表尾部加入新元素
bool append(const Elem& item)
// Remove and return first Elem in right partition 移除fence指针指向元素的下一个元素
bool remove(Elem& it)
bool is_empty(); //判断链表是否为空
void setStart() //将链表内部指针置于链表头
void setEnd() //将链表内部指针置于链表尾
// Move fence one step left; no change if left is empty //将链表内部指针前移一位
void prev()
void next() //将链表内部指针后移一位
int leftLength() const { return leftcnt; } //链表内部指针左侧元素个数
int rightLength() const { return rightcnt; } //链表内部指针右侧元素个数
// Set the size of left partition to pos
bool setPos(int pos)
bool getValue(Elem& it) const //获取链表内部指针指向的下一个元素值
bool Locate(Elem& it) //将内部指针置于值为it的元素的前一个
};
队列类:
template <class Elem> class LQueue
{
public:
CLink<Elem>* front; // Pointer to front queue node //队列头
CLink<Elem>* rear; // Pointer to rear queue node //队列尾
int size; // Number of elements in queue //队列中元素个数
public:
void clear() // Clear queue //删除队列中元素
bool enqueue(const Elem& it) //把新元素it加入队列
bool dequeue(Elem& it) //队列头元素出列
bool frontValue(Elem& it) const //获取队列头元素值
int length() const //获取队列中元素个数
bool is_outqueue(Elem& it) //判别队列中是否有值为it的元素
若有则返回false。
};
5.0改进了读文件函数,使之能正确读地形数据文件。
AppWizard has created this AntClusting application for you. This application
not only demonstrates the basics of using the Microsoft Foundation classes
but is also a starting point for writing your application.
This file contains a summary of what you will find in each of the files that
make up your AntClusting application.
AntClusting.dsp
This file (the project file) contains information at the project level and
is used to build a single project or subproject. Other users can share the
project (.dsp) file, but they should export the makefiles locally.
AntClusting.h
This is the main header file for the application. It includes other
project specific headers (including Resource.h) and declares the
CAntClustingApp application class.
AntClusting.cpp
This is the main application source file that contains the application
class CAntClustingApp.
AntClusting.rc
This is a listing of all of the Microsoft Windows resources that the
program uses. It includes the icons, bitmaps, and cursors that are stored
in the RES subdirectory. This file can be directly edited in Microsoft
Visual C++.
AntClusting.clw
This file contains information used by ClassWizard to edit existing
classes or add new classes. ClassWizard also uses this file
没有合适的资源?快使用搜索试试~ 我知道了~
一个VC实现的蚂蚁聚类的程序
共56个文件
h:18个
cpp:15个
log:4个
3星 · 超过75%的资源 需积分: 3 20 下载量 11 浏览量
2008-09-22
14:05:20
上传
评论
收藏 790KB RAR 举报
温馨提示
一个蚂蚁聚类的程序 : AntClustering 用VC实现的
资源推荐
资源详情
资源评论
收起资源包目录
[VC]一个蚂蚁聚类的程序_AntClusting.rar (56个子文件)
ReadMe.txt 11KB
StdAfx.h 1KB
DataStrcut.h 2B
LQueue.cpp 2KB
AntClusterAlogrithm.h 2KB
res
Toolbar.bmp 1KB
AntClusting.rc2 403B
AntClusting.ico 1KB
AntClustingDoc.ico 1KB
ParaDlg.cpp 2KB
Ant.h 1KB
AntClusting.rc 16KB
AntClusting.opt 64KB
KmeansAlg.h 601B
MainFrm.cpp 2KB
gene-83.log 4KB
AntClustingView.cpp 15KB
MainFrm.h 2KB
RDDlg.cpp 4KB
KmeansAlg.cpp 4KB
Debug
AntClusting.exe 160KB
InputCu.cpp 2KB
DataStruct.h 569B
AntClustingDoc.h 2KB
Resource.h 2KB
RDDlg.h 1KB
DataStruct.cpp 2KB
topography.dat 24KB
AntClustingDoc.cpp 2KB
AntClusting.clw 5KB
ArrayData.cpp 5KB
AntClusting.dsp 6KB
JPZData.data 14KB
ParaDlg.h 2KB
AntClusting.h 2KB
iris.data 5KB
link.h 356B
AntClusterAlogrithm.cpp 13KB
LQueue.h 2KB
resource.hm 738B
InputCu.h 1KB
LogData
gene--topography.log 2.57MB
para.txt 73B
gene.log 5.72MB
gene-iris.log 2.49MB
AntClusting.aps 32KB
AntClusting.plg 2KB
StdAfx.cpp 213B
LLIST.H 3KB
Link.cpp 723B
AntClusting.dsw 545B
ArrayData.h 1KB
AntClusting.ncb 401KB
Ant.cpp 1KB
AntClustingView.h 2KB
AntClusting.cpp 6KB
共 56 条
- 1
资源评论
- sammiwyp2014-04-10程序经调试可以运行,但使用起来不是很方便
alphameng
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 农村信用社联合社计算机信息系统投产与变更管理办.docx
- 农村信用社联合社计算机信息系统数据管理办法.docx
- 利用SPSS作临床效度分析线上计算网站介绍-医学研究部统计谘.(医学PPT课件).ppt
- 利用Zabbix监控mysqldump定时备份数据库状态.docx
- 利用计算机解决问题的基本过程.doc
- 化工铁路通信工程总结.doc
- 北京大学网络教育软件工程作业.docx
- 医药公司(连锁店)计算机操作规程未新系统的自行按照旧制修改-新系统过制的编号加修模版.doc
- 医药公司(连锁店)计算机系统操作规程模版.doc
- 医药连锁门店计算机系统的操作和管理程序未新系统的自行按照旧制修改-新系统过制的编号加修模版.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功