> java ProgramName inputFileName outputFileName [ID] 12345...
Transcript of > java ProgramName inputFileName outputFileName [ID] 12345...
1
Semester22018COMP3702/7702ARTIFICIALINTELLIGENCEASSIGNMENT2:GameChangingTechnologyNote:• Thisassignmentconsistsoftwoparts:Programmingandreport.• Youcandothisassignmentinagroupofatmost3students.Thismeansyoucanalsodotheassignmentindividually.
• Forthosewhochoosetoworkinagroup:o All students in the groupmust be enrolled in the same course code, i.e., allCOMP3702studentsorallCOMP7702students.
o Please register your group name before 5pm on Tuesday, 23 Oct’18 inhttp://robotics.itee.uq.edu.au/~ai/a2Group.html. If you have not registeredyour group by the said time, you will need to work on the assignmentindividually.
o Allgroupmembersareexpectedtoworkinbothprogrammingandreport.ThedemowillinvolveQ&Atoeachgroupmember,individually.
• SubmissionInstruction:o Yourprogramshouldcompilefromcommandpromptandgenerateanexecutablethatcanberunfromcommandpromptas:
> java ProgramName inputFileName outputFileName
o Youshouldsubmitonlythesourcecoderequiredtocompiletheprogram,i.e.,removeallobjectfilesandexecutablebeforesubmission.
o Thereportshouldbein.pdfformatandnameda2-[courseCode]-[ID].pdf.Ifyouworkindividually,IDisyourstudentnumber.Ifyouworkinagroup,IDisthestudentnumberofallgroupmembersseparatedbyadash.Forinstance,ifyouworkinagroupoftwo,andthestudentnumberis12345and45678,then
[ID]shouldbereplacedwith12345-45678o Thereportandallthesourcecodesnecessarytocompileyourprogramshouldbeplacedinsideafoldernameda2-[courseCode]-[ID].
o Thefoldershouldbezippedunderthesamename,i.e.,a2-[courseCode]-[ID].zip,andthezipfileshouldbesubmittedviaturnitinbefore5pmonTuesday,13Nov’18,withgraceperioduntil8am,Wednesday14Nov’18.
• DemoInstruction:o DemowillbeonWednesday,14Nov’18toFriday,16Nov’18.o Pleaseregisterforademoslotbefore5pmonTuesday,13Nov’18inhttp://robotics.itee.uq.edu.au/~ai/a2Demo.html
o Ifyouworkinagroup,allgroupmembersmustbepresentforthedemo.o YoumustusethelabPCforthedemo,andthereforeyoumustmakesurethatyourcodedoescompileandrunwellinthelabPC.
2
Inthisassignment,youwilldevelopanMDP agent to play a game, namedChanging Technology. In a nutshell,game Changing Technology is asuburban and off-road touring carracinggame,wheretheemphasizeisonthestrategythatateamshouldtake—that is, deciding which driver, carmodels,andcarcomponentsshouldbeused when and where—, so that theteamcanreachthegoalwithinagivennumberofsteps.In game Changing Technology, a caroperates in an environment withvarying terrain types. There are threevariables that influence terrain types: dirt/asphalt, straight/slalom, and hilly/flat.The environment map, including the terrain types, is known perfectly and isrepresentedas1-dimensionalgridcellofsizeN,wherecolumn-1isthestartingpointandcolumn-Nisthegoalregion.Ateachstep,theteammightbeabletodooneofthefollowing:A1. Continue moving. Depending on the terrain, driver, car models, and car
components,eachmovementmightmovethecarkcells,where𝑘 ∈ −4, 5 ∪𝑠𝑙𝑖𝑝, 𝑏𝑟𝑒𝑎𝑘𝑑𝑜𝑤𝑛 . The result of the exact movement is uncertain andrepresentedasaprobabilitydistribution.Thisdistributionisconditionedonthecomponentsdiscussedinaction#2—#6below.Tosimplifycomputationof transitionprobability, this gameassumes conditional independence oftheparametersbelow(i.e.,cartype,driver,andtiremodel,givenk)andpriordistributionsoftheparametersandofkisassumedtobeuniform.Ifthemovementcausesthecartohavenon-zeroprobabilitymassofbeingincellindex>N,thenallprobabilitymassforcellsbeyondNwillbeaddedtotheprobabilitymassofbeingatcell-N.Thesameisappliedtocell-1.Thecarmightalsoslip,whichwillincurasubstantialtimebeforeitcanstartmovingagain.Thecarmightalsobreakdown,whichwillincurarepairtime.
A2. Change the car type. Different type will have different speed in differentterrainsanddifferentfuelefficiency.Afterthechange,thecarfuelisatfulltank(50liters)andthepressureofallofitstiresareat100%capacity.
A3. Change the driver. Different drivers will have different speed in differentterrains.
A4. Changethetire(s)ofexistingcar.Theteamhasanoptiontochangeitsentiretireswithanothermodel.Theavailabletiretypesare:all-terrain,mud,low-profile,performance.Thedifferent typesof tiresand terrainswill influencehowfarthecarwillmoveinasinglestep.Afterthechange,thepressureofallitstiresisat100%capacity.
A5. Addfueltoexistingcar.Thecarfuellevelisaninteger,withrange0(emptytank)to50liters(fulltank).Thetimeittakestofillupthefuelbyxamountisceil(x/10)steps.Forexample:If8litersisadded,atthenextsteptheagentcan
Photo taken from http://4wdguys.com.au/opposite-lock-challenge-mudgee-2012/
3
dosomethingelse,butif19litersisadded,onlyatthenextnextstep,theagentcanchooseanotherdifferentaction.
A6. Changepressuretothetires.Theteamcanadd/reducethepressureto50%capacity, 75% capacity, or 100% capacity. The fuel consumptionwhen thepressure is at 75% capacity is double that of 100% capacity. The fuelconsumptionwhenpressureisat50%capacityistriplethatof100%capacity.However,thechancesofslipat75%capacityisdoublethatof50%capacity,andthechancesofslipat100%capacityistriplethatof50%capacity.
A7. CombinationofoptionsA2andA3.A8. CombinationofoptionsA4—A6.Thetimetodothechangefollowstheslowest
step(i.e.,iffuelisadded,thiswillbefueladdition).Thegamehas5levels,whichdifferinthepossibleterraintypesandavailableactions,asfollows:Level-1: Only two types of terrain (i.e., dirt and asphalt) withN≤ 10, and only
actions A1—A4 are possible, with two different car models and twodifferent drivers to choose from. Fuel and tire pressure are assumed toremainthesamethroughouttherace.
Level-2: Only four types of terrain (i.e., dirt-straight, dirt-slalom, asphalt-straight,
andasphalt-slalom)withN≤10,andonlyactionsA1—A6arepossible,withthreedifferentcarmodelsandtwodifferentdriverstochoosefrom.
Level-3: Alleightterraintypes(i.e.,dirt-straight-hilly,dirt-straight-flat,dirt-slalom-
hilly, dirt-slalom-flat, asphalt-straight-hilly, asphalt-straight-flat, asphalt-slalom-hilly,andasphalt-slalom-flat)withN≤30,andonlyactionsA1—A6are possible, with five different carmodels and five different drivers tochoosefrom.
Level-4: AlleightterraintypeswithN≤30,andactionsA1—A7arepossible,with
fivedifferentcarmodelsandfivedifferentdriverstochoosefrom.Level-5: All eight terrain types withN≤ 30, and all eight classes of actions are
possible,withfivedifferentcarmodelsandfivedifferentdriverstochoosefrom.
ProbabilityHint:
SupposeD,B,andCarerandomvariables.IfBandCareconditionallyindependentgivenD,thenwecancomputeP(D=d|B=b,C=c)asfollows:
𝑃 𝐷 = 𝑑 𝐵 = 𝑏, 𝐶 = 𝑐 =𝑃 𝐵 = 𝑏 𝐷 = 𝑑 𝑃 𝐶 = 𝑑 𝐷 = 𝑑 𝑃 𝐷 = 𝑑
𝑃 𝐵 = 𝑏 𝐷 = 𝑑 𝑃 𝐶 = 𝑐 𝐷 = 𝑑 𝑃 𝐷 = 𝑑<==>?@@AB=CD
Theaboveformulationcanbeexpandedtoanynumberofconditions.
4
WhatyouneedtodoYourtasksinthisassignmentcanbeclassifiedinto3parts: 1. Design thesolution.This taskcontains twomaincomponents, i.e., framing the
problemasanMDPproblemanddecidinghowtosolvetheproblem.Notethatyou should design the MDP components, i.e., what are the states, actions,transition, and reward functions,manually.However, the exact parameters ofyourMDPproblemwilldependonthegiveninputfile.
2. Implement your design. Your program is allowed a maximum of 2 minutescomputationpriortoeachsimulationrun.IfyouuseanonlinemethodforsolvingMDP, at each decision point step, your program is allowed amaximum of 15secondscomputationtime.YourprogramwillberunonaPCinthetutorialroom.Thetimerequirementisforaprogramthatrunsasasingle-threadedprocess.Ifyouusemulti-threading,thenwewilldividetheaforementionedtimelimitwiththenumberofthreadsyouuse.Note:Youarenotallowedtouseanylibraryforlinearalgebra,optimization,andMDPsolver.
3. Writeareport,whichanswersthequestionswepostfortheReportsection(seethelastpartofthisdocument).Notethattoanswerthequestionswell,youneedexperimentalresults.
InputandOutputformatInput format. Theinputisasingle.txtfile,containinginformationabouttheraceandhowtheterraintypesaffectperformanceofthecar,driver,andcarcomponents.Theformatisasfollows.1. Thefirstlineisthelevelofthegame,i.e.,1,2,3,4,or5.2. Thesecondlineconsistsofthreenumbersseparatedbyawhitespace.Thefirst
numberisthediscountfactor,thesecondnumberisthetimetorecoverfromaslip,thelastnumberisrepairtimetorecoverfromabreakdown.
3. Thethirdlineconsistsoftwonumbers.Thefirstnumberisthenumberofcellsinthemap, i.e.,N.Thesecondnumberisthemaximumnumberoftime-stepstheagentisallowedtotakeforreachingthegoalregion.Let’sdenotethisnumberasMaxT.
4. Eachlineinline4to(3+NT),whereNTisthenumberofterraintypes,hastwocomponentsseparatedbyacolon(‘:’).Totheleftofthecolonisthetypeofterrain,writtenasallsmalllettersasperdescriptioninp.2-3.Totherightofthecolonisthe index of the cells with such a terrain type, separated by a comma. Acontinuous sequence of cells with the same terrain type can be written asbeginningCellIdx—endCellIdx.Forexample:
dirt-straight-hilly:1-3,5,7 meanscellindex1,2,3,5,and7hasdirt-straight-hillyasitsterraintype.Note:Ifthere’snocellwithsuchterraintype,thentherightsideofthecolonisempty.Thecellindexstartsfrom1.
5. Line3+NT+1isthenumberofcartypes.Let’sdenotethisasCT.6. EachlineinthesubsequentCTlineshastwocomponentsseparatedbyacolon
(‘:’).Totheleftofthecolonisthecartype.Thetypeofthecarisalwaysasingleword.Totherightofthecolonis12numbersseparatedbyawhitespace.The
5
numbersrepresentconditionalprobabilitythattheresultsofmoving(i.e.,k)is-4,-3,-2,-1,0,1,2,3,4,5,slip,orbreakdown,giventheparticularcartypeisused.
7. Subsequentlineisthenumberofdrivers.Let’sdenotethisasDT.8. EachlineinthesubsequentDTlineshastwocomponentsseparatedbyacolon
(‘:’).Totheleftofthecolonisthedriver’sname.Thedriver’snameisalwaysasingleword.Totherightofthecolonis12numbersseparatedbyawhitespace.Thenumbersrepresentconditionalprobabilitythattheresultsofmoving(i.e.,k)is-4,-3,-2,-1,0,1,2,3,4,5,slip,orbreakdown,giventheparticulardriver.
9. Eachlineinthesubsequent4lineshastwocomponentsseparatedbyacolon(‘:’).Totheleftofthecolonisthetiresmodel,writtenasperwritteninA4.Totherightis12numbersseparatedbyawhitespace.Thenumbersrepresentconditionalprobabilitythattheresultsofmoving(i.e.,k)is-4,-3,-2,-1,0,1,2,3,4,5,slip,orbreakdown,giventheparticulartiresmodel.
10. The next line consists of NT*CT (NT: #types of terrain, CT: #types of car)numbers.Eachnumberrepresentstheamountof fuelusedbyasinglemovingaction(i.e.,A1)whenpressureofthetiresisat100%capacity.Thefirstnumberisthenumberforthecombinationbetweenthefirstterraintype(asperInput#4)andthefirstcartype(asperInput#6),thesecondisthenumberforthefirstterraintypeandthesecondcartype,etc..
11. The next line consists of NT*CT (NT: #types of terrain, CT: #types of car)numbers.Eachnumberrepresentstheslipprobabilityofasinglemovingaction(i.e.,A1)whenpressureofthetiresisat50%capacity.Thefirstnumberisthenumberforthecombinationbetweenfirstterraintype(asperInput#4)andthefirstcartype(asperInput#6),thesecondisthenumberforthefirstterraintypeandthesecondcartype,etc..Theprobabilityofallotherpossiblevalueofk isuniform.
Output format. The output is a single .txt file. The number of lines in the output file is at most the same as the lower among the number of steps to reach the goal +1 and MaxT+1 (maxT refers to #3 on Input format) lines. Each line-i consists of a number and 2 tuples separated by a semi-colon (‘;’). The number represents the current time-step. If the car receives a time “penalty” (i.e., due to slip/breakdown/adding fuel), then the time step will jump accordingly. For instance, if at step-5, the car goes into a slip state and the time to recover from slip is 2 steps, then the output file will have a line with time-step 5, no action performed, and subsequent line with time-step 7. The first tuple consists of 8 components separated by a comma. In sequential order, the components are: the cell index where the car is currently located, whether the car is in slip condition or not (1 slip, 0 not slip), whether the car is in breakdown condition or not (1 breaks down, 0 good condition), the current car type, the current driver’s name, the current tires type, the current fuel level, the current tire pressure. The second tuple consists of the index (e.g., A1) of the action(s) performed at time-i (in ascending order) followed by the value (if values are required). The action index and its value are separated by a colon (‘:’). If more than one actions are performed, the actions are separated by a comma. If there’s no action performed, the second tuple is written as ‘(n.a.)’.
6
GradingfortheProgrammingPart(totalpoints:60/100)Thedetailsofthegradingschemeisasfollows.Ifyoursituationsatisfiesmorethanonemarkingband,wewillusethehigherband.
COMP3702:• >=1&<10:Theprogramdoesnotcompilenorrun(staffdiscretion).• >=10&<20:Theprogramrunsbutfailstosolveanyquerywithinthegiventimelimit(staffdiscretion).
• 30:Theprogramsolvesaqueryinvolvingupto2level-1cases.• 40:Theprogramsolvesaqueryinvolvingupto2level-2cases.• 50:Theprogramsolvesaqueryinvolvingupto2level-3cases.• 60:Theprogramsolvesaqueryinvolvingupto2level-4cases.
COMP7702:• >=1&<5:Theprogramdoesnotcompilenorrun(staffdiscretion).• >=5&<10:Theprogramrunsbutfailstosolveanyquerywithinthegiventimelimit(staffdiscretion).
• 20:Theprogramsolvesaqueryinvolvingupto2level-1cases.• 30:Theprogramsolvesaqueryinvolvingupto2level-2cases.• 40:Theprogramsolvesaqueryinvolvingupto2level-3cases.• 50:Theprogramsolvesaqueryinvolvingupto2level-4cases.• 60:Theprogramsolvesaqueryinvolvingupto2level-5cases.
Report(totalpoints:40/100)Yourreportmustcontainanswerstothefollowingquestions:
1. [10points]PleasedefineyourMDPproblem.2. [10points] Please explain themethod youuse to solve the problemat the
conceptuallevel(i.e.,pseudocodeandwhatabstractdatastructureisusedforthecontainer).
3. [20points]Pleaseanalyseyouralgorithm’stimeandmemorycomplexity,viacomparisonstudy.Forthispurpose,attheveryleast,youneedtoanalysetheperformance as the size of the problem (i.e., size of state space and actionspace)increases.Pleasenotethatinthisquestion,youwillgethighermarkforstronger arguments. A strong argument should at least include a logicalexplanationofwhyandincludeexperimentalresultstobackyourexplanation.Also,pleasealsonotethatgoodexplanationisNOTequaltolongexplanation!!!
oOoThat’s All, FolksoOoJOnceyoudothisassignment,youcouldwriteinyourCVthat
youhavedevelopedgameCHANGINGTECHNOLOGY(usewithdiscretion)J