# hello ,have a good day all , i need some answers of these questions...

• May 24th, 2013, 11:25 PM
sahin11
hello ,have a good day all , i need some answers of these questions...
1. Operator effect definition:
oi,j ((a1 , a2 , . . . , a12 )) = (b1 , b2 , . . . , b12 )
k = 1, 2, . . . , 12
if (a1 , a2 , . . . , a12 ) ∈ dom(oi,j )
bk =
ak + j
ak + 120
if ∃l(al > ak ) ∨ (ak + ai = 0)
otherwise
Exercise 4. Create the Java implementation for the function above as a body of a void function!
We suppose that a1 , a2 , . . . , a12 are integers, and they are accessible in the function body as a[1], a[2],
. . ., a[12], and b1 , b2 , . . . , b12 are integers, and they are accessible in the function body as b[1], b[2], . . .,
b[12].

2.

Set of operators:
O = {o1,2 , o1,3 , o2,1 , o2,3 , o3,1 , o3,2 }
Domain of operators:
dom(oi,j ) = {(a1 , a2 , . . . , a12 ) ∈ N12 | ∀k((k = j) ⊃ (ak + i > aj )) ∧ ∃k∃l(a1 = ak ∗ al )}
Exercise 3. Create the Java implementation for the preconditions above as a body of a boolean
function! We suppose that a1 , a2 , . . . , a12 are integers, and they are accessible in the function body as a[1],
a[2], . . ., a[12].

3.

Set of goal states:
G = {(a1 , a2 , . . . , a12 ) ∈ N12 | ∀i∃j((ai + aj > 20) ⊃ (ai ∗ aj < 200))}
Exercise 2. Create the Java implementation for the goal condition above as a body of a boolean
function! We suppose that a1 , a2 , . . . , a12 are integers, and they are accessible in the function body as a[1],
a[2], . . ., a[12]

4.

∀i(∃j((aj < ai ) ∨ (aj = 1000)) ⊃ (ai > 0) ∨ ∃j(aj = 50))
where i ∈ {1, 2, . . . , 6} and j ∈ {1, 2, . . . , 6}
Exercise 1. Create the Java implementation for the formula above as a body of a boolean
function! We suppose that a1 , a2 , . . . , a6 are integers, and they are accessible in the function body as a[1],
a[2], . . ., a[6].

5.

1.all i exists j a[i] > a[j] or a[1] = a[4]

all i ( exists j ( (a[j] < a[i]) or not (a[j] = 1000) ) implies ( a[i] > 0 or exists j ( a[j] = 50 ) ) )

implementation in java :

------------------------------------------------------------------------------------------------

Complete the Java implementation of the Breadth-first search

Exercise 1. Initialize the database.
Exercise 2. Construct the solution as an operator list.
Exercise 3. Complete the code of the extension.

public interface Problem {
State startState();
Collection<Operator> operators();
}
public interface State {
boolean isGoal();
}
public interface Operator {
boolean isApplicable(State s);
State apply(State s);

}

public abstract class Solver {
private static class Node {
State state;
Operator creator;
Node parent;
int deep;
public Node(State state, Operator op, Node parent ) {
this.deep = parent == null ? 0 : parent.deep + 1;
this.creator = op;
this.parent = parent;
this.state = state;
}

}
public List<Operator> run(Problem p) {
/* Exercise 1: Initialize the database. */

while ( ! openNodes.isEmpty() ) {
Node node = openNodes.removeFirst();
if ( node.state.isGoal() ) {
/* Exercise 2: Construct the solution as an operator list. */

return solution;
}
for ( Operator op : p.operators() ) {
if ( op.isApplicable(node.state) ) {
State newState = op.apply(node.state);
/* Exercise 3: Complete the code of the extension

* (use the search function below when necessary). */
}
}
}
return null;
}
private static Node search(List<Node> nodeList, State state) {
for ( Node node : nodeList )
if ( state.equals(node.state) )
return node;
return null;
}
}
• May 25th, 2013, 02:57 AM
jps
Re: hello ,have a good day all , i need some answers of these questions...
Welcome sahin11
Please see the Announcements page for the use of code tags when posting code to the forum.
If you have some questions of your own, and not those of your assignment, please post them.