cps721: questions about the 3rd assignment.  

Questions related to the 3rd assignment

This page contains questions from students and my answers to them. If a question is asked that has already been answered, then I will not post another answer. So if your questions seems to go unanswered, you should check over previous questions.

Our group have one question regarding part 1 in A3. For the first part of the question, it is clear that variable T is 1, since the result of multiplying STRAW with T is STRAW. Can we just assign the variable as 1?  Or do we need to use backtracking in order to find the correct value for this variable T? 
I said in class that you cannot embed your reasoning into a solution. In a real application, you may inadvertently make an error by trusting your ability to cut corners. Follow exactly the techniques presented in class. Let your program discover everything.

In Q1 of Assignment 3 it asks us to product cputime. How do we find cpu time? Is it Finish Time - Start Time? What is the function call?
Well, just open any Prolog (with GUI or otherwise) and read

        ?- help(cputime).
Also, try a query
        ?- statistics(session_time,X).
See what happens. Wait for 5 seconds (but do not close your session with Prolog), and try it again. See what happens. For details, read
        ?- help(statistics/2).
and pay attention to paragraph where the argument "session_time" is explained. Also, you can measure how much time your program takes using this query:
        ? statistics(session_time,Start), solve(List),
                statistics(session_time,End), T is End - Start.
Assignment says we have to use 'smart interleaving of generate and test technique.' How "smart" does our algorithm have to be? I am selecting [ . . . ]. Is this good enough to count as 'smart interleaving of generate and test technique' or do we have to use a more complicated algorithm?
Your strategy seems reasonable, but test how much time the resulting program will take. For example, try a query mentioned in the assignment including time taken to print a solution. So, let's say if your program spends 1sec or less to solve a puzzle, then interleaving in your program is smart enough.

This is a question about part 3 Are we creating rules to solve ken ken problems in general, or this particular ken ken problem.
No, this particular instance only. Solving arbitrary 4x4 kek-ken would be too difficult. Even formatting the input for an arbitrary ken-ken puzzle is a non-trivial issue. Note that similarly we do not solve arbitrary crypt-arithmetical problems, but only instances like that we discussed in class.

In Part 1, suppose that I have a constraint on the variable R coming from mutiplication, e.g., R is T*R + Carry3, but later I have another constraint on the same variable R coming from addition, e.g., R is T +W +Car1. Should this change the value of R, i.e., assign another value to R?
You have to express correctly all constraints given in this puzzle. If there are several constraints on the same letter, formulate all of them. Remember that in Prolog, once you assigned a value to a variable using "is" you cannot assign a different value in the same rule, unless your program back-tracks. So, the second "is" expression simply checks whether the value assigned previously is identical to the value of the second arithmetical expression. If not, then back-tracking will retrieve (generate) another value for the variables, and re-calculate your R in the first expression. Follow the crypt-arithmetical puzzle example that we considered in class. You can start with drawing the dependency graph.

For the scheduling of lunches are we allowed to embed the fact that all the classes will be restricted to Monday, Wednesday and Friday, and that those three days are guaranteed to have a class, or should the cool have to determine which days need lunches?
Read the pre-ambule of the 3rd assignment carefully: you are not allowed to solve any part of the problem yourself. Your program should consider all combinations and find all solutions. You lose marks if you solve a part of the problem yourself. Basically, you are expected to learn some techniques for solving CSPs and demonstrate in your solutions that you do know how to use these techniques. So, make sure that you apply methodology precisely, without taking any short-cuts.

I just had a quick question concerning Question 1 in Assignment 3. In the cryptarithmetic problem we need to solve, we are multiplying STRAW by TO, and STRAW* O = WARTS. Does this mean we have to have some constraint specifying that S*O would have to be less than 10? (Because if S*O were greater than 10, then the answer wouldn't be WARTS but CWARTS where C is the carry from S*O).
You have to formulate constraints as we did in class. In particular for this multiplication task, we have that S is (T*S+Car1000) mod 10 and this should be enough to compute S. So, there is no need to add an extra constraint "that S*O would have to be less than 10". Rememeber, you have to express faithfully all constraints given to you without adding your own thoughts regarding what the values of variables should be. If you start guessing them, or adding your personal constraints, you can make an error. Make sure you formulate all constraints correctly.

I have a question regarding question 1 from assignment 3 (the crypt-arithmetic puzzle). In the part of the problem where we are checking if the values for the variables satisfy the addition constraints (after we have successfully found values that satisfy the multiplication constraints), is there an implicit constraint for the value of S+C1000, (where C1000 is the carry-digit from the addition of T+W) to be a single digit?
You just have to formulate all constraints given to you explicitly. In particular, you need C is (S + Carry1000), and the other remaining constraints. Pay attention to the fact that distinct letters stand for distinct digits. You can add C < 10, if you really want, but it is not required to find a correct siolution.

For assignment 3, Part 3, i made an auxiliary predicate called myDivide to check if something a value is equal to  a number divided by another number. Using the / sign for this purpose seems to throw me an error, whereas using the div() built-in predicate works.  In the assignment it says we have to reimplement  the predicates, does this apply for standard prolog library such as the div() ? Also, the / gives me a solution of no. This is because sometimes the numbers will give me decimal values, am i allowed double slashes // ?
You cannot use any of the library predicates in this assignment (except of  those discussed in class). The usual division operator "/" works for me well. Perhaps,  you use it incorrectly and this is why you get an error message. Remember in Prolog you use is or =:= when you work with arithmetical expressions. Of course, you can use any arithmetical operators including // Make sure the RHS of your rule is implemented correctly and for all values of arguments your helping predicate myDivide does the correct computation.

our program displays the same result multiple times if you press “;” or “more" because (...skip...), is this okay? or do you want it to just display the answer once.
Repetitions of correct answers are OK. This applies to all assignments in cps721. I already said this about the 1st assignment. But your program should never print a solution that violates at least one constraint. If you are not sure, then check each solution manually.