# AI代写 | COMP9414: Arti cial Intelligence Assignment 1: Temporal Planner

This assignment concerns developing optimal solutions to planning problems for complex tasks
inspired 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 all
the constraints between all the tasks are satis ed. The objective is to develop a plan to nish each
of the basic tasks as early as possible.

For simplicity, let us represent time as days using integers starting at 0, i.e. days are numbered
0, 1, 2, etc., up to 99. A temporal planning problem is speci ed as a series of basic tasks. Each
task has a xed duration in days. In addition, there can be constraints both on single tasks and
between two tasks, for example, a task might have to start after day 20, or one task might have
to start after another task nishes (the complete list of possible constraints is given below). A
solution to a planning problem is an assignment of a start day to each of the tasks so that all
the constraints are satis ed. The objective of the planner is to develop a solution for any given
planning problem where each task nishes soonest, i.e. the solution such that the sum of the end
days 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 problem
that has constraints like a standard Constraint Satisfaction Problem (CSP), but also a cost as-
sociated with each solution. For this assignment, you will implement a greedy algorithm to nd
optimal solutions to temporal planning problems that are speci ed and read in from a le. How-
ever, unlike the greedy search algorithm described in the lectures on search, this greedy algorithm
has the property that it is guaranteed to nd an optimal solution for any temporal planning
problem (if a solution exists).

You must use the AIPython code for constraint satisfaction and search to develop a greedy search
method that uses costs to guide the search, as in heuristic search (heuristic search is the same as
A search where the path costs are all zero). The search will use a priority queue ordered by the
values of the heuristic function that gives a cost for each node in the search. The heuristic function
for use in this assignment is de ned below.

The nodes in this search are CSPs, i.e. each state is
a CSP with variables, domains and the same constraints (and a cost estimate). The transitions
in the state space implement domain splitting subject to arc consistency (the AIPython code
implements this). A goal state is an assignment of values to all variables that satis es all the
constraints. 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 of
tasks, and unary domain constraints on tasks. The domains for the start days of the tasks the
integers from 0 to 99, and a task duration is in days > 0. The only possible values for the start
and end days of a task are integers, however note that it is possible for a task to nish after day
99. Each task name is a string (with no spaces).
The possible input (tasks and constraints) are as follows:
# tasks with name and duration

# binary constraints
constraint ht1i before ht2i # t1 ends before t2 starts
constraint ht1i after ht2i # t1 starts after t2 ends
constraint ht1i starts ht2i # t1 and t2 start on the same day
constraint ht1i ends ht2i # t1 and t2 end on the same day
constraint ht1i meets ht2i # t2 starts the next day after t1 ends
constraint ht1i overlaps ht2i # t2 starts after t1 starts and ends after t1 ends
constraint ht1i during ht2i # t1 starts after t2 starts and ends before t2 ends
constraint ht1i equals ht2i # t1 and t2 must be over the same interval
# domain constraints
domain hti starts-before hdi # t starts on or before d
domain hti starts-after hdi # t starts on or after d
domain hti ends-before hdi # t ends on or before d
domain hti ends-after hdi # t ends on or after d
domain 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]

E-mail: itcsdx@outlook.com  微信:itcsdx