A generic program for sequential decision processe

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

AGenericProgramforSequentialDecisionProcessesOegedeMoorProgrammingResearchGroup,OxfordUniversityComputingLaboratoryWolfsonBuilding,ParksRoad,OxfordOX13QD,UK1MotivationAgenericprogramforaclassofproblemsisaprogramwhichcanbeusedtosolveeachprobleminthatclassbysuitablyinstantiatingitsparameters.ThemostcelebratedexampleofagenericprogramisthealgorithmofAho,HopcroftandUllmanforthealgebraicpathproblem[1].Herewehaveasingleprogram,pa-rameterisedbyanumberofoperators,thatsolvesnumerousseeminglydisparateproblems.Furthermore,theapplicabilityofthegenericprogramiselegantlystatedastheconditionthattheparametersformaclosedsemi-ring.Examplesofsuchgenericalgorithmsareadmittedlyscarce,andonemightbeledtobelievethatthemajorityofprogramscannotbeexpressedinsuchagenericmanner.Ipersonallydonotsharethatview,forthefollowingtworeasons:Firstly,littleeorthasgoneintoattemptstoclassifyexistingalgorithms,reectingthefactthatthecomputingcommunityasawholeplacesmorevalueontheinventionofnewalgorithmsthanontheorganisationofexistingknowledge.Incertainspecialisedareaswhereorganisationaltoolsareindispensable(forexampleinthedesignofarchitecture-independentparallelalgorithms),numerousgenericalgorithmshavebeendiscovered,andformthecoreofthesubject[13].Secondly,toexpressgenericalgorithmsonerequiresahigher-ordernotationinwhichbothprogramsandtypescanbeparameterstootherprograms.Suchhigher-ordernotationsencouragetheprogrammertoexploitgenericitywherepossible,andindeedmanyfunctionalprogrammersnowdosoasamatterofcourse.Moretraditionalprogrammingnotationsdonotoersimilarsupportforwritinggenericprograms.Thispaperisanattempttopersuadeyouofmyviewpointbypresentinganovelgenericprogramforacertainclassofoptimisationproblems,namedsequen-tialdecisionprocesses.ThisclasswasoriginallyidentiedbyRichardBellmaninhispioneeringworkondynamicprogramming[4].Itisaperfectexampleofaclassofproblemswhichareverymuchalike,butwhichhasuntilnowescapedsolutionbyasingleprogram.ThosereaderswhohavefollowedsomeoftheworkthatRichardBirdandIhavebeendoingoverthelastveyears[6,7]willrecognisemanyindividualexamples:allofthesehavenowbeenunied.Thepointofthisobservationisthatevenwhenyouareonthelookoutforgenericprograms,itcantakearatherlongtimetodiscoverthem.Thepresentationbelowwillfollowthatearlierwork,byreferringtothecalculusofrelationsandtherelationaltheoryofdatatypes.Ishallhoweverattempttobelightontheformalism,asIdonotregarditasessentialtothemainthesisofthispaper.Undoubtedlythereareother(perhapsmoreconvenient)notationsinwhichthesameideascouldbedeveloped.ThispaperdoesassumesomedegreeoffamiliaritywithalazyfunctionalprogramminglanguagesuchasHaskell,Hope,Miranda1orGofer.Infact,theLaTEXleusedtoproducethispaperisitselfanexecutableGoferprogram.2SequentialDecisionProcessesManyoptimisationproblemscanbespeciedintheformspecrpgen=listminr.filterp.genHerethegeneratorgengeneratesalistofcandidatesolutions,filterpselectsthosesolutionswhicharefeasible(thosethatsatisfythepredicatep),andnallytheselectorlistminrpicksaminimumsolutionaccordingtotheorderrelationr.Sequentialdecisionprocessesaredistinguishedfromotheroptimisationprob-lemsinthewaythegeneratorisformulated.Thesequentialnatureofthegenera-toriscapturedbyexpressingitasaninstanceofthefunctionfold2.Informally,foldisdenedbytheequationfoldadde[a1,a2,...,an]=a1‘add‘(a2‘add‘...(an‘add‘e))Inwordsonemightsaythatfoldaddextraversesthelistxfromrighttoleft,startingwiththeseedvaluee,andsummingwiththeoperatoraddateachstep.Therecursivedenitionoffoldisfoldadde[]=efoldadde(a:x)=a‘add‘(foldaddex)Inasequentialdecisionprocess,wehavegen=foldfe1MirandaisatrademarkofResearchSoftwareLtd.2Thefunctionfoldisnormallycalledfoldr.BecauseIshalldeviatefromthecommondenitionoffoldr1,Ihavedecidedtousefoldandfold1toavoidconfusion.andateachstep,theoperatorfoersanondeterministicchoicebetweenanumberofalternatives.Itisthischoicethataccountsforthetermdecisionprocess.Thealternativesarepresentedasalistofoperators,andthespecicationofasequentialdecisionprocessthereforereadssdp_specrpfsc=listminr.filterp.fold(choicefs)[c]choicefsaxs=[fax|f-fs,x-xs]Thatis,ateachstepwehavethechoiceofapplyinganyoftheoperatorsfromfstoanyoftheresultssofarproducedinxs.Cognoscentiwillrecognisearelationalfoldhere[2].Theabovecanbevariedslightlyaccordingtothekindoflistsoneworkswith.Forinstance,fornon-emptyliststhecounterpartoffoldisfold1fg[a]=gafold1fg(a:x)=fa(fold1fgx)Thatis,thefunctiongisappliedtothelastelementofthelist,andthenwesumfromrighttoleftusingthefunctionf.Modifyingthenotionofsequentialdecisionprocessaccordingly,oneobtainssdp1_specrpfsl=listminr.filterp.fold1(choicefs)l’wherel’a=[la]Notethatthisdiersfromthedenitionofsdpspecinthebasecaseonly.Belowweshallalsohaveauseforlistswithatleasttwoelements.Againfoldcanbemodiedforthisparticulardatatype:fold2fg[a,b]=gabfold2fg(a:x)=fa(fold2fgx)Inwords,gisappliedtothelasttwoelementsofthelist,andthenwesum(asbefore)fromrighttoleft,usingthefunctionf.Thecorrespondingnotionofsequentialdecisionprocessisgivenbysdp2_specrpfsl=listminr.filterp.fold2(choicefs)l’wherel’ab=[lab]Th

1 / 23
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功