University of Calgary
Rob Kremer
Q&A Group Assignment 2

CPSC 433: Artifical Intelligence
Winter 2013
Department of Computer Science
Computer
Science


Q&A

1. Regarding asserting predicates, is it allowable to assert predicates that we are not explicitly given yet but are implied by the predicate? For example if we assert a_in_project(p, prj), and we do not have that person or project yet, can we also assert a_person(p) and a_project(prj), or do we have to wait for those asserts to come in from the file later? If we have to wait, and those other asserts are not in the file, would that then count as the problem being incomplete and unsolvable, as we are asserting facts about entities that do not exist?

I believe this issue is clear from the assignment description (in the part about inferences with the ":-"'s in it).  Addressing your example, lines 9 and 10 of the inferences table [person(x) :- project(x,y) & project(x) :- project(y,x)] indicate that you MUST assert person(p) and project(prj) if they are not already asserted.

2. Do we have to account for a single person to be a member of multiple groups/projects?

Let's say no. If group(Mike,x) and later group(Mike,y) occurs, then take the later.

3. From what you said in class today it sounded like you are going to be using the supplied Test.java file to test our solution. Does this mean that we need to adhere to the requirements of Test.java for our IO demo next week as well, or are we able to create our own main class to make things a little simpler?

You can do what you want with your main(), but it must run with the following command line, as specified in the assignment spec:

java -classpath myprog.jar cpsc433.SisyphusI filename maxtime

You can ignore the maxtime parameter for this assignment, however.

That is, your program MUST have a main in class "SisyphusI" in package "cpsc433", and that main() must interpret a first parameter as an input file (and dump it's output to "<filename>.out").

4. We believe we have found an error in your sample input file. It appears that group(Werner, YQT) should actually be in-group(Werner, YQT). Same problem with project. We have discussed this with Andrew and he agrees with us that there is either a problem with the input file or a problem in your SisyphusPredicates class.

I looked at this, and there are places between the spec and the code where "in-group" and "in-project" are used and "group" and "project" are used.  I think the easiest way to resolve this is that we will take the two-parameter versions of "group" and "project" to be synonyms for "in-group" and "in-project". respectively.

I have updated the SisyphusPredicates.java file and the web doc to require both versions.

I know the predicates "group" and "project" are overloaded: each has a one-parameter, and two-parameter version.  The predicate reader has no problem distinguishing these though.

5. Some things are not well defined such as:
    a) how many roles can a person have?
not limited.  normally just one, but you can't count on that.  Being a manager and a researcher is not inconsistent.
    b) how many projects can a person be in? (Same for groups)
not limited.  But to simplify a bit, lets say just one.  I'll keep to that in the data.
    c) how many group heads can a group have? (same for a project)
not limited. Normally, a very low number, like 0 or 1, possibly 2.
    d) does a group have to have a head? (same for a project)
not necessarily -- ie: there might not currently be one, or that person isn't part of the room assignment.

6. If a predicate (eg: group(x, y)) is called with the same first parameter but different second parameters what happens?
    eg: if the following is in the input file:
        group(Adam, ASDF)
        group(Adam, fdsa)
    Which group is Adam in?  Is he in both, or just one?
    eg2:
        small-room(ABC)
        large-room(ABC)
    what size is room ABC?

Let's take the last update to be the correct one.  ie: in eg1, group(Adam, fdsa) overrides; in eg2, large-room(ABC) overrides.

7. Can a group and a person have the same name?

Yes, but I will try to avoid such name classes.

8. Are project and large-project the same or different? If they are different why is there no heads-large-project predicate?

You will note in the Sisyphus rules refer to projects and large projects, so they are different, but only in there are some rules that only apply to large project, but a large project is always a project.  Therefore, you can take "large" to be an attribute of a project.  Constraints 8 and 12 apply to large and "regular" projects, and constraints 9 and 10 only apply to large projects.

9. Will the PredicateReader ever call the "e_*" functions in SisyphusPredicates?  Will the "e_*" functions every be called?

You predicate reader is designed to be used from the command line.  You should use it as debugging tool.  I believe if you run the main() in Test.java with no parameters, you will get a command prompt.  You can use it as an interactive debugging tool.  Eg:

 1. Synopsis: Sisyphus <search-prg> [<env-file> [<maxTimeInMilliseconds:default=30000>]]
 2.
 3. Sisyphus I: query using predicates, assert using "!" prefixing predicates;
 4.  !exit() to quit; !help() for help.
 5.
 6. > person(Joe)
 7.  --> false
 8. > !person(Joe)
 9.
10. > person(Joe)
11. --> true

line 6 I interactively typed a query (the "e_" function) and the system responded false (Joe is not a person).  On line 8 I asserted that Joe is a person (and "a_" function), specified with the exclamation point.  On line 10, I repeated the first query, and the system now responds true (Joe is a person).

10. The code provided is unable to properly parse the sample input file.  It appears group(x,y) should be in_group(x,y)

Yes, I noticed that problem.  Lets solve it by making in_group and group (both with 2 parameters) synonyms.  I will update the source code and doc to reflect that.

11. If a soft constraint is violated (eg: people dont like to share rooms) is the soft constraint considered violated for each person or for each pair of people? 
    Eg: if Adam and Jon are in the same room.  Does this equate to -4 or -8 (-4 per person)?

Probably won't effect the outcome much, however, here goes:
constraint 2: I count from the perspective of the head only, but -2 for each member not close to the head.
constraint 7,8: same as 2.
constraint 11: counted for from the perspective of the smoker only (really, sound be the other way around, but it doesn't actually matter).
constraint 12: counted from both person's perspective (counted twice).
constraint 13: counted twice.
constraint 14: counted twice.
constraint 15: counted twice.
constraint 16: counted twice.

12. When given an input file how do we determine if we need to try to find a solution or just evaluate the goodness of the input?

For the current assignment, you only need to re-output the input the you received, but not necessarily in the same order or format.  Eg:
for input of one line "project(Joe, "Java++")", I would expect the following output:
  person(Joe)
  project("Java++")
  project(Joe,"Java++")
(but not necessarily in that exact order, although I'd normally expect both of the first 2 to come before the third).  No assign-to(Person, Room) predicates are required in the output unless they were in the input.
Bonus marks for calculating the goodness function and putting it in the output as a comment. (delineate comments with "//").

13. How will the demo be done?

a. I will give you a memory stick and you will copy your jar file onto it in the directory on the memory stick "G<groupNumber>".
b. > cd <root directory on the memory stick">
c. > java -jar TestIO.jar G<groupNumber>/<yourFile>.jar G<groupNumber>/test.txt

This will display your output file and a list of test predicates searched for in your file along with any failures. An example fallows.  This is the output from my program (not yours) -- but your program's output file (ending in ".out") is displayed by my program between the "****OUTPUT FILE *****" and "***************" lines:

**************** OUTPUT FILE *********************
// --theEnvironment : Environment-----------------------------
// PEOPLE
person(Monika)
secretary(Monika)
group(Monika, YQT)
works-with(Monika, {Thomas, Ulrike})
person(Thomas)
researcher(Thomas)
group(Thomas, YQT)
heads-group(Thomas, YQT)
project(Thomas, EULISP)
person(Ulrike)
secretary(Ulrike)
group(Ulrike, YQT)
works-with(Ulrike, {Monika, Thomas})
// ROOMS
room(C5119)
large-room(C5119)
close(C5119, {C5120})
room(C5120)
large-room(C5120)
close(C5120, {C5119})
// GROUPS
group(YQT)
// PROJECTS
project(EULISP)
// --END theEnvironment : Environment-------------------------
**************************************************
reading file G0/test.txt...
... read 25 lines from file G0/test.txt
person(Monika)
secretary(Monika)
group(Monika,YQT)
works-with(Monika,{Thomas,Ulrike})
person(Thomas)
researcher(Thomas)
group(Thomas,YQT)
heads-group(Thomas,YQT)
project(Thomas,EULISP)
person(Ulrike)
secretary(Ulrike)
group(Ulrike,YQT)
works-with(Ulrike,{Monika,Thomas})
room(C5119)
large-room(C5119)
close(C5119,{C5120})
room(C5120)
large-room(C5120)
close(C5120,{C5119})
group(YQT)
project(EULISP)
*** SUCCESS ***
Errors will be listed if a test predicate isn't found in your output file.  The search accounts for white space characters around parentheses and commas, and also accounts for optional quote marks.  One problem that may occur is the optional {} list form.  Errors found in these forms are counted as "warnings" rather than "failures".

14. In our current version we are reading the environment from a input.txt, creating all predicates and storing them, and reading the solution from another file solution.txt.
During the demo to check the validity and calculate the score, is the solution included in the test.txt as well?

I will have another file available with a solution.  I suggest, if you want to get the bonus marks, you have your program run in "comand mode" as the Test class (Test.java) does if it's given no parameters.  I implement several additional predicates to handle the situation interactively:

> !read(scripts/small.txt)
reading file scripts/small.txt...
... read 25 lines from file scripts/small.txt

> !read-solution(scripts/small.sol)
reading file scripts/small.sol...
... read 5 lines from file scripts/small.sol
Const      #        Pen      Total
-----      ---      ---      -----
   14 :      2    *  -4     =   -8
                             -----
                                -8
// Attributes: complete, solved, utility=-8, 3/3 people assigned.
Also, remember that your program must run from the command line, taking parameters (including the data file to read) from the command line.  You cannot go with constant file names.


UofC
CPSC 433: Artificial Intelligence
Department of Computer Science

Last updated 2013-01-08 23:32
Rob Kremer