COMP9414语言编程 写作、Python编程 辅导

” COMP9414语言编程 写作、Python编程 辅导COMP9414: Artificial IntelligenceAssignment 1: Temporal PlannerDue Date: Week 6, Friday, July 9, 11:59 p.m.Value: 15%This assignment concerns developing optimal solutions to planning problems for complex tasksinspired by the scenario of building a house, which requires a range of basic tasks to be performed,sometimes in sequence, sometimes in parallel, but where there are constraints between the tasks.We can assume that any number of basic tasks can be scheduled at the same time, provided allthe constraints between all the tasks are satisfied. The objective is to develop a plan to finish eachof the basic tasks as early as possible.For simplicity, let us represent time as Days using integers starting at 0, i.e. days are numbered0, 1, 2, etc., up to 99. A temporal planning problem is specified as a series of basic tasks. Eachtask has a fixed duration in days. In addition, there can be constraints both on single tasks andbetween two tasks, for example, a task might have to start after day 20, or one task might haveto start after another task finishes (the complete list of possible constraints is given below). Asolution to a planning problem is an assignment of a start day to each of the tasks so that allthe constraints are satisfied. The objective of the planner is to develop a solution for any givenplanning problem where each task finishes soonest, i.e. the solution such that the sum of the enddays over all the tasks is the lowest amongst all the possible plans that satisfy the constraints.More technically, this assignment is an example of a constraint optimization problem, a problemthat has constraints like a standard Constraint Satisfaction Problem (CSP), but also a cost associatedwith each solution. For this assignment, you will implement a greedy algorithm to findoptimal solutions to temporal planning problems that are specified and read in from a file. However,unlike the greedy search algorithm described in the lectures on search, this greedy algorithmhas the property that it is guaranteed to find an optimal solution for any temporal planningproblem (if a solution exists).You must use the AIPython code for constraint satisfaction and search to develop a greedy searchmethod that uses costs to guide the search, as in heuristic search (heuristic search is the same asAsearch where the path costs are all zero). The search will use a priority queue ordered by thevalues of the heuristic function that gives a cost for each node in the search. The heuristic functionfor use in this assignment is defined below. The nodes in this search are CSPs, i.e. each state isa CSP with variables, domains and the same constraints (and a cost estimate). The transitionsin the state space implement domain Splitting subject to arc consistency (the AIPython codeimplements this). A goal state is an assignment of values to all variables that satisfies all theconstraints. The cost of a solution is the sum of the end days of the basic tasks in the plan.A CSP for this assignment is a set of variables representing tasks, binary constraints on pairs oftasks, and unary domain constraints on tasks. The domains for the start days of the tasks theintegers from 0 to 99, and a task duration is in days 0. The only possible values for the startand end days of a task are integers, however note that it is possible for a task to finish after day99. Each task name is a string (with no spaces).The possible input (tasks and constraints) are as follows:# tasks with name and durationtask hnamei hdurationi# binary constraintsconstraint ht1i before ht2i # t1 ends before t2 startsconstraint ht1i after ht2i # t1 starts after t2 endsconstraint ht1i starts ht2i # t1 and t2 start on the same dayconstraint ht1i ends ht2i # t1 and t2 end on the same dayconstraint ht1i meets ht2i # t2 starts the next day after t1 endsconstraint ht1i overlaps ht2i # t2 starts after t1 starts and ends after t1 endsconstraint ht1i during ht2i # t1 starts after t2 starts and ends before t2 endsconstraint ht1i equals ht2i # t1 and t2 must be over the same interval# domain constraintsdomain hti starts-before hdi # t starts on or before ddomain hti starts-after hdi # t starts on or after ddomain hti ends-before hdi # t ends on or before ddomain hti ends-after hdi # t ends on or after ddomain hti starts-in hd1i hd2i # t starts in the range [d1,d2]domain hti ends-in hd1i hd2i # t ends in the range [d1,d2]domain hti between hd1i hd2i # t starts and finishes in the range [d1,d2]To define the cost of a solution, simply sum over the end days of all the tasks in the plan. Theend day of a task is the Start day of the task assigned in the solution plus the given duration ofthe task, minus 1. More formally, let V be the set of variables (representing tasks) in the CSPand let sv be the start day of a task v, which has duration dv, in a solution S. Then:cost(S) = XvV(sv + dv 1)HeuristicIn this assignment, you will implement greedy search using a priority queue to order nodes basedon a heuristic function h. This function must take an arbitrary CSP and return an estimate of thedistance from any state S to a solution. So, in contrast to a solution, each variable v is associatedwith a set of possible values (the current domain), which here we take as the possible start daysof the task.The heuristic estimates the cost of the best possible solution reachable from a given state S byassuming each variable can be assigned a value that minimizes the end day of the task. Theheuristic function sums these minimal costs over the set of all variables, similar to calculating thecost of a solution cost(S). Let S be a CSP with variables V and let the domain of v, writtendom(v), be a set of start days for v. Then, where the sum is over all variables v V representinga task with duration dv as above:h(S) = XvVminsvdom(v)(sv + dv 1)ImplementationPut all your code in one Python file called temporalPlanner.py. You may (in one or twocases) copy code from AIPython to temporalPlanner.py and modify that code, but do notcopy large amounts of AIPython code to your file. Instead, in preference, write classes intemporalPlanner.py that extend the AIPython classes (classes in green in the appendix below).Use the Python code for generic search algorithms in searchGeneric.py. This code includes aclass Searcher with a method search() that implements depth-first search using a list (treatedas a stack) to solve any search problem (as defined in searchProblem.py). For this assignment,extend the AStarSearcher class that extends Searcher and makes use of a priority queue to storethe frontier of the search. Order the nodes in the priority queue based on the cost of the nodescalculated using the heuristic function, but making sure the path cost is always 0. Use this codeby passing the CSP problem created from the input into a searchProblem (sub)class to make asearch problem, then passing this search problem into a Searcher (sub)class that runs the searchwhen the search() method is called on this search problem.Use the Python code in cspProblem.py, which defines a CSP with variables, domains and constraints.Add costs to CSPs by extending this class to include a cost and a heuristic function h tocalculate the cost. Also use the code in cspConsistency.py. This code implements the transitionsin the state space Necessary to solve the CSP. The code includes a class Search with AC from CSPthat calls a method for domain splitting. Every time a CSP problem is split, the resulting CSPs aremade arc consistent (if possible). Rather than extending this class, you may prefer to write a newclass Search with AC from Cost CSP that has the same methods but works with over constraintoptimization problems. This involves just adding costs into the relevant methods, and modifyingthe constructor to calculate the cost by calculating h whenever a new CSP is created.You should submit your temporalPlanner.py and any other files from AIPython needed to runyour program (see below). The code in temporalPlanner.py will be run in the same directoryas the AIPython files that you submit. Your program should read input from a file passed asan argument (i.e. not hard-coded as input.txt) and print output to standard output (i.e. nothard-coded to a file called output.txt).Sample InputAll input will be a sequence of lines defining a number of tasks, binary constraints and domainconstraints, in that order. Comment lines (starting with a # character) may also appear in thefile, and your program should be able to process and discard such lines. All input files can beassumed to be of the correct format there is no need for any error checking of the input file.Below is an example of the input form and meaning. Note that you will have to submit at leastthree input test files with your assignment. These test files should include one or more commentsto specify what Scenario is being tested.# four unconstrained tasks that are all before a final tasktask wall1 10task wall2 15task wall3 12task wall4 10task roof 20# binary constraintsconstraint wall1 before roofconstraint wall2 before roofconstraint wall3 before roofconstraint wall4 before roof# domain constraintsdomain wall1 starts-after 5domain roof starts-after 10Sample OutputPrint the output to standard output as a series of lines, giving the start day for each task (in theorder the tasks were defined) and the cost of the optimal solution. If the problem has no solution,print No solution (with capital N). When there are multiple optimal solutions, your programshould produce one of them. Important: For auto-marking, make sure there are no extra spacesat the ends of lines, and no extra empty lines after the cost is printed (i.e. no additional newlinecharacters after the one on the last line of the solution showing the cost). This is the standardbehaviour of the Python print function. Set all display options in the AIPython code to 0.The output corresponding to the above input is as follows:wall1:5wall2:0wall3:0wall4:0roof:15cost:82Submission Submit all your files using the following command (this includes relevant AIPython code):give cs9414 ass1 temporalPlanner.py search*.py csp*.py display.py *.txt Your submission should include: Your .py source file(s) including any AIPython files needed to run your code A series of .txt files (at least three) that you have used as input files to test your system(each including comments to indicate the scenarios tested), and the corresponding .txtoutput files (call these input1.txt, output1.txt, input2.txt, output2.txt, etc.);submit only Valid input test files When your files are submitted, a test will be done to ensure that your Python files run onthe CSE machine (take note of any error messages printed out) Check that your submission has been received using the command:9414 classrun -check ass1AssessmentMarks for this assignment are allocated as follows: Correctness (auto-marked): 10 marks Programming style: 5 marksLate penalty: The maximum mark you can obtain is reduced by 3 marks per day orpart-day late for up to 3 calendar days after the due date. Any submission more than3 days late receives 0 marks.Assessment Criteria Correctness: Assessed on valid input tests as follows (where the input file can have anyname, not just input1.txt, so read the file name from sys.argv[1]):python3 temporalPlanner.py input1.txt output1.txt Programming style: Understandable class and variable names, easy to understand code,good reuse of AIPython code, adequate comments, suitable test filesPlagiarismRemember that ALL work submitted for this assignment must be your own work and no codesharing or copying is Allowed. You may use code from the Internet only with suitable attributionof the source in your program. Do not use public code repositories on sites such as github make sure your code repository, if you use one, is private. All submitted assignmentswill be run through plagiarism detection software to detect similarities to other submissions,including from past years. You Should carefully read the UNSW policy on academic integrityand plagiarism (linked from the course web page), noting, in particular, that collusion (workingtogether on an assignment, or sharing parts of assignment solutions) is a form of plagiarism.DO NOT USE ANY CODE FROM CONTRACT CHEATING ACADEMIES ORONLINE TUTORING SERVICES. THIS COUNTS AS SERIOUS MISCONDUCTWITH A HEAVY PENALTY UP TO AUTOMATIC FAILURE OF THE COURSEWITH 0 MARKS.请加QQ:99515681 或邮箱:99515681@qq.com WX:codehelp

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导