乐趣区

关于算法:COMP9414-Intelligence那点事儿

COMP9414: Articial Intelligence
Assignment 1: Temporal Planner
Due Date: Week 6, Friday, July 9, 11:59 p.m.
Value: 15%
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 satised. 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 specied 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 satised. 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 specied 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 dened 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 satises 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

  1. Each task name is a string (with no spaces).
    The possible input (tasks and constraints) are as follows:
    as a stack) to solve any search problem (as dened in searchProblem.py). For this assignment,
    extend the AStarSearcher class that extends Searcher and makes use of a priority queue to store
    the frontier of the search. Order the nodes in the priority queue based on the cost of the nodes
    calculated using the heuristic function, but making sure the path cost is always 0. Use this code
    by passing the CSP problem created from the input into a searchProblem (sub)class to make a
    search problem, then passing this search problem into a Searcher (sub)class that runs the search
    when the search() method is called on this search problem.
    Use the Python code in cspProblem.py, which denes a CSP with variables, domains and con-
    straints. Add costs to CSPs by extending this class to include a cost and a heuristic function h to
    calculate the cost. Also use the code in cspConsistency.py. This code implements the transitions
    in the state space necessary to solve the CSP. The code includes a class Search with AC from CSP
    that calls a method for domain splitting. Every time a CSP problem is split, the resulting CSPs are
    made arc consistent (if possible). Rather than extending this class, you may prefer to write a new
    class Search with AC from Cost CSP that has the same methods but works with over constraint
    optimization problems. This involves just adding costs into the relevant methods, and modifying
    the constructor to calculate the cost by calculating h whenever a new CSP is created.
    You should submit your temporalPlanner.py and any other les from AIPython needed to run
    your program (see below). The code in temporalPlanner.py will be run in the same directory
    as the AIPython les that you submit. Your program should read input from a le passed as
    an argument (i.e. not hard-coded as input.txt) and print output to standard output (i.e. not
    hard-coded to a le called output.txt).
    Sample Input
    All input will be a sequence of lines dening a number of tasks, binary constraints and domain
    constraints, in that order. Comment lines (starting with a `#’ character) may also appear in the
    le, and your program should be able to process and discard such lines. All input les can be
    assumed to be of the correct format {there is no need for any error checking of the input le.
    Below is an example of the input form and meaning. Note that you will have to submit at least
    three input test les with your assignment. These test les should include one or more comments
    to specify what scenario is being tested.

    four unconstrained tasks that are all before a final task

    task wall1 10
    task wall2 15
    task wall3 12
    task wall4 10
    task roof 20

    binary constraints

    constraint wall1 before roof
    constraint wall2 before roof
    constraint wall3 before roof
    constraint wall4 before roof

    domain constraints

    domain wall1 starts-after 5
    domain roof starts-after 10
    Sample Output
    Print the output to standard output as a series of lines, giving the start day for each task (in the
    order the tasks were dened) and the cost of the optimal solution. If the problem has no solution

WX:codehelp

退出移动版