




版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
昆明理工大學(xué)人工智能第二次實(shí)驗(yàn)報(bào)告昆明理工大學(xué)信息工程與自動(dòng)化學(xué)院學(xué)生實(shí)驗(yàn)報(bào)告2013—2014學(xué)年第1學(xué)期)課程名稱(chēng):人工智能開(kāi)課實(shí)驗(yàn)室:信自樓4452013年12月20日年級(jí)、專(zhuān)業(yè)、計(jì)科113學(xué)號(hào)201110405314姓名周?chē)?guó)映成績(jī)班教A.了解□B.基本了師該同學(xué)是否了解實(shí)驗(yàn)原理:解□C.不了解□評(píng)語(yǔ)該同學(xué)的實(shí)驗(yàn)?zāi)芰Γ篈.強(qiáng)□B.中等□C.差□該同學(xué)的實(shí)驗(yàn)是否達(dá)到要求:A.達(dá)到□B.基本達(dá)到□C.未達(dá)到□實(shí)驗(yàn)報(bào)告是否規(guī)范:A.規(guī)范□B.基本規(guī)范□C.不規(guī)范□實(shí)驗(yàn)過(guò)程是否詳細(xì)記錄:A.詳細(xì)□B.一般□C.沒(méi)有□教師簽名:年月日實(shí)驗(yàn)項(xiàng)目名稱(chēng)天氣決策樹(shù)指導(dǎo)教師劉英莉一、上機(jī)目的及內(nèi)容上機(jī)內(nèi)容用確定性推理算法求解教材65-66頁(yè)介紹的八數(shù)碼難題。-2-上機(jī)目的1)復(fù)習(xí)程序設(shè)計(jì)和數(shù)據(jù)結(jié)構(gòu)課程的相關(guān)知識(shí),實(shí)現(xiàn)課程間的平滑過(guò)渡;2)掌握并實(shí)現(xiàn)在小規(guī)模狀態(tài)空間中進(jìn)行圖搜索的方法;3)理解并掌握?qǐng)D搜索的技術(shù)要點(diǎn)。二、實(shí)驗(yàn)原理及基本技術(shù)路線(xiàn)圖(方框原理圖或程序流程圖)1)設(shè)計(jì)并實(shí)現(xiàn)程序,求解出正確的解答路徑;2)對(duì)所設(shè)計(jì)的算法采用大O符號(hào)進(jìn)行時(shí)間復(fù)雜性和空間復(fù)雜性分析;3)對(duì)一般圖搜索的技術(shù)要點(diǎn)和技術(shù)難點(diǎn)進(jìn)行評(píng)述性分析。三、所用儀器、材料(設(shè)備名稱(chēng)、型號(hào)、規(guī)格等或使用軟件)1臺(tái)PC及VISUALC++6.0 軟件四、實(shí)驗(yàn)方法、步驟(或:程序代碼或操作過(guò)程)建立工程后建立 5個(gè)sourceFiles文件分別為-3-AttributeValue.cpp#include"AttributeValue.h"#include"base.h"AttributeValue::AttributeValue(std::stringconst&instring)m_value(instring){}boolAttributeValue::GetType(){if(m_value=="P"){returntrue;}elseif(m_value=="N"){returnfalse;}else{-4-throwDataErrException();}}basefun.cpp#include<math.h>floatlog2(floatx){return1.0/log10(2)*log10(x);}floatcalEntropy(floatprob){floatsum=0;if(prob==0||prob==1){return0;}sum-=prob*log2(prob);sum-=(1-prob)*log2(1-prob);returnsum;-5-}DataPoint.cpp#include<iostream>#include"DataPoint.h"DataPoint::DataPoint(std::vector<AttributeValue>const&attributes,booltype)m_type(type){for(inti=0;i<attributes.size();++i){m_attributes.push_back(attributes[i]);}}voidDataPoint::display(){for(inti=0;i<m_attributes.size();++i){std::cout<<"\t"<<m_attributes[i].getValue();-6-}if(true==m_type){std::cout<<"\tP";}else{std::cout<<"\tN";}std::cout<<std::endl;}DataSet.cppmain.cpp#include<fstream>#include<iostream>#include<list>#include<sstream>#include<string>#include<vector>-7-#include"AttributeValue.h"#include"DataPoint.h"#include"DataSet.h"DataPointprocessLine(std::stringconst&sLine){std::istringstreamisLine(sLine,std::istringstream::in);std::vector<AttributeValue>attributes;TODO:needtohandlebeginningandendingemptyspaces.while(isLine.good()){std::stringrawfield;isLine>>rawfield;attributes.push_back(AttributeValue(rawfield));}-8-AttributeValuev=attributes.back();attributes.pop_back();booltype=v.GetType();returnDataPoint(attributes,type);}voidmain(){std::ifstreamifs("in.txt",std::ifstream::in);DataSetinitDataset;while(ifs.good()){TODO:needtohandleemptylines.std::stringsLine;std::getline(ifs,sLine);initDataset.addDataPoint(processLine(sLine));}std::list<DataSet>processQ;std::vector<DataSet>finishedDataSet;-9-processQ.push_back(initDataset);while(processQ.size()>0){std::vector<DataSet>splittedDataSets;DataSetdataset=processQ.front();dataset.splitDataSet(splittedDataSets);processQ.pop_front();for(inti=0;i<splittedDataSets.size();++i){floatprob=splittedDataSets[i].getPositiveProb();if(prob==0.0||prob==1.0){finishedDataSet.push_back(splittedDataSets[i]);}else{-10-processQ.push_back(splittedDataSets[i]);}}}std::cout<<"Thedicisiontreeis:"<<std::endl;for(inti=0;i<finishedDataSet.size();++i){finishedDataSet[i].display();}}建立4個(gè)HeaderFiles文件1.AttributeValue.h#ifndefATTRIBUTE_VALUE_H_#defineATTRIBUTE_VALUE_H_#include<string>classAttributeValue{public:AttributeValue(std::stringconst&instring);-11-boolGetType();std::stringconst&getValue()const{returnm_value;}private:std::stringm_value;};structAttributeValueCmp{booloperator()(AttributeValueconst&lhs,AttributeValueconst&rhs)const{returnlhs.getValue()<rhs.getValue();}};#endif2.base.hclassDataErrException:publicstd::exception{-12-};floatcalEntropy(floatprob);3.DatePoint.h#ifndefDATA_POINT_H_#defineDATA_POINT_H_#include<vector>#include"AttributeValue.h"classDataPoint{public:DataPoint(std::vector<AttributeValue>const&attributes,booltype);boolisPositive(){returnm_type;}intgetNAttributes(){-13-returnm_attributes.size();}AttributeValueconst&getAttribute(intindex){returnm_attributes[index];}voiddisplay();private:std::vector<AttributeValue>m_attributes;boolm_type;};#endifDateSet.h#include<map>#include<utility>#include"DataPoint.h"classSplitAttributeValue{-14-public:SplitAttributeValue(AttributeValuev,intid): m_v(v)m_attributeIndex(id){}intgetAttributeIndex(){returnm_attributeIndex;}voiddisplay();private:intm_attributeIndex;AttributeValuem_v;};classDataSet{public:voidaddDataPoint(DataPointconst&datapoint);floatgetPositiveProb();-15-voidsplitDataSet(std::vector<DataSet>&splittedSets);voiddisplay();private:std::vector<SplitAttributeValue>m_splitAttributes;std::vector<DataPoint>m_data;};五、實(shí)驗(yàn)過(guò)程原始記錄
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 企業(yè)內(nèi)部溝通協(xié)作平臺(tái)建設(shè)方案
- 江西省九江市都昌縣2024-2025學(xué)年八年級(jí)上學(xué)期期末生物試題(含答案)
- 北京延慶區(qū)2024-2025學(xué)年高二上學(xué)期期末生物學(xué)試題(含答案)
- 三農(nóng)用物資采購(gòu)管理作業(yè)指導(dǎo)書(shū)
- 從理論到實(shí)踐科學(xué)探究活動(dòng)課
- 青稞種植知識(shí)培訓(xùn)課件
- 電商直播平臺(tái)搭建與運(yùn)營(yíng)服務(wù)協(xié)議
- 數(shù)學(xué)王國(guó)里的智慧讀后感
- 電子支付平臺(tái)推廣專(zhuān)項(xiàng)資金協(xié)議
- 智能供應(yīng)鏈管理服務(wù)合同
- 高壓變頻器技術(shù)協(xié)議最終2.3日
- 《廣告攝影》課件第五講 食品廣告拍攝與后期制作
- 保潔整改方案計(jì)劃
- 碘-淀粉比色法測(cè)定淀粉酶課件
- 各元素特征X射線(xiàn)能量表
- 課堂觀察記錄與分析(高中數(shù)學(xué)-周渚華)
- 第九章單細(xì)胞蛋白質(zhì)飼料
- 安裝超載限制器方案
- 《石灰吟》教學(xué)設(shè)計(jì)(課堂實(shí)錄)
- 架子工實(shí)操比賽方案(共19頁(yè))
- 人教版七年級(jí)數(shù)學(xué)下冊(cè):7.1.2平面直角坐標(biāo)系ppt課件
評(píng)論
0/150
提交評(píng)論